I want to be able to click on a <div>
(with some text in it) and be able to scale it properly. I scale the <div>
using transform: scale(<x>)
.
The problem with the below code is that the scaling pushes the <div>
"forward" and sort of spazzes out on hovering. I effect I would like is that it pops-out, such that, it stays in the middle, but, it expands its width and height.
Example (notice the font size increases):
Sample code with the problem:
div {
position: absolute;
width: 300px;
height: 150px;
border: 1px black solid;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
display: flex;
align-items: center;
justify-content: center;
}
div:hover {
transform: scale(1.5);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div>This is a div.</div>
</body>
</html>