- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用光滑的 slider 设置图片库,我想在分辨率 > 1024px 的大屏幕上更改 slider 的布局,就像在 1023px 屏幕上一样。(通过在另一个上方显示一个 slider )我需要改变什么?或添加?
"the result I want on big screens"
我花时间尝试更改值和设置,但没有达到令人满意的结果。所以我走到了死胡同。
const $left = $(".left");
const $gl = $(".gallery");
const $gl2 = $(".gallery2");
const $photosCounterFirstSpan = $(".photos-counter span:nth-child(1)");
$gl2.on("init", (event, slick) => {
$photosCounterFirstSpan.text(`${slick.currentSlide + 1}/`);
$(".photos-counter span:nth-child(2)").text(slick.slideCount);
});
$gl.slick({
rows: 0,
slidesToShow: 2,
arrows: false,
draggable: false,
useTransform: false,
mobileFirst: true,
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 3
}
},
{
breakpoint: 1023,
settings: {
slidesToShow: 1,
vertical: true
}
}
]
});
$gl2.slick({
rows: 0,
useTransform: false,
prevArrow: ".arrow-left",
nextArrow: ".arrow-right",
fade: true,
asNavFor: $gl
});
function handleCarouselsHeight() {
if (window.matchMedia("(min-width: 1024px)").matches) {
const gl2H = $(".gallery2").height();
$left.css("height", gl2H);
} else {
$left.css("height", "auto");
}
}
$(window).on("load", () => {
handleCarouselsHeight();
setTimeout(() => {
$(".loading").fadeOut();
$("body").addClass("over-visible");
}, 300);
});
$(window).on(
"resize",
_.debounce(() => {
handleCarouselsHeight();
/*You might need this code in your projects*/
//$gl1.slick("resize");
//$gl2.slick("resize");
}, 200)
);
$(".gallery .item").on("click", function() {
const index = $(this).attr("data-slick-index");
$gl2.slick("slickGoTo", index);
});
$gl2.on("afterChange", (event, slick, currentSlide) => {
$photosCounterFirstSpan.text(`${slick.currentSlide + 1}/`);
});
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
img {
max-width: 100%;
height: auto;
}
button {
background: none;
border: none;
outline: none;
cursor: pointer;
}
body {
font: normal 18px/1.5 monospace;
overflow: hidden;
background: #424242;
}
.over-visible {
overflow: visible;
}
.loading {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: flex;
align-items: center;
justify-content: center;
z-index: 2;
background: white;
}
.container {
max-width: 880px;
padding: 20px 10px;
margin: 0 auto;
}
.synch-carousels {
position: relative;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.synch-carousels > * {
width: 100%;
}
.synch-carousels .right {
order: -1;
}
.synch-carousels .left {
overflow: hidden;
}
.synch-carousels .gallery {
display: none;
}
.synch-carousels .slick-slide {
outline: none;
}
.synch-carousels .slick-vertical .slick-slide {
border: none;
}
.synch-carousels .gallery .slick-list {
height: auto !important;
margin: 0 -20px;
}
.synch-carousels .gallery .slick-slide {
cursor: pointer;
}
.synch-carousels .gallery .slick-slide {
margin: 0 20px;
}
.synch-carousels .nav-arrows {
display: flex;
position: absolute;
bottom: -50px;
left: 50%;
transform: translateX(-50%);
}
.synch-carousels .nav-arrows svg {
fill: white;
}
.synch-carousels .arrow-left {
margin-right: 35px;
}
.synch-carousels .photos-counter {
position: absolute;
top: 10px;
right: 0;
padding: 0 20px;
color: white;
background: #292929;
}
@media screen and (min-width: 480px) {
.synch-carousels .right {
margin-bottom: 20px;
}
.synch-carousels .gallery {
display: block;
}
}
@media screen and (min-width: 1024px) {
.synch-carousels .right {
position: relative;
width: calc(100% - 230px);
margin-bottom: 0;
order: 2;
}
.synch-carousels .left {
width: 210px;
}
.synch-carousels .gallery .slick-slide {
margin: 0 0 20px 0;
}
.synch-carousels .gallery .slick-list {
margin: 0;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css" rel="stylesheet"/>
<div class="loading">Carousel is loading...</div>
<div class="container">
<div class="synch-carousels">
<div class="left child">
<div class="gallery">
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery1.jpg" alt="">
</div>
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery2.jpg" alt="">
</div>
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery3.jpg" alt="">
</div>
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery4.jpg" alt="">
</div>
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery5.jpg" alt="">
</div>
</div>
</div>
<div class="right child">
<div class="gallery2">
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery1.jpg" alt="" />
</div>
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery2.jpg" alt="" />
</div>
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery3.jpg" alt="" />
</div>
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery4.jpg" alt="" />
</div>
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery5.jpg" alt="" />
</div>
</div>
<div class="nav-arrows">
<button class="arrow-left">
<!--SVGs from iconmonstr.com-->
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="M2.117 12l7.527 6.235-.644.765-9-7.521 9-7.479.645.764-7.529 6.236h21.884v1h-21.883z"/></svg>
</button>
<button class="arrow-right">
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="M21.883 12l-7.527 6.235.644.765 9-7.521-9-7.479-.645.764 7.529 6.236h-21.884v1h21.883z"/></svg>
</button>
</div>
<div class="photos-counter">
<span></span><span></span>
</div>
</div>
</div>
</div>
我希望 UI 在大于 1024 像素的屏幕上以与在 1023 像素屏幕上类似的方式执行,以在另一个上方显示一个 slider ,而不是彼此相邻。
最佳答案
更改 min-width: 9999px 在 css 中的值并在你的 js 中修改这一行 if (window.matchMedia("(min-width: 9999px)").matches)
const $left = $(".left");
const $gl = $(".gallery");
const $gl2 = $(".gallery2");
const $photosCounterFirstSpan = $(".photos-counter span:nth-child(1)");
$gl2.on("init", (event, slick) => {
$photosCounterFirstSpan.text(`${slick.currentSlide + 1}/`);
$(".photos-counter span:nth-child(2)").text(slick.slideCount);
});
$gl.slick({
rows: 0,
slidesToShow: 2,
arrows: false,
draggable: false,
useTransform: false,
mobileFirst: true,
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 3
}
},
{
breakpoint: 9999,
settings: {
slidesToShow: 1,
vertical: true
}
}
]
});
$gl2.slick({
rows: 0,
useTransform: false,
prevArrow: ".arrow-left",
nextArrow: ".arrow-right",
fade: true,
centerMode: true,
asNavFor: $gl
});
function handleCarouselsHeight() {
if (window.matchMedia("(min-width: 9999px)").matches) {
const gl2H = $(".gallery2").height();
$left.css("height", gl2H);
} else {
$left.css("height", "auto");
}
}
$(window).on("load", () => {
handleCarouselsHeight();
setTimeout(() => {
$(".loading").fadeOut();
$("body").addClass("over-visible");
}, 300);
});
$(window).on(
"resize",
_.debounce(() => {
handleCarouselsHeight();
/*You might need this code in your projects*/
//$gl1.slick("resize");
//$gl2.slick("resize");
}, 200)
);
$(".gallery .item").on("click", function() {
const index = $(this).attr("data-slick-index");
$gl2.slick("slickGoTo", index);
});
$gl2.on("afterChange", (event, slick, currentSlide) => {
$photosCounterFirstSpan.text(`${slick.currentSlide + 1}/`);
});
$('.gallery2').slickLightbox({
itemSelector : 'a',
navigateByKeyboard : true
});
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
img {
max-width: 100%;
height: auto;
}
button {
background: none;
border: none;
outline: none;
cursor: pointer;
}
body {
font: normal 18px/1.5 monospace;
overflow: hidden;
background: #424242;
}
.over-visible {
overflow: visible;
}
.loading {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: flex;
align-items: center;
justify-content: center;
z-index: 2;
background: white;
}
.container {
max-width: 880px;
padding: 20px 10px;
margin: 0 auto;
}
.synch-carousels {
position: relative;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.synch-carousels > * {
width: 100%;
}
.synch-carousels .right {
order: -1;
}
.synch-carousels .left {
overflow: hidden;
}
.synch-carousels .gallery {
display: none;
}
.synch-carousels .slick-slide {
outline: none;
}
.synch-carousels .slick-vertical .slick-slide {
border: none;
}
.synch-carousels .gallery .slick-list {
height: auto !important;
margin: 0 -20px;
}
.synch-carousels .gallery .slick-slide {
cursor: pointer;
}
.synch-carousels .gallery .slick-slide {
margin: 0 20px;
}
.synch-carousels .nav-arrows {
display: flex;
position: absolute;
bottom: -50px;
left: 50%;
transform: translateX(-50%);
}
.synch-carousels .nav-arrows svg {
fill: white;
}
.synch-carousels .arrow-left {
margin-right: 35px;
}
.synch-carousels .photos-counter {
position: absolute;
top: 10px;
right: 0;
padding: 0 20px;
color: white;
background: #292929;
}
@media screen and (min-width: 480px) {
.synch-carousels .right {
margin-bottom: 20px;
}
.synch-carousels .gallery {
display: block;
}
}
@media screen and (min-width: 9999px) {
.synch-carousels .right {
position: relative;
width: calc(100% - 230px);
margin-bottom: 0;
order: 2;
}
.synch-carousels .left {
width: 210px;
}
.synch-carousels .gallery .slick-slide {
margin: 0 0 20px 0;
}
.synch-carousels .gallery .slick-list {
margin: 0;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css" rel="stylesheet"/>
<link href="https://mreq.github.io/slick-lightbox/dist/slick-lightbox.css" rel="stylesheet"/>
<script src="https://mreq.github.io/slick-lightbox/dist/slick-lightbox.js"></script>
<div class="loading">Carousel is loading...</div>
<div class="container">
<div class="synch-carousels">
<div class="left child">
<div class="gallery">
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery1.jpg" alt="Image One">
</div>
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery2.jpg" alt="Image Two">
</div>
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery3.jpg" alt="Image Three">
</div>
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery4.jpg" alt="Image Four">
</div>
<div class="item">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery5.jpg" alt="Image Five">
</div>
</div>
</div>
<div class="right child">
<div class="gallery2">
<div class="item">
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery1.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery1.jpg" alt="Image One" />
</a>
</div>
<div class="item">
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery2.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery2.jpg" alt="Image Two" />
</a>
</div>
<div class="item">
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery3.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery3.jpg" alt="Image Three" /></a>
</div>
<div class="item">
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery4.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery4.jpg" alt="Image Four" />
</a>
</div>
<div class="item">
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery5.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/gallery5.jpg" alt="Image Five" />
</a>
</div>
</div>
<div class="nav-arrows">
<button class="arrow-left">
<!--SVGs from iconmonstr.com-->
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="M2.117 12l7.527 6.235-.644.765-9-7.521 9-7.479.645.764-7.529 6.236h21.884v1h-21.883z"/></svg>
</button>
<button class="arrow-right">
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="M21.883 12l-7.527 6.235.644.765 9-7.521-9-7.479-.645.764 7.529 6.236h-21.884v1h21.883z"/></svg>
</button>
</div>
<div class="photos-counter">
<span></span><span></span>
</div>
</div>
</div>
</div>
关于javascript - 如何更改此代码中 slider 的布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56052055/
我尝试理解[c代码 -> 汇编]代码 void node::Check( data & _data1, vector& _data2) { -> push ebp -> mov ebp,esp ->
我需要在当前表单(代码)的上下文中运行文本文件中的代码。其中一项要求是让代码创建新控件并将其添加到当前窗体。 例如,在Form1.cs中: using System.Windows.Forms; ..
我有此 C++ 代码并将其转换为 C# (.net Framework 4) 代码。有没有人给我一些关于 malloc、free 和 sprintf 方法的提示? int monate = ee; d
我的网络服务器代码有问题 #include #include #include #include #include #include #include int
给定以下 html 代码,将列表中的第三个元素(即“美丽”一词)以斜体显示的 CSS 代码是什么?当然,我可以给这个元素一个 id 或一个 class,但 html 代码必须保持不变。谢谢
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我试图制作一个宏来避免重复代码和注释。 我试过这个: #define GrowOnPage(any Page, any Component) Component.Width := Page.Surfa
我正在尝试将我的旧 C++ 代码“翻译”成头条新闻所暗示的 C# 代码。问题是我是 C# 中的新手,并不是所有的东西都像 C++ 中那样。在 C++ 中这些解决方案运行良好,但在 C# 中只是不能。我
在 Windows 10 上工作,R 语言的格式化程序似乎没有在 Visual Studio Code 中完成它的工作。我试过R support for Visual Studio Code和 R-T
我正在处理一些报告(计数),我必须获取不同参数的计数。非常简单但乏味。 一个参数的示例查询: qCountsEmployee = ( "select count(*) from %s wher
最近几天我尝试从 d00m 调试网络错误。我开始用尽想法/线索,我希望其他 SO 用户拥有可能有用的宝贵经验。我希望能够提供所有相关信息,但我个人无法控制服务器环境。 整个事情始于用户注意到我们应用程
我有一个 app.js 文件,其中包含如下 dojo amd 模式代码: require(["dojo/dom", ..], function(dom){ dom.byId('someId').i
我对“-gencode”语句中的“code=sm_X”选项有点困惑。 一个例子:NVCC 编译器选项有什么作用 -gencode arch=compute_13,code=sm_13 嵌入库中? 只有
我为我的表格使用 X-editable 框架。 但是我有一些问题。 $(document).ready(function() { $('.access').editable({
我一直在通过本教程学习 flask/python http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-wo
我想将 Vim 和 EMACS 用于 CNC、G 代码和 M 代码。 Vim 或 EMACS 是否有任何语法或模式来处理这种类型的代码? 最佳答案 一些快速搜索使我找到了 this vim 和 thi
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve this
这个问题在这里已经有了答案: Enabling markdown highlighting in Vim (5 个回答) 6年前关闭。 当我在 Vim 中编辑包含 Markdown 代码的 READM
我正在 Swift3 iOS 中开发视频应用程序。基本上我必须将视频 Assets 和音频与淡入淡出效果合并为一个并将其保存到 iPhone 画廊。为此,我使用以下方法: private func d
pipeline { agent any stages { stage('Build') { steps { e
我是一名优秀的程序员,十分优秀!