Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image Slider with "Responsive Width", "Fixed Height", "Center Aligned" and "Auto Rotate"

I need a full width (responsive) slider with fixed height and centered image ( the min width is 960px and people with a wider screens will see the rest of the image (the extra on the left and right)) and it needs to auto-rotate.

Now I got the html/css worked out, but my javascript is rubbish so i have no idea how to let the images slide. I've checked out a lot of Questions here but nothing seems to work. My image dimensions are 2300x350.

CSS:

body {
    margin: 0 auto;
}

#slider_container {
    width:100%;
    height:350px;
    overflow:hidden;
    position: relative;
    z-index: 1;
}

.image {
    position:relative;
    float:left;
    height: 350px;
    width: 100%;
    overflow: hidden;
}

.image img {   
    position:absolute;
    left:50%;
    top:50%;
    margin-left:-1150px;
    margin-top:-175px;
}

HTML:

<div id="slider_container">
    <div class="image">
        <img src="images/header.jpg" />
    </div>
    <div class="image">
        <img src="images/header2.jpg"/>
    </div>
    <div class="image">
        <img src="images/header3.jpg" />
    </div>
</div>

With this code the pictures come out nice in the middle on every screen but how do I let it slide and autorotate? I guess the first image just needs to be replaced by the second so a z-index change? or + or - the width of one picture?

like image 547
user1830235 Avatar asked Dec 07 '25 08:12

user1830235


1 Answers

You need to only style the img tag if using flexslider. Try the fiddle link below. I have included four files for this.

  • jQuery 1.9.1
  • flexslider.css
  • jquery.flexslider-min.js
  • bg_direction_nav.png

jsfiddle

like image 84
Jehanzeb.Malik Avatar answered Dec 08 '25 22:12

Jehanzeb.Malik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!