【发布时间】:2021-02-15 13:13:52
【问题描述】:
使用 Flexbox,在移动设备上,其父容器的宽度/最大宽度不会受到尊重。
@media (max-width: 767px) {
.table-responsive tr {display: inline-flex; flex-wrap: wrap;}
.table-responsive td.td-smaller {flex: 98%; max-width: 98%;}
.table-responsive td.td-larger {flex: 98%; max-width: 98%;}
}
td.td-smaller & td.td-larger 在视口宽度为 500 像素时打破其父容器的宽度。
.table-responsive {overflow-x: hidden;}
.table-responsive tr {display: inline-flex; justify-content: space-between; border-collapse: separate;}
.table-responsive td.td-smaller {flex: 38%; max-width: 38%;}
.table-responsive td.td-larger {flex: 58%; max-width: 58%;}
.table-responsive img {border-radius: 10px; max-width: 100%; height: auto;}
.table-responsive p {width: 500px; max-width: 100%;}
@media (max-width: 991px) {
.table-responsive td.td-smaller {flex: 48%; max-width: 48%;}
.table-responsive td.td-larger {flex: 48%; max-width: 48%;}
}
@media (max-width: 767px) {
.table-responsive tr {display: inline-flex; flex-wrap: wrap;}
.table-responsive td.td-smaller {flex: 98%; max-width: 98%;}
.table-responsive td.td-larger {flex: 98%; max-width: 98%;}
}
<table class="table-responsive">
<tbody>
<tr>
<td class="td-smaller"><img loading="lazy" class="alignleft size-full wp-image-230 border-radius" src="//herodevelopment.com.au/allbathroomgear/wp-content/uploads/2021/02/dark-bathrooms-Brisbane.jpg" alt="dark bathrooms Brisbane" width="1200" height="800" sizes="(max-width: 1200px) 100vw, 1200px"></td>
<td class="td-larger">
<h2 class="bottom-border-left">40+ 5-Star Reviews & Counting</h2>
<p><img loading="lazy" class="size-full wp-image-231 alignnone" src="//herodevelopment.com.au/allbathroomgear/wp-content/uploads/2021/02/5-stars.png" alt="5 star review" width="142" height="25"></p>
<p>“Absolutely brilliant service by Paul and the team in creating our dream bathrooms.”</p>
<p>—Upekha Edirisinghe</p>
<p><a class="btn btn-black" href="#">More Reviews</a></p></td>
</tr>
</tbody>
</table>
这就是in development的样子:
【问题讨论】:
-
您能用图片说明问题所在吗?这似乎可以正常工作,直到您降低到 ~188px 视口宽度。
-
@SRDMH 我能知道使用
table的原因吗?