After shrinking the div, it is still in the middle.


div,div,csstransform:scale,transform-origin:left


,div,,,...
div,css,js,(vuedemo)

this is without transform-origin:left. Less centered and weirder.

Jun.20,2021

isn't the transform-origin: left in your CSS just not going to center it?


Hello, open DEMO to change the width and height of any element in the console, which will be centered. I hope it will be helpful to you!

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        div{
            position: absolute;
            width: 300px;
            height: 300px;
            background-color: red;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
    </style>
</head>
<body>
    <div id="box"></div>
</body>
</html>

I don't know what you're going to do.
will you center an element first? Well, I thought you would
for simplicity, I used this to center left:0;right:0;top:0;bottom:0;

.

http://jsrun.net/EKhKp/edit

Menu