GithubHelp home page GithubHelp logo

simpleslider's Introduction

SimpleSlider v1.3

A vanilla Javascript and CSS3 slider.

About

SimpleSlider is a responsive slider script written using pure Javascript (no libraries).

The images will scale to completely fill the wrapper leaving no whitespace, similar to background-size:cover

All animations are done using CSS3, which means to see the beautiful transitions you'll have to be using a modern browser, but it will still gracefully degrade for older browsers.

The project is open source; use the issue tracker to submit bugs or change requests.

I would love to know if you're using SimpleSlider. Contact me and I'll feature your site.

Creative Commons License

Browser support

  • Chrome 24+
  • Firefox 18+
  • Opera 20+
  • Safari 5.1.7
  • IE7+

How to use

If you are comfortable adding images in HTML, you can use this method:

1 - Set up your markup and add your images. Any <img> tags you add within <div id="ss__wrapper"> will become part of the slider.

<div id="simpleslider">
	<div id="ss__wrapper">
		<img src="img/image1.jpg" alt="An orange image" class="current"/>
		<img src="img/image2.jpg" alt="A larger image with a different proportion to ss"/>
		<img src="img/image3.jpg" alt="A portrait image"/>
	</div>
	<div id="ss__controls">
		<div id="ss__prev"><div id="ss__prevChev"></div></div>
		<div id="ss__next"><div id="ss__nextChev"></div></div>
		<div id="ss__dots"></div>
	</div>
</div>

2 - Link to simpleslider.css in the <head> tag:

<link rel="stylesheet" type="text/css" href="simpleslider.css"/>

3 - Include simpleslider.js just before the </body> tag:

<script src="simpleslider.js"></script>

4 - SimpleSlider's dimensions are set using a width:height ratio. The width will always be 100% of its parent container.

5 - Initiate SimpleSlider and pass through the width:height ratio as the parameter:

<script>
	simpleslider('16:9');
</script>

SimpleSlider can also load a set number of images from a specified directory, without having to specify them in the HTML:

1 - Set up your markup, this time leaving the ss__wrapper container empty:

<div id="simpleslider">
	<div id="ss__wrapper"></div>
	<div id="ss__controls">
		<div id="ss__prev"><div id="ss__prevChev"></div></div>
		<div id="ss__next"><div id="ss__nextChev"></div></div>
		<div id="ss__dots"></div>
	</div>
</div>

2 - Link to simpleslider.css in the <head> tag:

<link rel="stylesheet" type="text/css" href="simpleslider.css"/>

3 - Include simpleslider.js just before the </body> tag:

<script src="simpleslider.js"></script>

4 - SimpleSlider's dimensions are set using a width:height ratio. The width will always be 100% of its parent container.

5 - Initiate SimpleSlider. Pass SimpleSlider the width:height ratio, how many images to load, the directory in which they belong and the filename prefix:

<script>
	simpleslider('16:9', 3, "img/directory", "prefix");
</script>

simpleslider's People

Contributors

jamesl1001 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.