Challenges faced when creating a dynamic HTML and CSS slider

I recently added some code from a CodePen to my website.

While the code is functioning correctly, it seems to be causing issues with other content on my page such as links and images. Any idea why this might be happening and how can I fix it? :)

HTML

<base href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/">
<div id="slider">
<figure>
<img src="austin-fireworks.jpg" alt>
<img src="taj-mahal_copy.jpg" alt>
<img src="ibiza.jpg" alt>
<img src="ankor-wat.jpg" alt>
<img src="austin-fireworks.jpg" alt>
</figure>
</div>

CSS

@keyframes slidy {
0% { left: 0%; }
20% { left: 0%; }
25% { left: -100%; }
45% { left: -100%; }
50% { left: -200%; }
70% { left: -200%; }
75% { left: -300%; }
95% { left: -300%; }
100% { left: -400%; }
}

body { margin: 0; } 
div#slider { overflow: hidden; }
div#slider figure img { width: 20%; float: left; }
div#slider figure { 
  position: relative;
  width: 500%;
  margin: 0;
  left: 0;
  text-align: left;
  font-size: 0;
  animation: 30s slidy infinite; 
}

Answer №1

It's likely that the presence of

<base href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/">
is causing all links and references to be affected.

This element sets the base URL for all relative URLs in the document, as explained by Mozilla developers:

The HTML <base> element specifies the base URL to use for all relative URLs contained within a document. There can be only one <base> element in a document.

To resolve your specific issue:

Remove the base href element at the top of your page and update the sources for each image in the slider with their absolute URLs.

Answer №2

**This is the current functioning code that I have developed so far **

<div id="slider">
        <div class="slider-title">
            <h2>best seller</h2>
        </div>
        <figure>
            <img src="simon-lee-TW93DCT6T_U-unsplash.jpg" alt="sample photo">
            <img src="colin-cassidy-wdG7v-9pJ1A-unsplash.jpg" alt="sample photo">
            <img src="massimiliano-corradini-Nylf-HeGX2w-unsplash.jpg" alt="sample photo">
            <img src="studio-blackthorns-C7vX_SBPrqk-unsplash.jpg" alt="sample photo">
            <img src="simon-lee-TW93DCT6T_U-unsplash.jpg" alt="sample photo">
        </figure>
    
    </div>

This is the accompanying CSS for the design

    #slider {
    margin-top: 25px;
    background: #417378;
    border-radius: 10px;
    overflow: hidden;
}
#slider figure {
    border-radius: 10px;
    position: relative;
    width: 500%;
    margin: 0;
    left: 0;
    animation: 20s slider infinite;
    }
    #slider figure img {
    width: 20%;
    height: 400px;
    float: left;
    margin-top: -25px;
    }
    @keyframes slider {
    0% {
        border-radius: 10px;
        left: 0;
    }
    20% {
        border-radius: 10px;
        left: 0;
    }
    25% {
    border-radius: 10px;
        left: -100%;
    }
    45% {
        border-radius: 10px;
        left: -100%;
    }
    50% {
        border-radius: 10px;
        left: -200%;
    }
    70% {
        border-radius: 10px;
        left: -200%;
    }
    75% {
        border-radius: 10px;
        left: -300%;
    }
    95% {
        border-radius: 10px;
        left: -300%;
    }
    100% {
        border-radius: 10px;
        left: -400%;
    }

}

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

- Utilize bullet points to exhibit keywords within a D3.js div by appending them

I'm looking to showcase the comma-separated values from a JSON file as a list in a mouseover tooltip on each node. Here is my current code snippet: div.append("div") .attr("class", "tooltip") .style("opacity", 1) .html("Node name : " + d.NodeName + ...

Consistent max-width applied to various items using full HTML and CSS styling

Can a CSS class be created where the width is dynamically set to match the width of the longest item? I know how to do this in jQuery by iterating through, but I need a solution using only CSS/CSS3. ...

Is there a way to avoid overlapping in CSS3 transforms?

Check out my jsfiddle demo: http://jsfiddle.net/WLJUC/ I have noticed that when you click to rotate the larger container, it overlaps the smaller one. This poses a problem as I am attempting to create a picture gallery where users can rotate and enlarge ...

Centralize Arabic symbol characters

Is it possible to center the symbols that by default go above characters such as مُحَمَّد? .wrapper { text-align: center; vertical-align: center; } span { font-size: 4rem; display: inline-block; padding: 2rem; margin: 0.2rem; ba ...

Completely alter the appearance of an <img> element using CSS without modifying the src attribute

Hey there! I currently have an image in the img src="image" tag. Is there a method within CSS to completely replace that image? I am unable to modify the JavaScript or HTML. I attempted using background-image, but the original image is still b ...

Click on the anchor tag to reveal additional content beyond the default display

This question stems from a previous discussion on the topic at: Only show specific div with anchor In my profiles.html page, there are profiles of around 20 people all grouped under a class named "profile" and unique ids such as "example-name1", "example ...

What is the best way to pass the double-clicked row as a parameter to a function, when the row is dynamically created in the code?

I am facing an issue with adding rows to an empty table using a button and attaching a dblclick event listener to each row. The challenge arises when I need to execute a function that requires the specific row being double-clicked. In tables already popu ...

Troubleshooting IE's alignment issue on HTML pages without DTD validation

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <body> <div id="container"> <div id="menu"> <ul> <li><a > ...

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 ...

Sharing data with external domains and retrieving HTML output using JavaScript

When a browser sends a POST request and expects an HTML page result from JavaScript, problems arise if there is no Access-Control-Allow-Origin in the server response. Unfortunately, changing anything on the server side is not an option. If a human clicks ...

The lower text box on the page being covered by the virtual keyboard on IOS

Our website features a fixed header and footer with scrollable content. We have 20 text boxes on the page, but the ones at the bottom, like Zip and Telephone, are obscured by the iOS virtual keyboard that appears when a text box is clicked. If we could d ...

Decrease spacing between lines in menu options

Struggling to adjust the line height for a specific menu item on my Wordpress site. Looking to decrease the space between lines. Check out the website here: kristinaartgallery.ru Appreciate any assistance you can provide, thank you! ...

Insert the dollar sign into a box for entering text

Is there a way to keep the dollar symbol at the beginning of a text box consistently across different browsers? The current code achieves this but with some issues in Firefox. How can I resolve this problem and improve the alignment of the dollar symbol us ...

How can I send inline HTML code using Asyncwebserver?

Attempting to execute inline HTML code using Asyncwebserver without a "GET" request. Functional HTML file on a Windows PC: <!DOCTYPE html> <html> <head> <title>README</title> </head> <body> <div><object ...

By utilizing the <tr> element, one can enhance the border thickness by 1 pixel

Is it possible to ensure that row selection in a table is consistent in terms of border alignment on both sides? https://i.stack.imgur.com/qmZiQ.png If you have any suggestions or solutions, please share them. Thank you! table { margin: 10px; bord ...

Challenges with HTML form text area

I am having an issue with my HTML form where the word "message" is displaying at the bottom-left of the textarea. How can I adjust it to appear on the top-left of the textarea? See image here - <form name="reg_form" method="post" actio ...

Attempting to superimpose a CSS triangle arrow onto a Google Map

I'm currently working on incorporating a CSS arrow on top of a Google map as a design element. The concept involves a horizontal stripe with a downward arrow placed halfway through, and I aim to have this arrow overlay the Google map. Here is a snipp ...

Utilizing Font Awesome for social icons in a Vue component display

Currently, I'm in the process of building my own website and making the switch from traditional HTML, CSS, and JS to using VueJs. I've hit a roadblock when trying to transfer some code from my original HTML file to a Vue JS component, specificall ...

The issue encountered with Bootstrap Carousel and the <img> tag displaying incorrect object-fit and object-position properties

Currently, I am working on a carousel design that looks like the code snippet below: <div id="myCarousel" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> ... </ol> <div class="carousel ...

Ways to ensure the footer sticks to the bottom of the page when there is minimal content

Using Bootstrap 3.3.7 I am trying to ensure that my footer always stays at the bottom of the browser window. I prefer not to use a "sticky footer" as I don't want it to cover any part of my content. Currently, when there is enough content on the pa ...