【发布时间】:2020-07-10 18:19:34
【问题描述】:
我正在使用带有 Bootstrap 的 jumbotron 的媒体查询。我想在 jumbotron 中垂直对齐两个 div 以实现移动响应。问题是,在一定的宽度下,jumbotron 会像预期的那样响应地拍打,而我在右边的照片会停留在那里,而不是与第一个 div 垂直对齐。
为了防止这种情况,我添加了媒体查询以将照片对齐到其父 div 的左侧,但我没有得到结果。
附上代码和图片。
<div class="jumbotron">
<div class="row">
<div id="about2" class="col-md-6">
<h1>About Me</h1>
<p>This page contains a brief information about Mehmet Eyüpoğlu.
</p>
<a href="index.html">
<i id="home-button" class="fas fa-home"></i>
</a>
</div>
<div class="col-md-6">
<img id="about-foto" src="images/unnamed.jpg" alt="profile.photo">
</div>
</div>
</div>
CSS代码:
#about2 {
font-size: 35px;
margin-top: 50px;
}
#about-foto {
max-width: 70%;
border-radius: 10px;
margin-left: 60%;
}
//The actual problem starts here:
@media (max-width: 768px) {
#about-foto {
margin-left: 5%;
}
}
【问题讨论】:
标签: html css twitter-bootstrap media-queries