gpt4 book ai didi

jquery - LightGallery 中的居中缩略图

转载 作者:行者123 更新时间:2023-11-28 05:46:14 24 4
gpt4 key购买 nike

我正在使用 LightGallery 制作图片库,到目前为止一切正常,但我想将整个缩略图网格与页面中心对齐。现在只是卡在左侧。这是我使用的代码:

<div class="demo-gallery">
<ul id="lightgallery" class="list-unstyled row">
<li class="col-xs-6 col-sm-4 col-md-3" data-responsive="img/alba-iulia.jpg 480, img/1.jpg 480, img/3.jpg 800" data-src="img/alba-iulia.jpg" data-sub-html="">
<a href="">
<img class="img-responsive" src="img/alba-iulia.jpg">
</a>
</li>
<li class="col-xs-6 col-sm-4 col-md-3" data-responsive="img/alba-iulia.jpg 480, img/1.jpg 480, img/3.jpg 800" data-src="img/3.jpg" data-sub-html="">
<a href="">
<img class="img-responsive" src="img/3.jpg">
</a>
</li>
<li class="col-xs-6 col-sm-4 col-md-3" data-responsive="img/alba-iulia.jpg 480, img/1.jpg 480, img/3.jpg 800" data-src="img/1.jpg" data-sub-html="">
<a href="">
<img class="img-responsive" src="img/1.jpg">
</a>
</li>
<li class="col-xs-6 col-sm-4 col-md-3" data-responsive="img/alba-iulia.jpg 375, img/1.jpg 480, img/3.jpg 800" data-src="img/alba.jpg" data-sub-html="">
<a href="">
<img class="img-responsive" src="img/alba.jpg">
</a>
</li>
</ul>
</div>

编辑:这是 CSS:

.demo-gallery{
display: inline-block;
margin-left: auto;
margin-right: auto;
width: 1120px;
margin-top: 50px;
}

.demo-gallery > ul {
margin-bottom: 0;
}
.demo-gallery > ul > li {
float: left;
margin-bottom: 15px;
margin-right: 0px;
width: 280px;
}
.demo-gallery > ul > li a {
border: 3px solid #FFF;
border-radius: 3px;
display: block;
overflow: hidden;
position: relative;
float: left;
text-align: center;
}
.demo-gallery > ul > li a > img {
-webkit-transition: -webkit-transform 0.15s ease 0s;
-moz-transition: -moz-transform 0.15s ease 0s;
-o-transition: -o-transform 0.15s ease 0s;
transition: transform 0.15s ease 0s;
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1);
height: 100%;
width: 100%;
}
.demo-gallery > ul > li a:hover > img {
-webkit-transform: scale3d(1.1, 1.1, 1.1);
transform: scale3d(1.1, 1.1, 1.1);
}
.demo-gallery > ul > li a:hover .demo-gallery-poster > img {
opacity: 1;
}
.demo-gallery > ul > li a .demo-gallery-poster {
background-color: rgba(0, 0, 0, 0.1);
bottom: 0;
left: 0;
position: absolute;
right: 0;
top: 0;
-webkit-transition: background-color 0.15s ease 0s;
-o-transition: background-color 0.15s ease 0s;
transition: background-color 0.15s ease 0s;
}
.demo-gallery > ul > li a .demo-gallery-poster > img {
left: 50%;
margin-left: -10px;
margin-top: -10px;
opacity: 0;
position: absolute;
top: 50%;
-webkit-transition: opacity 0.3s ease 0s;
-o-transition: opacity 0.3s ease 0s;
transition: opacity 0.3s ease 0s;
}
.demo-gallery > ul > li a:hover .demo-gallery-poster {
background-color: rgba(0, 0, 0, 0.5);
}
.demo-gallery .justified-gallery > a > img {
-webkit-transition: -webkit-transform 0.15s ease 0s;
-moz-transition: -moz-transform 0.15s ease 0s;
-o-transition: -o-transform 0.15s ease 0s;
transition: transform 0.15s ease 0s;
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1);
height: 100%;
width: 100%;
}
.demo-gallery .justified-gallery > a:hover > img {
-webkit-transform: scale3d(1.1, 1.1, 1.1);
transform: scale3d(1.1, 1.1, 1.1);
}
.demo-gallery .justified-gallery > a:hover .demo-gallery-poster > img {
opacity: 1;
}
.demo-gallery .justified-gallery > a .demo-gallery-poster {
background-color: rgba(0, 0, 0, 0.1);
bottom: 0;
left: 0;
position: absolute;
right: 0;
top: 0;
-webkit-transition: background-color 0.15s ease 0s;
-o-transition: background-color 0.15s ease 0s;
transition: background-color 0.15s ease 0s;
}
.demo-gallery .justified-gallery > a .demo-gallery-poster > img {
left: 50%;
margin-left: -10px;
margin-top: -10px;
opacity: 0;
position: absolute;
top: 50%;
-webkit-transition: opacity 0.3s ease 0s;
-o-transition: opacity 0.3s ease 0s;
transition: opacity 0.3s ease 0s;
}
.demo-gallery .justified-gallery > a:hover .demo-gallery-poster {
background-color: rgba(0, 0, 0, 0.5);
}
.demo-gallery .video .demo-gallery-poster img {
height: 48px;
margin-left: -24px;
margin-top: -24px;
opacity: 0.8;
width: 48px;
}
.demo-gallery.dark > ul > li a {
border: 3px solid #04070a;
}
.home .demo-gallery {
padding-bottom: 80px;
}

我在一篇文章中读到我应该使用 margin-left: auto 和 margin-right: auto(我在 ul 上使用它但似乎不起作用。)感谢您的帮助!

最佳答案

用下面的代码替换你的代码,将解决你的问题:

<div class="demo-gallery">
<ul id="lightgallery" class="list-unstyled row">
<li class="col-xs-6 col-sm-4 col-md-3" data-responsive="img/alba-iulia.jpg 480, img/1.jpg 480, img/3.jpg 800" data-src="img/alba-iulia.jpg" data-sub-html="">
<a href="">
<img class="img-responsive text-center" src="img/alba-iulia.jpg">
</a>
</li>
<li class="col-xs-6 col-sm-4 col-md-3" data-responsive="img/alba-iulia.jpg 480, img/1.jpg 480, img/3.jpg 800" data-src="img/3.jpg" data-sub-html="">
<a href="">
<img class="img-responsive text-center" src="img/3.jpg">
</a>
</li>
<li class="col-xs-6 col-sm-4 col-md-3" data-responsive="img/alba-iulia.jpg 480, img/1.jpg 480, img/3.jpg 800" data-src="img/1.jpg" data-sub-html="">
<a href="">
<img class="img-responsive text-center" src="img/1.jpg">
</a>
</li>
<li class="col-xs-6 col-sm-4 col-md-3" data-responsive="img/alba-iulia.jpg 375, img/1.jpg 480, img/3.jpg 800" data-src="img/alba.jpg" data-sub-html="">
<a href="">
<img class="img-responsive text-center" src="img/alba.jpg">
</a>
</li>
</ul>
</div>

关于jquery - LightGallery 中的居中缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37587890/

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