当我将其设置为绝对时,我想控制它
我尝试让它向左30%向右30%,然后我给了顶部一个特定的像素,当它到达我想要的位置时,它被压扁了我应该做什么,因为我想给它一个最大宽度
position: absolute;
left: 0;
right: 0;
margin: auto;
top: 100px; /* Adjust the top position as needed */
max-width: 500px; /* Adjust the maximum width as needed */
}```
This will center the absolute div horizontally within its container and give it a maximum width, preventing it from becoming squished when the viewport width changes. You can adjust the values for top and max-width to suit your design requirements.