Success Bureau
Success Bureau

Reputation: 77

how to make slider responsive (codepen)?

I am using this slider but its not responsive. can anyone tell me how can i make this slider responsive.

i made width:100%; but contents are not responsive any help or slimier slider suggestion would be appreciated

https://codepen.io/ivanrafael/pen/xGNOrP

    .anim-slider {
  background: #225A86;
  list-style-type: none;
  position: relative;
  overflow: hidden;
  text-align: center;
  top: 0;
  left: 0;
  width: 100%;
  height: 550px;
  padding:0;
  margin:0;
}

Upvotes: 1

Views: 749

Answers (1)

Scipion
Scipion

Reputation: 11888

Here is the sass mixin I am currently using (the dimensions are probably a bit outdaded nowadays) :

@mixin breakpoint($class) {
  @if $class == xs {
    @media (max-width: 767px) { @content; }
  }
  @else if $class == sm {
    @media (min-width: 768px) { @content; }
  }

  @else if $class == md {
    @media (min-width: 992px) { @content; }
  }
  @else if $class == lg {
    @media (min-width: 1200px) { @content; }
  }
  @else if $class == xlg {
    @media (min-width: 1367px) { @content; }
  }
  @else {
    @warn "Breakpoint mixin supports: xs, sm, md, lg";
  }
}

it is just a shortcut for media queries. I then use

@include breakpoint(xs) {
 ... properties targeting mobile only go here ...
}

it then depends how you want your slider to appear in the different breakpoints. By instance :

.anim-slide img#css3 {
    left: 35%;
    top: 4%;
}

don't seem to work really well on mobile view.

for that specific case, you may prefer :

.anim-slide img#css3 {
    left: 35%;
    @include breakpoint(xs) {
      left: 25%;
    }
    top: 4%;
}

which is the same as :

.anim-slide img#css3 {
    left: 25%;
    @include breakpoint(sm) {
      left: 35%;
    }
    top: 4%;
}

which is the same as (no sass) :

.anim-slide img#css3 {
    left: 35%;
    @media (max-width: 767px) {
      left: 25%;
    }
    top: 4%;
}

It was only one example, you may have to do this on several classes and using several different breakpoints to have your slider perfectly responsive.

Upvotes: 2

Related Questions