是否有其他方法来包装具有flex-wrap
属性的这些图片项?现在我使用body {
margin: 0px;
}
img {}
h1 {}
p {}
a {
background-color: #ddd;
border: 1px solid #000;
padding: 10px 20px;
margin: 10px;
}
.container {
display: flex;
flex-wrap: wrap;
}
.item {
background-color: #eee;
padding: 10px;
margin: 10px;
}
属性包装它们,但那里还有它们吗?
<div class="container">
<div class="item">
<img src="http://lorempixel.com/1024/512/" alt="">
<h1>Title 1</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
<div class="item">
<img src="http://lorempixel.com/512/512/" alt="">
<h1>Title 2</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
<div class="item">
<img src="http://lorempixel.com/1024/512/" alt="">
<h1>Title 3</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
<div class="item">
<img src="http://lorempixel.com/512/256/" alt="">
<h1>Title 4</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
<div class="item">
<img src="http://lorempixel.com/512/512/" alt="">
<h1>Title 5</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
<div class="item">
<img src="http://lorempixel.com/1024/512/" alt="">
<h1>Title 6</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
<div class="item">
<img src="http://lorempixel.com/512/512/" alt="">
<h1>Title 7</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
</div>
&#13;
os.system(r'PATH_TO_EXE')
&#13;
答案 0 :(得分:1)
使用flex-wrap: wrap
的替代方法是使用媒体查询从flex-direction: row
切换到column
。
body {
margin: 0px;
}
img {}
h1 {}
p {}
a {
background-color: #ddd;
border: 1px solid #000;
padding: 10px 20px;
margin: 10px;
}
.container {
display: flex;
/* flex-wrap: wrap; */
}
.item {
background-color: #eee;
padding: 10px;
margin: 10px;
}
@media ( max-width: 500px ) {
.container {
flex-direction: column;
}
<div class="container">
<div class="item">
<img src="http://lorempixel.com/1024/512/" alt="">
<h1>Title 1</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
<div class="item">
<img src="http://lorempixel.com/512/512/" alt="">
<h1>Title 2</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
<div class="item">
<img src="http://lorempixel.com/1024/512/" alt="">
<h1>Title 3</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
<div class="item">
<img src="http://lorempixel.com/512/256/" alt="">
<h1>Title 4</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
<div class="item">
<img src="http://lorempixel.com/512/512/" alt="">
<h1>Title 5</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
<div class="item">
<img src="http://lorempixel.com/1024/512/" alt="">
<h1>Title 6</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
<div class="item">
<img src="http://lorempixel.com/512/512/" alt="">
<h1>Title 7</h1>
<a href="#">Link</a>
<p>Lorizzle ipsizzle dolor shizzle my nizzle crocodizzle amizzle, yo mamma fo shizzle mah nizzle fo rizzle, mah home g-dizzle elit. Nullizzle mofo velizzle, dizzle volutpizzle, suscipizzle fo shizzle, phat vizzle, fizzle. Pellentesque eget rizzle. Sizzle
erizzle. Shizzle my nizzle crocodizzle izzle bling bling dapibus turpis tempizzle crunk.</p>
</div>
</div>
答案 1 :(得分:0)
flex的另一种替代方法是删除容器上的display: flex
并在所有项目图片上使用display: inline-block
。
.item{
display: inline-block;
background-color: #eee;
padding: 10px;
margin: 10px;
}
答案 2 :(得分:0)