我希望价格和货币居中?最好的方法是什么?
.currency {
background: url(../css/images/currency.png);
background-size: 30px;
background-repeat: no-repeat;
background-position-x: center;
background-position-y: center;
}
<div id="price1" class="pricebox">
<div class="titleabo"><strong>3</strong>jours</div>
<div class="price">
<div class="howmuch">300<div class="currency"></div></div>
</div>
</div>
答案 0 :(得分:0)
div
必须定义text-align
请参阅以下内容:
添加边框以便更好地观看
.currency {
background: url(../css/images/currency.png);
background-size: 30px;
background-repeat: no-repeat;
background-position-x: center;
background-position-y: center;
}
.pricebox{
width: 100px;
border: 1px solid #333;
}
.price{
text-align: center;
}
<div id="price1" class="pricebox">
<div class="titleabo"><strong>3</strong>jours</div>
<div class="price"><div class="howmuch">300<div class="currency"></div> </div></div>
答案 1 :(得分:0)
我找到了一种方法,我只是添加了一个img而不是带有背景的div,并使用了&#34; text-align:center&#34;不知道它实际上是用图像