我在 div 中有一个标签。我想将标签放在 div 的中间,将文本放在标签的左侧,垂直居中对齐。如果没有填充和边距,我怎么能做到这一点?
<div class="center">
<label style="width:255px;height:40px;display:inline-block;float:center">Test</label>
</div>
.center {
padding:0px;
background:#B3B3B3;
height:44px;
width:400px;
border-top:2px solid red;
border-bottom:2px solid red;
border-left:2px solid red;
border-right:2px solid red;
}
label{
border-top:2px solid yellow;
border-bottom:2px solid yellow;
border-left:2px solid yellow;
border-right:2px solid yellow;
}
最佳答案
最好的方法是添加margin: 0px auto;
标签。
您还可以使用 border: 2px solid red;
拍摄边框代码
border: <border-width> || <border-style> || <color>
关于css - 使用 css 的标签定位不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14603397/