好吧,这是个很奇怪的问题。
我不能以我的生命为中心,在这个范围内。所以我已经把它定位了。
然而,我想要的是将蓝色数字精确地放在div内。麻烦的是,当数字变化到10时,它就会向右移动。有一个同事堆栈,帮助我的js,只是需要一些帮助,在css内对齐现在。
我不确定你是否绝对能把一个以单个数字为中心的计数器居中,两位数的数字也是居中的。
没道理吗?
K链接:测试页
Css (我知道span元素timer没有居中,但它需要居中。
无法正确显示代码的堆栈,请检查链接的源代码
任何关于数字中心化的建议,使它们成为死的水平中心。当数字跃升到10时,它不会向右或向左移动?
发布于 2010-11-27 01:09:09
移除绝对定位,将text-align: center添加到div中,在跨度中添加一个顶边距,使其垂直居中。
.content {
text-align: center;
}
.timer{
position: static;
}您不需要position: static,但是我添加了它,因为您的页面上有它在absolute上。
发布于 2010-11-27 01:04:01
只需从".timer“元素中删除"top”、"left“和"position”属性,并在".content“元素中添加”文本对齐:中心“。CSS:
.content {
height:140px;
width:240px;
border-color: #51505b;
border-style:solid;
border-width:1px;
left:500px;
position:relative;
-moz-border-radius: 6px; -webkit-border-radius: 6px;
text-align: center;
}
.timer {
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
font-size:5em;
color: #398fe8;
text-shadow: 0 1px 1px rgba(0,0,0,.3);
}
.msg {
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
color: #51505b;
text-shadow: 0 1px 1px rgba(0,0,0,.3);
}HTML:
<div class="content">
<span class="timer">10</span>
<br>
<span class="msg"></span>
</div>https://stackoverflow.com/questions/4289507
复制相似问题