0
我试过如果其他语句,它应该是相当简单的,但似乎无法逆转重新调整大小650px以上的换行。任何帮助将非常感激!!!如何在调整大小时打包然后展开div?
基要IM当试图窗口下方为650宽度GET包裹在一个DIV的复选框,然后解开后调整大小高于650像素
HTML:
<div id="cat-area">
<div id="cat-container">
<img class="box" src="http://via.placeholder.com/200x200">
<img class="box" src="http://via.placeholder.com/200x200">
<img class="box" src="http://via.placeholder.com/200x200">
<img class="box" src="http://via.placeholder.com/200x200">
</div>
</div>
CSS:
#cat-area{
width: 100%;
display: inline-block;
text-align: center;
background-color: red;
}
#cat-container{
background-color: yellow;
width: 92.5%;
margin: 0 auto;
display: flex;
justify-content: space-between;
}
.box {
display: inline-block;
width: 20%;
height: 20%;
max-height: 300px;
max-width: 300px;
min-height: 100px;
min-width: 100px;
padding: 1%;
background-color: #d7d7d7;
}
@media only screen and (max-width: 650px) {
#cat-area{
width: 100%;
display: block;
text-align: center;
background-color: red;
}
#cat-container{
background-color: blue;
width: 92.5%;
display: block;
}
.box {
position: relative;
display: block;
margin: 4px 0px;
}
.boxwrap{
background-color: #d7d7d7;
width: 100%;
}
JQUERY:
$(window).resize(function() {
if($(window).width() < 650)
$('.box').wrap("<div class='boxwrap'><div/>")
});
$(window).resize(function() {
if($(window).width() > 650)
$('.box').unwrap("<div class='boxwrap'><div/>")
});
请勿呼喊。这不是必需的。 –
$('.box')。unwrap()应该足够了,不需要指定div – TechGirl
是否有问题?如果是这样,请说明。 –