css文本不对齐
问题描述:
我有一个问题,集中我的div内的文本。有人可以帮我对齐这个文本框css文本不对齐
这里的中心就是我的CSS:
#btc-container {
height: 50px;
width: 150px;
background: orange;
border: 2px solid;
border-radius: 25px;
bottom: 50px;
left: 0px;
border-style: ridge;
}
#btc-price {
color: black;
font-family: digital-7;
font-size: 30px;
alignment-adjust:middle;
}
这里是我的HTML:
<div id="btc-container">
<div id="btc-price">930.1234</div>
</div>
答
只要改变你的css是这样的:
#btc-price {
color: black;
font-family: digital-7;
font-size: 30px;
text-align: center;
line-height: 50px; // or what ever is your button height
}
答
以居中对齐文字使用text-align: center
。垂直对齐它会变得更加复杂(特别是如果你想跨浏览器和/或需要支持旧浏览器),但一个简单的方法垂直居中文本内部文本,如果你知道它只有一条线正在使用line-height
像line-height:50px
情况
答
这里是一个小提琴:http://jsfiddle.net/digitalextremist/QXT5B/
更改后的CSS:
#btc-container {
height: 40px;
width: 130px;
background: orange;
border: 2px solid;
border-radius: 25px;
bottom: 50px;
left: 0px;
border-style: ridge;
padding: 5px 15px;
text-align: center
}
请发布呈现的HTML,而不是PHP。 – j08691
text-align:center; –