Creating numerous presentations without the need for excessive copying and pasting

I recently created a slideshow by modifying some code I found from this original source.

For those interested, here is the link to view the slideshow on jsfiddle:

View full source code here

The issue I encountered is that when attempting to display two separate slideshows on the same page, the buttons of the second slideshow end up controlling the first one due to hard-coded CSS.

Is there a way to modify the code to allow for multiple independent slide shows on a single webpage?

Snippet of the HTML code used:

<div id="slideshow-wrap">
    <input type="radio" id="button-1" name="controls" checked="checked"/>
    <label for="button-1"></label>

Snippet of the problematic CSS code:

#slideshow-wrap input[type=radio]#button-1:checked~label[for=button-1] { background-color: rgba(100,100,100,1) }

#slideshow-wrap input[type=radio]#button-2:checked~label[for=button-2] { background-color: rgba(100,100,100,1) }

#slideshow-wrap input[type=radio]#button-3:checked~label[for=button-3] { background-color: rgba(100,100,100,1) }

Answer №1

Of all the sliders out there, the one you're using was actually my very first back in 2012. It's pretty cool. However, I highly recommend checking out Responsiveslides.js. It's incredibly awesome and has been my go-to slider anytime I need one. While it may require a bit more styling depending on your needs, it is versatile and the sliders don't interfere with each other. Here's an example: a fiddle with 2 sliders as an example:

HTML

The markup is really simple. You can put anything you want in the list items.

<ul class="rslides">
    <li><img src="http://placekitten.com/300/150-1" alt="" /></li>
    <li><img src="http://placekitten.com/300/150-2" alt="" /></li>
    <li><img src="http://placekitten.com/300/150-3" alt="" /></li>
</ul>

CSS

The base CSS is also quite simple - and there are customizable themes available. This allows you to have full control over the appearance.

.rslides {
  position: relative;
  list-style: none;
  overflow: hidden;
  width: 100%;
  padding: 0;
  margin: 0;
}

.rslides li {
  -webkit-backface-visibility: hidden;
  position: absolute;
  display: none;
  width: 100%;
  left: 0;
  top: 0;
}

.rslides li:first-child {
  position: relative;
  display: block;
  float: left;
}

.rslides img {
  display: block;
  height: auto;
  float: left;
  width: 100%;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Steps for connecting a div to a collapsible navigation bar

I have a website with a collapsible navbar at the top for small screens. I want to add a red circle positioned on the right side of the navbar. Something like this: view image here The circle is not a button and should be centered on the border of the navb ...

The AngularJS 2 TypeScript application has been permanently relocated

https://i.stack.imgur.com/I3RVr.png Every time I attempt to launch my application, it throws multiple errors: The first error message reads as follows: SyntaxError: class is a reserved identifier in the class thumbnail Here's the snippet of code ...

Validating and submitting forms using Bootstrap 4

I recently integrated a Bootstrap 4 form with validation using the provided "starter" JavaScript code available on their official website: https://getbootstrap.com/docs/4.4/components/forms/#validation. This form is located within a sidebar of a Google Do ...

What is the best way to apply a class to the 'td' element for two specific columns?

I have a rendered row from a database echo "<table border='1' cellpadding='10'>"; echo "<tr> <th>ID</th> <th>First Name</th> <th>Last Name</th> <th></th> <th></th> ...

Connecting Lightbox2 within a table: A step-by-step guide

My website now showcases a table where all rows have been transformed into clickable links using the code below: HTML - <tr data-href="../images/accept.png" > <td> Blah Blah </td> </tr> JQuery- $(document).ready(function(){ ...

What is the process for creating a dynamic URL, such as example.com/profile/CroatiaGM?

I am in the process of developing a user control panel, and I have encountered some difficulties with creating a dynamic profile link. For instance, how can I achieve something like example.com/profile/CroatiaGM? Given that my website is primarily coded ...

Issue with Bootstrap gradient mixin functionality in Internet Explorer 9

I recently obtained this code after compiling a bootstrap gradient less mixin: html, body { height: 100%; background-image: -webkit-linear-gradient(top, rgba(108, 91, 123, 0.8) 0%, rgba(53, 92, 125, 0.8) 100%); background-image: -o-linear-grad ...

What could be causing IE8 to keep text centered even though the text-align property is set to left?

When using Internet Explorer 8's own development tools, the text-align property of the element is displayed as left. However, in IE8 standards mode, it appears centered. In quirks mode or IE7 standards mode, everything aligns correctly to the left. h ...

Inquiring about JavaScript: How to utilize the (body-tag)?

Is it possible to speed up page loading by placing JavaScript before the closing </body> tag? Consider this scenario: <body> Sample content <script type="text/javascript" src="jQuery.js"></script> <script type="text/javasc ...

Redux integration for react-country-region-selector Form submission

Currently, I am working on implementing a country-region selection feature using ReactJS. To achieve this functionality, I decided to utilize the react-country-region-selector library and created a component named CountryRegion. This component consists of ...

Disabling iframe javascript timers when iframe is no longer in the user's view

Currently, I am working on a blog post that will showcase various HTML5/Javascript animations through multiple <iframe> sections. These animations utilize methods such as requestAnimationFrame() and/or setInterval(). Due to limitations within the blo ...

Stop the replication of HTML/CSS styles during the extraction of content from a div

Is there a way to prevent the copying of CSS properties, such as font styles and sizes, when content is copied from a div? I want only the plain text to be copied to the clipboard, without any formatting applied. ...

CSS: Struggling with Div Alignment

Here is a visual representation of the issue I am facing: View the screenshot of the rendered page here: http://cl.ly/image/0E2N1W1m420V/Image%202012-07-22%20at%203.25.44%20PM.png The first problem I have encountered is the excessive empty space between ...

What is the best way to showcase information retrieved from an AJAX request onto a div using Jquery or Javascript?

When data is received in a HTML page through an AJAX call, it typically appears like this: <input type="hidden" id="s1" name="1" value="111" /> <input type="hidden" id="s2" name="2" value="222" /> The data then loads into <div="ajax"> A ...

axio. to retrieve the information stored in an alternate document

Seeking assistance in utilizing API data in a separate file. I have three files: api.jsx import axios from 'axios'; export const api = (url, data) => { const { path, method } = url; let result ={}; axios({ method: ...

Finding the Vue module within a helper function or mixin: A step-by-step guide

In my development work with Nuxt.js, I am utilizing the cookie-universal-nuxt package to access cookies in both server-side and client-side. modules:[ [.....] , [.....] , [.....] , ['cookie-universal-nuxt', { alias: 'myCookie' ...

Creating an HTML element with jQuery using the before() method

Here is the code snippet I am working with: $(document).on("click", "#add", function() { console.log("clicked"); $(this).before('<lable>'+ current +'.</label><input type="text", id="option"><br>'); ...

Tips for generating multiple instances of a JavaScript function on a single page

Consider the following JavaScript code snippet : var from,to; to = $(".range-to-dt").persianDatepicker({ inline: true, minDate: new persianDate(cleanDate(serverDateTime)), altField: '.range-to-dt-alt', altFormat: ...

Whenever I attempt to connect to Stripe, my code fails to execute properly

My knowledge of Javascript is limited, but I have a basic understanding. I am currently diving into learning about Stripe and testing it in a local environment with a Wordpress install. Following the Stripe documentation, I have successfully installed Node ...

Bootstrap dropdown menu experiencing functionality issues

I am facing an issue with implementing the javascript bootstrap file in my project. The dropdown menu is not working as expected even though I have saved bootstrap to my project folder. I have tried looking at other example codes and even copied and paste ...