How to Slide the background using jQuery-Backstretch Plugin

in #utopian-io6 years ago (edited)

What Will I Learn?

  • You will learn how to install jQuery-Backstretch Plugin
  • You will learn how to use jQuery-Backstretch Plugin
  • You will learn how to call image using Backstretch Plugin

Requirements

  • Basic Knowledges about HTML
  • Basic Knowledges about jQuery
  • Provide some images for sample
  • You have to install or host the jQuery file, You can add jQuery CDN if you don't want to install or host it
  • You have to install or host the about hideshowpassword plugin, You can get it on github : https://github.com/jquery-backstretch/jquery-backstretch

Difficulty

  • Basic

Tutorial Contents

Backstretch is a simple jQuery plugin that allows you to add a dynamically-resized, slideshow-capable background image to any page or element. The image will stretch to fit the page/element, and will automatically resize as the window/element size changes[source]

Here the simple steps to create background slider using jQuery-Backstretch Plugin:

&Download and host the jQuery-Backstretch Plugin
&Adding Some Images
  • Add same images you will slide it on background and save it in the same folder of Backstretch Plugin.
&Creating PHP file.
  • Open your text editor.

  • Create new file and save as index.php. Save it on the Backstretch folder.

  • Add the HTML element as usual.

<html>
<head>
<title>Background Slider</title>
</head>
<body>
</body>
</html>
  • Create some content in the page for example
    <h2 style="color:red">BACKGROUND SLIDER</h2>
    <p style="color:white">Backstretch is a simple jQuery plugin that allows you to add a dynamically-resized,
         slideshow-capable background image to any page or element. The image will stretch to fit the page/element, 
         and will automatically resize as the window/element size changes</p>
  • Because the jQuery-Backstretch Plugin is part of jQuery so to use it we need to host jquery also or you can add the CDN of jQuery if you don't want to host it. For more Detail you can visit jquery official web. In this tutorial I use Google CDN. Add the CDN in <head> element.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  • Include the jQuery-Backstretch Plugin
<script src="jquery.backstretch.min.js"></script>
&Start code JS Script
  • To write the jQuery Script we should open <script> tag. You can put it in ,head> element or in <body> element.
<script></script>
  • To add Backstretch Plugin just open backstretch() function with the parameter is the images, the duration and the fade of slide. Here the format
$.backstretch(["img (1).jpg","img (2).jpg","img (3).jpg","img (4).jpg"], {duration: 1500, fade: 800});
&Testing
  • Save the file and run it on your localhost in browser.
    image.png
&Full Code
<html>
<head>
<title>Background Slider</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="jquery.backstretch.min.js"></script>
</head>
<body>
<center>
    <h2 style="color:red">BACKGROUND SLIDER</h2>
    <p style="color:white">Backstretch is a simple jQuery plugin that allows you to add a dynamically-resized,
         slideshow-capable background image to any page or element. The image will stretch to fit the page/element, 
         and will automatically resize as the window/element size changes</p>
</center>
<script>
    $.backstretch(["img (1).jpg","img (2).jpg","img (3).jpg","img (4).jpg"], {duration: 1500, fade: 800});
</script>
</body>
</html>

Download Full File in GDrive

Curriculum



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Akhi ne follow ata Lon beuh dan vote hehh

@sogata, I always try to support who contribute to open source project, upvote you.

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @sogata I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

@sogata sungguh indah gambar di atas 👍👍👍

Coin Marketplace

STEEM 0.26
TRX 0.11
JST 0.033
BTC 64507.66
ETH 3080.07
USDT 1.00
SBD 3.85