gpt4 book ai didi

jquery - 固定宽度的标题和带有同位素/砌体的流体图像

转载 作者:行者123 更新时间:2023-11-28 07:38:18 24 4
gpt4 key购买 nike

我在页面上有一个固定宽度的标题和大量图像。我想让它们与屏幕截图中显示的一样。

enter image description here

图像宽度可变,最大可达 200 像素。我尝试了以下代码,但它不起作用。图片与标题重叠,图片之间有一个小空间。

$(function() {
$('.grid').isotope({
itemSelector: '.item',
percentPosition: true,
masonry: {
columnWidth: ''
}
});
});
.container {
width: 1024px;
margin: 0 auto;
}
body {
margin: 0;
}
.header {
width: 300px;
height: 40px;
background-color: #0fa3c3;
float: left;
}
.item {
width: 20%;
float: left;
}
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.isotope/2.2.0/isotope.pkgd.min.js"></script>
<div class="container">
<div class="grid">
<div class="header"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
</div>
</div>

最佳答案

试试这个..我也给了标题绝对位置..和 2 的 z-index,现在试试吧。

$(function() {
$('.grid').isotope({
itemSelector: '.item',
percentPosition: true,
masonry: {
columnWidth: ''
}
});
});
.container {
//width: 1024px;
//margin: 0 auto;
}
body {
margin: 0;
}
.header {
width: 300px;
height: 40px;
background-color: #0fa3c3;
float: left;
position: absolute;
z-index: 2;
}
.item {
width: 20%;
float: left;
}
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.isotope/2.2.0/isotope.pkgd.min.js"></script>
<div class="container">
<div class="grid">
<div class="header"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
<div class="item"><img src="http://lorempixel.com/200/300/"></div>
</div>
</div>

关于jquery - 固定宽度的标题和带有同位素/砌体的流体图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31104075/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com