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
是否有問題?如果是這樣,請說明。 –