i start to learn about Web and make example page
i use swiper in javascript and that swiper is work, but all slide exhibit when that slide does not in center.
what attribute need to code?
Actual page
and this my js page
new Swiper('.notice-line .swiper-container', {
direction: 'vertical',
autoplay: true,
loop: true
});
html page
<div class="inner__left">
<h2>공지사항</h2>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">
크리스마스 & 연말연시 스타벅스 매장 영업시간 변경 안내
</div>
<div class="swiper-slide">
[당첨자 발표] 2021 스타벅스 플래너 영수증 이벤트
</div>
<div class="swiper-slide">
스타벅스커피 코리아 애플리케이션 버전 업데이트 안내
</div>
<div class="swiper-slide">
[당첨자 발표] 뉴이어 전자영수증 이벤트
</div>
</div>
</div>
<a href="javascript:void(0)" class="notice-line__more">
<div class="material-icons">
<span class="material-symbols-outlined">add_circle</span>
</div>
</a>
</div>
Related
When I am adding swiper to my HTML the CSS is messed up it is not properly functional.
the margin from the container is disabled after adding the swiper. here is my HTML and JS code:-
let swiper = new Swiper('.portfolio_container', {
cssMode: true,
loop: true,
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev'
},
pagination: {
el: '.swiper-pagination',
clickable: true,
},
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/9.0.0/swiper-bundle.min.js"></script>
<h2>Portfolio</h2>
Most recent work
<div class="portfolio_container container swiper">
<div class="swiper-wrapper">
<!-- ==================PORTFOLIO 1 ============ -->
<div class="porfolio_content grid swiper-slide">
<img src="img/portfolio1.jpg" alt="" class="portfolio_img">
<div class="portfolio_data">
<h3 class="portfolio_title">Modern Websites</h3>
<p class="portfolio_description">Websites adaptable to all devices, with UI components and animated interactions. </p>
Demo<i class="uil uil-arrow-right button_icon"></i></div>
</div>
<img src="img/portfolio3.jpg" alt="" class="">
<h3>Online Store</h3>
<p>Websites adaptable to all devices, with UI components and animated interactions. </p>
Demo<i></i>
</div>
<!-- Add Arrows -->
<div class="swiper-button-next ">
<i class="uil uil-angle-right-b swiper-portfolio-icon "></i>
</div>
<div class="swiper-button-prev ">
<i class="uil uil-angle-left-b swiper-portfolio-icon "></i>
</div>
<!-- Add Pagination -->
<div class="swiper-pagination "></div>
To add a swiper slide to my portfolio section
This is my problem.
I'm using the owl.carrousel MIT libraries in my page.
This libraries automatly creates a div to give it the class "active" when it has to be shown.
I want to set a different background in the carrousel section when any different "owl-item" is active.
This is the html code as i have it on my index.html document:
<section id="testimonials">
<div class="container">
<div class="owl-carousel testimonials-carousel">
<div class="testimonial-item Titem1">
<h3>First carousel item</h3>
</div>
<div class="testimonial-item Titem2">
<h3>Second carousel item</h3>
</div>
<div class="testimonial-item Titem3">
<h3>Third carousel item</h3>
</div>
<div class="testimonial-item Titem4">
<h3>Fourth carousel item</h3>
</div>
</div>
</div>
</section>
This is the html code on the page after the owl.carrousel libraries does it's magic:
<section id="testimonials">
<div class="container">
<div class="owl-carousel testimonials-carousel">
<div class="owl-stage-outer">
<div class="owl-stage">
<div class="owl-item active">
<div class="testimonial-item Titem1">
<h3>First carousel item</h3>
</div>
</div>
</div>
</div>
<div class="owl-stage-outer">
<div class="owl-stage">
<div class="owl-item">
<div class="testimonial-item Titem2">
<h3>Second carousel item</h3>
</div>
</div>
</div>
</div>
<div class="owl-stage-outer">
<div class="owl-stage">
<div class="owl-item">
<div class="testimonial-item Titem3">
<h3>Third carousel item</h3>
</div>
</div>
</div>
</div>
<div class="owl-stage-outer">
<div class="owl-stage">
<div class="owl-item">
<div class="testimonial-item Titem4">
<h3>Fourth carousel item</h3>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
I want to use the div with class="owl-item active" child's (the active testimonial-item that is being showed) to give a class to the section element id="testimonials", so each time any different .owl-item gets the class .active, the background of the section changes as well.
I tried to do it with javascript and with jQuery but nothing worked for me, mabe because i'm still a noob xD.
For example this is the last thing i tried
$('#testimonials').addClass( $('.owl-item.active > .testimonial-item').attr("class") );
So if any GOD of JS or jQuery can help me pls :V
I don´t really know what im doing.
Thank you for reading till the end ;)
The code of Daddys Code worked well, but actualy fast enough to give the class to the "#testimonials" even before the class "active" changes from an "owl-item" to another, so it gave it the class from the last "owl-item active" it can be fixed easily using "translated.owl.carousel" instead of "change.owl.carousel":
$(".owl-carousel").owlCarousel();
var owl = $(".owl-carousel");
owl.owlCarousel();
owl.on("translated.owl.carousel", function (event) {
$("#IDi").removeClass();
$("#IDi").addClass($(".owl-item.active > .testimonial-item").attr("class"));
});
As I am able to understand your question, add below code to your js file
$(".owl-carousel").owlCarousel();
var owl = $(".owl-carousel");
owl.owlCarousel();
owl.on("translated.owl.carousel", function (event) {
$("#testimonials").removeClass();
$("#testimonials").addClass(
$(".owl-item.active > .testimonial-item").attr("class")
);
});
I have two owl carousel. And one is over the other. One is image with some content and other is only content. And the both slider needs to change together.
This the code below for content slider
<div id="owkey-content-slider" class="owl-carousel">
<div class="item">
<div class="slider-content">
<h4>WE CREATE</h4>
</div>
</div>
<div class="item">
<div class="slider-content">
<h4>WE BUILD</h4>
</div>
</div>
<div class="item">
<div class="slider-content">
<h4>WE OFFER</h4>
</div>
</div>
<div class="item">
<div class="slider-content">
<h4>WE DELIVER</h4>
</div>
</div>
</div>
This is the codes for image slider
<div class="header-bg-image-slide">
<div id="owkey-bg-slider" class="owl-carousel">
<div class="item">
<img src="img/owkey-slider-2.jpg">
<div class="number-item">01</div>
</div>
<div class="item">
<img src="img/owkey-slider.jpg">
<div class="number-item">02</div>
</div>
<div class="item">
<img src="img/shutterstock_327808505.jpg">
<div class="number-item">03</div>
</div>
<div class="item">
<img src="img/owkey-head.png">
<div class="number-item">04</div>
</div>
</div>
And they are initialized in the same conditions/parameters. They are changing together. But, when button was clicked those buttons are for the image slider and that doesn't change the other slider's contents certainly.
<script type="text/javascript">
$(document).ready(function() {
var owl = $("#owkey-bg-slider, #owkey-content-slider");
owl.owlCarousel({
navigation : true,
navigationText: ["<i class=\"fa fa-angle-up\">","<i class=\"fa fa-angle-down\">"],
singleItem : true,
transitionStyle : "fade",
autoPlay: true,
touchDrag: false,
mouseDrag: false
});
})
</script>
And I think experienced owl carousel user can help me in this.
There are solution for this problem in here that is for any other kind of slider but not for owl carousel.
Use Flickity Slider, it's a much better slider plugin.
I am trying to create a content slider same as here the only thing is that they have text and images and i want only images.
Basically on first page it shows thumbnails so when you click any of them it jumps to that particular slide.
I have tried and setup the slider with swiper jquery plugin but i couldn't make it to jump to specific slide here is my code:
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide" style="background-image:url(http://lorempixel.com/1000/1000/nightlife/5)">
<div class="block">
Jumo to page 1
</div>
<div class="block">
Jumo to page 2
</div>
<div class="block">
Jumo to page 3
</div>
</div>
<div id="page2" data-page-number="2" class="swiper-slide" style="background-image:url(http://lorempixel.com/1000/1000/nightlife/1)"></div>
<div id="page3" data-page-number="3" class="swiper-slide" style="background-image:url(http://lorempixel.com/1000/1000/nightlife/2)"></div>
<div id="page4" data-page-number="4" class="swiper-slide" style="background-image:url(http://lorempixel.com/1000/1000/nightlife/3)"></div>
<div id="page5" data-page-number="5" class="swiper-slide" style="background-image:url(http://lorempixel.com/1000/1000/nightlife/4)"></div>
<div id="page6" data-page-number="6" class="swiper-slide"><h1>THIS IS PAGE 6</h1></div>
</div>
<div class="swiper-pagination swiper-pagination-white"></div>
<div class="swiper-button-next swiper-button-white"></div>
<div class="swiper-button-prev swiper-button-white"></div>
</div>
<script>
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
spaceBetween: 30,
effect: 'fade'
});
</script>
Jsfiddle here https://jsfiddle.net/yuv72u60/
Seeking help!
Thank you
HTML
<div class="block">
Jumo to page 1
</div>
<div class="block">
Jumo to page 2
</div>
<div class="block">
Jumo to page 3
</div>
JS
$(".block a").click(function(){
var index=$(this).attr('href');
swiper.slideTo(index);
});
The above mentioned are changes in have made to your JS fiddle in the HTML and JS section. index in the above js is the position of your page.
DEMO
There is an API in Slider itself for your requirement I have updated your Fiddle slightly for that API to work
So I'm creating a image marquee for a mobile site that uses iDangerous Swiper plugin and have run into a issue when trying to use it. Following the set up based on the site, found here, I built my demo page to the exact spec of their demo. But for some reason, the function isn't running and I cant swipe to the next div. Being a mobile site, I'm using Jquery and Jquery Mobile. Any ideas?
<body>
<div class="swiper-container">
<div class="swiper-wrapper">
<!--First Slide-->
<div class="swiper-slide">
<img src="img/1.png" width="200" height="118">
</div>
<!--Second Slide-->
<div class="swiper-slide">
<img src="img/2.png" width="200" height="118">
</div>
<!--Third Slide-->
<div class="swiper-slide">
<img src="img/3.png" width="200" height="118">
</div>
<!--Fourth Slide-->
<div class="swiper-slide">
<img src="img/4.png" width="200" height="118">
</div>
<!--Fifth Slide-->
<div class="swiper-slide">
<img src="img/5.png" width="200" height="118">
</div>
</div>
</div>
<script>
$(function(){
var mySwiper = $('.swiper-container').swiper(options);
})
</script>
</body>
To use buttons for Swiper you need to use .swipeNext() and .swipePrev() methods on mySwiper object like:
<!-- Add somewhere in HTML your buttons:-->
<span class="button-next">Next button</span>
<span class="button-prev">Previous button</span>
<script>
$(function(){
var mySwiper = $('.swiper-container').swiper();
//"Next" button - some HTML element with "button-next" class
$('.button-next').click(function(){mySwiper.swipeNext()})
//"Prev" button - some HTML element with "button-prev" class
$('.button-prev').click(function(){mySwiper.swipePrev()})
})
</script>
iDangero.us here!:) Your HTML is correct. But what is "options" in your example? this should be an object with parameters or if you want to use default options then just remove "options" word from your example like: var mySwiper=$('.swiper-container').swiper()