我有一个游戏正在进行中,我正在做 hitsplats 以在你击中对手时出现在你的照片上。我使用的是绝对位置,但我遇到了一个问题。问题是,如果我调整窗口大小或者我在另一个分辨率下,这些点不是我最初设置它们的方式。将我的命中 splats 置于相对模式只会移动东西。那么我怎样才能像现在使用 Absolute 一样让我的 hitsplats 位于中心,但又不使它们绝对绝对?所以它们会随文档一起流动?
#npchitbox {
width: 50px;
height: 50px;
position: absolute;
background-color:blue;
z-index: 11;
top: 100px;
left: 1050px;
text-align: center;
font-weight: bold;
font-size: 50px;
color: red;
}
这是HTML代码
<div id="playerbox">
<div id="hitbox"> </div>
最佳答案
你能显示 html 并且你只是试图将 hisplate 居中吗?如果是这样就这样做
{
margin: auto;
position: absolute;
top: 0; bottom:0; right:0; left:0;
}
关于html - CSS3 : How can I get something that works like "absolute" but isn't?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19697190/