这段代码生成了一个序列:block,text,block,text,block,text 它看起来是正确的除了我不能让文本在 div 的中心垂直对齐所以它看起来像它对齐的垂直靠近盒子的中心。有什么建议吗?
<div style="position: absolute; right: 0; top: 0; text-align: right;">
<span style="display: inline-block; width: 15px; height: 15px; background: #2880BB"></span>
<span style="display: inline-block">Created </span>
<span style="display: inline-block; width: 15px; height: 15px; background: #7FC31B"></span>
<span style="margin-left: 5px;">Won </span>
<span style="display: inline-block; width: 15px; height: 15px; background: #FD2A2F"></span>
<span style="margin-left: 5px;">Lost </span>
</div>
最佳答案
替代解决方案:
<div style="position: absolute; right: 0; top: 0; text-align: right;">
<span style="border-left: 15px solid #2880BB; padding-left: 5px;">Created</span>
<span style="border-left: 15px solid #7FC31B; margin-left: 5px; padding-left: 5px">Won</span>
<span style="border-left: 15px solid #FD2A2F; margin-left: 5px; padding-left: 5px">Lost</span>
</div>
jsFiddle:http://jsfiddle.net/w2wVc/1/
关于html - Div格式: center text vertically,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12286771/