[英]align text and image in center of div
I have div and two components in it, logo and phone number. 我有div和两个组成部分,徽标和电话号码。 I managed to place logo in center of div, but phone number is not exactly in the center: 我设法将徽标放置在div的中心,但电话号码不完全位于div的中心:
I want a phone number a little bit (text.height / 2) down. 我想要一个电话号码(text.height / 2)下来。 How to do this? 这个怎么做?
<div class="payments-mobile-cash-insert-round-corner-div payments-mobile- cash-insert-number-box">
<img id="service-logo" src="//:0"
data-bind="attr: { src: paymentService.image }"/>
<span id="phone-number" class="textstyle-4"
data-bind="text: infoLines[0].value">
</span>
</div>
.payments-mobile-cash-insert-round-corner-div{
margin: auto;
border: 1px solid #dfdfdf;
border-radius: 7px;
width: 1170px;
text-align: center;
}
.payments-mobile-cash-insert-number-box {
height: 196px;
}
.payments-mobile-cash-insert-number-box img{
vertical-align: middle;
}
.payments-mobile-cash-insert-number-box span{
margin-left: 50px;
font-size: 62px;
line-height: 196px;
vertical-align: middle;
}
Add this code in your css file for the phone number component, 在您的css文件中为电话号码组件添加此代码,
.height{
padding-top:10px;
padding-left:5px;
}
in your html code, add the following line to class attribute section of phone number component, 在您的html代码中,将以下行添加到电话号码组件的class属性部分,
class="height"
Please try it this css.. 请尝试此CSS。
.class
{
display: table-cell;
float: none;
vertical-align: middle;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.