我的 HTML 代码--
<div class="Card">
<div class="FestivalPhoto"><img src="Image/test1.jpg" width="300px" alt="MusicFestivalImage"></div>
<div class="FestivalDetails">Hello World</div>
</div>
<div class="Card">
<div class="FestivalPhoto"><img src="Image/test1.jpg" width="300px" alt="MusicFestivalImage"></div>
<div class="FestivalDetails">Hello World</div>
</div>
<div class="Card">
<div class="FestivalPhoto"><img src="Image/test1.jpg" width="300px" alt="MusicFestivalImage"></div>
<div class="FestivalDetails">Hello World</div>
</div>
这是我的 CSS——
.Card {
background: #fff;
border-radius: 2px;
display: inline-block;
height: 500px;
margin: 1rem;
position: relative;
width: 300px;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
padding: 30px auto;
overflow: hidden;
justify-content: center;
}
.FestivalDetails {
position: absolute;
width:auto;
max-width: 500px;
height: auto;
display: block;
padding: 20px 20px;
}
.FestivalPhoto {
height: 200px;
width: auto;
position: relative;
top: 0;
display: block;
overflow: hidden;
margin: auto;
background-size: initial;
}
@media(max-width: 700) {
.Card {
background: #000;
border-radius: 2px;
display: block;
height: 500px;
margin: auto;
position: relative;
width: 80%;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
padding: 30px auto;
overflow: hidden;
}
}
我正在尝试将 Card div 设置为“margin: auto;” 在移动设备上但它不起作用。我还添加了 head 标签。请建议我。现在我正在 Chrome 和 Firefox 开发者控制台上测试响应式。有没有更好的测试方法?谢谢。
慕勒3428872
波斯汪
至尊宝的传说
相关分类