Hal*_*NAL 12 css positioning center
我想DIV在中心左侧放置一个200像素.
我目前正在使用以下代码,但在更高分辨率的显示器(例如1920×1080)上,DIV正在滑出位置:
.hsonuc {
position: absolute;
top: 20px;
margin:auto;
margin-left:200px;
display:none;
}
Run Code Online (Sandbox Code Playgroud)

0b1*_*011 20
只需50%从右侧(right:50%;)定位它,然后使用margin-right:200px;(示例)将其推过.
<div class="hsonuc">DIV</div>
Run Code Online (Sandbox Code Playgroud)
.hsonuc {
position:absolute;
top:20px;
right:50%; /* Positions 50% from right (right edge will be at center) */
margin-right:200px; /* Positions 200px to the left of center */
}
Run Code Online (Sandbox Code Playgroud)