我想要做的是根据广告框中图像的高度垂直对齐记分框中的中间文字(h3)。我已经尝试了几种方法使它工作,但直到现在都没有成功。我也很好奇div如何使用盒子大小调整(在我的情况下为.ads-box& .score-box)可以设置相同的高度。提前谢谢!
.current-scores {
display: table;
width: 100%;
color: #ffffff;
background-color: #01DFA5;
}
.current-scores .ads-box {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 80%;
text-align: center;
padding: 8px 10px;
margin: 0;
float: left;
}
.current-scores .score-box {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 20%;
text-align: center;
padding: 8px 10px;
margin: 0;
float: left;
}
.current-scores .score-box h3 {
font-size: 16px;
line-height: 18px;
font-weight: bold;
margin: 5px 0 0;
padding: 0;
}
<div class="current-scores">
<div class="ads-box">
<img class="img-responsive" src="https://s3.amazonaws.com/images.seroundtable.com/google-mobile-app-ad-1347454342.png" />
</div>
<div class="score-box">
<h3>IND Vs AUS</h3>
<h3>IND - 153/0</h3>
</div>
<div style="clear:both;"></div>
</div>
答案 0 :(得分:0)
更新了您的css .current-scores
和.current-scores .score-box
/*Current Scores and Schedules*/
.current-scores {
display: table;
/*position: fixed;
left: 0;
right: 0;
bottom: 0; */
overflow: hidden;
width: 100%;
color: #ffffff;
background-color: #01DFA5;
padding: 0;
margin: 0;
position:relative;
}
.current-scores .ads-box {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 80%;
text-align: center;
padding: 8px 10px;
margin: 0;
float: left;
}
.current-scores .score-box {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 20%;
text-align: center;
padding: 8px 10px;
margin: 0;
float: right;
position:absolute;
top:50%;
margin-top:-2em;
right:0px;
z-index:1000;
}
.current-scores .ads-box img {
width: 100%;
height: auto;
}
.current-scores .score-box h3 {
font-size: 16px;
line-height: 18px;
font-weight: bold;
margin: 5px 0 0;
padding: 0;
text-transform: uppercase;
text-shadow: -1px 2px 3px rgba(30, 30, 30, 0.8);
}
答案 1 :(得分:0)
position:relative;
transform:translate(-50%,-50%);
left:50%;
top: <number>%;