html - Div格式: center text vertically

标签 html css

这段代码生成了一个序列: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/

相关文章:

css - PrimeFaces Tabview - 调整选项卡的宽度

html - 导航栏中元素的对齐

html -::-webkit-inner-spin-button 在 Firefox 上显示

Python file.write 在 html 标签内

html - 图像与文本对齐 -CSS/HTML

javascript - 如何更改ant-design Tabs默认边框颜色

python - Selenium Python : Can't Get Path To Chat Element On Google Hangouts

javascript - 单击 UI 网格上的链接时的 Bootstrap Modal

html - 如何在html中设置自定义光标?

javascript - 如何在angularjs中的div元素上附加父子div?