Coder Social home page Coder Social logo

Styling troubles about swiper HOT 4 CLOSED

nolimits4web avatar nolimits4web commented on August 15, 2024
Styling troubles

from swiper.

Comments (4)

JayHoltslander avatar JayHoltslander commented on August 15, 2024

Screenshot...
Screenshot

from swiper.

nolimits4web avatar nolimits4web commented on August 15, 2024

Hi Jay. Don't set margins on slides! It will not work. If you need visible margins between slides, add some container inside of slide and set margins/paddings to this elements. Also you can't set single slide's width, Swiper calculates it automatically. To have more than one slide pers swiper-container you need to use slidesPerSlide parameter on initialization.

For example your swiper-container width is 640px, and if you set slidesPerSlide equal to "2", then each slide will be 640/2 = 320 px wide.

Also, you can change this parameter dynamically after Swiper initialization like:

var swiper = $('.swiper-container').swiper({
  ...
  slidesPerSlide : 2,
  ...
})
// And then you can change it,  for example if your container became wider and you can fit there 3 slides:
swiper.params.slidesPerSlide = 3;
// Re-init slider to apply new settings:
swiper.init()

from swiper.

JayHoltslander avatar JayHoltslander commented on August 15, 2024

Sorry...
is that code snippet for inside the idangerous.swiper-1.5.js ?

Or in the page body like

<script type="text/javascript">   
var swiper = $('.swiper-container').swiper({
slidesPerSlide : 2,
})
</script>

from swiper.

nolimits4web avatar nolimits4web commented on August 15, 2024

slidesPerSlide is the parameter that you should add when you initialize your Swiper, i suppose you do in body or in included JS script. That code snippet above is just the example of Swiper initialization that of course should be in your scripts/body and executed on document/window ready.

from swiper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.