`Unable to implement horizontal scroll in CSS`

While designing a content slider, I encountered an issue where the width of the container is set at 640px but the content overflow is not triggering horizontal scroll in popular browsers like Firefox, Chrome, and IE.

For a live example, you can visit: http://jsfiddle.net/fjw5x/1/

This is the HTML structure:

<div id="content">

    <!-- start slider -->
    <section id="featured-slider">

        <section id="wrap">

            <!-- slide one -->
            <span id="slide-one" class="slides">
                <!-- empty -->
            </span>         
            <hr id="line-one" class="lines">


            <!-- slide two -->
            <span id="slide-two" class="slides">
                <!-- empty -->
            </span>
            <!-- (overlap) -->
            <span id="slide-two-overlap" class="slides">
                <!-- empty -->
            </span>
            <hr id="line-two" class="lines">


            <!-- slide three -->
            <span id="slide-three" class="slides">
                <!-- empty -->
            </span>
            <hr id="line-three" class="lines">


            <!-- slide four -->
            <span id="slide-four" class="slides">
                <!-- empty -->
            </span>
            <hr id="line-four" class="lines">


            <!-- slide five -->
            <span id="slide-five" class="slides">
                <!-- empty -->
            </span>
            <hr id="line-five" class="lines">

        </section>

        <nav>
            <!-- empty -->
        </nav>

    </section>
    <!-- end slider -->

</div>


</body>
</html>

Here is the corresponding CSS styling:

/*  GLOBAL
    ______________________________
*/

#content #featured-slider {
    float: left;
    width: 100%;
    height: 265px;
    margin: 75px 0 0 0;
}

#content #featured-slider #wrap {
    float: left;
    overflow-x: scroll;
    overflow: -moz-scrollbars-horizontal;
    width: 640px;
    height: 245px;
    margin: 5px;
}

#content #featured-slider #wrap .lines {
    float: left;
    border: 0;
    height: 1px;    
    background-color: #DCDCDC;
}

#content #featured-slider #wrap .slides {
    float: left;
    border-radius: 50%;
    border: thin dotted #B8B8B8;
}



/*  CONTENT
    ______________________________
*/

/*  SLIDE ONE
    ------------------------------
*/

#content #featured-slider #wrap #slide-one {
    width: 50px;
    height: 50px; 
    margin: 50px 0px;
}

#content #featured-slider #wrap #line-one { 
    width: 45px;
    margin: 110px 7.5px;

    /* ROTATE */
    transform:rotate(21deg);
    -ms-transform:rotate(21deg); /* IE 9 */
    -webkit-transform:rotate(21deg); /* Safari and Chrome */
}


/*  SLIDE TWO
    ------------------------------
*/

#content #featured-slider #wrap #slide-two {
    width: 75px;
    height: 75px; 
    margin: 100px 0px;
}

#content #featured-slider #wrap #slide-two-overlap {
    width: 75px;
    height: 75px; 
    margin: 125px 0px 0px -35px;;
}

#content #featured-slider #wrap #line-two { 
    width: 90px;
    margin: 135px 9.5px;

    /* ROTATE */
    transform:rotate(-14deg);
    -ms-transform:rotate(-14deg); /* IE 9 */
    -webkit-transform:rotate(-14deg); /* Safari and Chrome */
}


/*  SLIDE THREE
    ------------------------------
*/

#content #featured-slider #wrap #slide-three {
    width: 75px;
    height: 75px; 
    margin: 70px 0px;
}

#content #featured-slider #wrap #line-three {   
    width: 60px;
    margin: 115px 9.5px;

    /* ROTATE */
    transform:rotate(12deg);
    -ms-transform:rotate(12deg); /* IE 9 */
    -webkit-transform:rotate(12deg); /* Safari and Chrome */
}


/*  SLIDE FOUR
    ------------------------------
*/

#content #featured-slider #wrap #slide-four {
    width: 40px;
    height: 40px; 
    margin: 110px 0px;
}

#content #featured-slider #wrap #line-four {    
    width: 90px;
    margin: 115px 9.5px;

    /* ROTATE */
    transform:rotate(-12deg);
    -ms-transform:rotate(-12deg); /* IE 9 */
    -webkit-transform:rotate(-12deg); /* Safari and Chrome */
}


/*  SLIDE FIVE
    ------------------------------
*/

#content #featured-slider #wrap #slide-five {
    width: 40px;
    height: 40px; 
    margin: 110px 0px;
}

#content #featured-slider #wrap #line-five {    
    width: 90px;
    margin: 115px 9.5px;

    /* ROTATE */
    transform:rotate(-12deg);
    -ms-transform:rotate(-12deg); /* IE 9 */
    -webkit-transform:rotate(-12deg); /* Safari and Chrome */
}




/*  NAV
    ______________________________
*/

#content #featured-slider nav {
    float: right;
    width: 180px;
    height: 65px;
    border: thin dotted grey;
    margin: 105px 25px 0 0;
}

Answer №1

Make sure to enclose your float elements within a wrapping element and specify its width

<div id="float_wrapper"></div>

#float_wrapper{width:640px;}

If the specified width is not enough, the float element will move to the next line

Check it out live:http://jsfiddle.net/fjw5x/5/

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

Having trouble locating elements that "match this specific selector" using jQuery's `.find()` method?

According to the jQuery documentation, the find function filters elements based on whether they match a given selector. This sentence may not be completely accurate, or I might be misunderstanding its meaning. For instance, when attempting to change the ...

Strategies for aligning a link on top of another div with absolute positioning

Looking for some assistance with my HTML and CSS code. Specifically, I need the position of the #header id to be set as absolute: <div class="main"> <a href="www.website.com"> <div id="header" class="other"> </div> #heade ...

Android: A comprehensive look at how Universal Image Loader addresses blank space problems

Currently, I am dealing with a string that includes HTML content like text and images. To properly display the <img> tags in a TextView, I have opted for the Android Universal Image Loader (UIL). Each image should ideally appear in its original posit ...

The phenomenon of an invisible Absolute or relative position leading to grid components overlapping in Next.js

I've been struggling with this issue for over 48 hours now. I've attempted to troubleshoot by commenting out everything except the affected components and even swapping entire components around, but the problem persists. Oddly enough, rearranging ...

ExtJS web displays appear differently when viewed on Chrome's toggle device mode versus a mobile browser

Greetings, I have been working on developing a web application that can be accessed through a mobile browser. Initially, I created the web application and tested it in mobile mode using Chrome's simulation feature. https://i.sstatic.net/aAvVW.jpg H ...

The button must be programmed to remove a specific item from the server

I am currently developing an application to monitor my expenses using javascript, nodejs, express, and handlebars as the templating engine. Within the app, I have a "list" div that displays all of my expenses. (There is an add button next to the list, not ...

How can I align all the columns in every row to the left except for the first one?

To achieve the goal of making all columns except the first of a row in a table to have a text alignment of left (with the first column having a defined text alignment in CSS), the following code is utilized: <script type="text/javascript" src="../js/jq ...

What are the steps to make CSS grid stack on mobile devices?

In my CSS grid, I have set the grid template columns to grid-template-columns: repeat(auto-fit, minmax(225px, 1fr)) However, when I test the site's responsiveness on mobile, the grid elements do not stack but just get smaller. I am trying to make the ...

Including onMouseUp and onMouseDown events within a JavaScript function

I am experiencing an issue with a div that contains an input image with the ID of "Area-Light". I am attempting to pass the ID of the input image to a function. Although event handlers can be directly added inside the input tag, I prefer to do it within ...

applying conditional rendering in vue.js

I'm currently working on developing a chat application using the guidelines outlined in this tutorial: https://socket.io/get-started/private-messaging-part-1/ One of my goals is to customize the appearance of the messages, so that when a message is s ...

Divide document using PHP and create material

Looking for a way to split the content below into separate files and remove the placeholder tags? Also, want to extract the text inside the placeholder tags and save them in a new contents file. <div class='placeholder'>The First Chapter& ...

Mastering the Art of Revealing and Concealing

I stumbled upon a great demonstration on reversing the Hide and Show functionality at https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_toggle_hide_show <!DOCTYPE html> <html> <head> <meta name="viewport" content="width ...

Issue with prolonged CSS transition duration affecting width and position changes

Suppose we need a transition for width and position. However, using a long duration can result in unexpected behavior. The timing function will reset from zero for the remainder of the operation. #test { border: solid 1px; width: 100px; ...

Update the value of a JSF managed bean property for a h:SelectOneMenu using JavaScript

Hello, I have a unique method of injecting HTML code at runtime into my web page using JavaScript. The specific piece of code that I am cloning and inserting is as follows: <div id="any"> <h:selectOneMenu value="#{browserOSList.browserXP[0]}" ...

Creating a background image with linear gradients in Rails 5

Does anyone know how to implement a background image with linear gradients in CSS? Here is the code snippet I have: .main-bg-back-1{ background:linear-gradient(180deg,#22263f,rgba(33,41,94,.96)),url(../img/app/download-bg.jpg) no-repeat; backgroun ...

Swapping out an ImageButton for a custom-styled icon

I am in need of replacing an ImageButton within a GridView ItemTemplate with an icon that is defined in a CSS style. My usual approach would be to replace the ImageButton with a hidden button and then use JQuery to trigger a click event on the hidden butt ...

What causes my field-set containers to overflow on mobile devices but not on larger screens?

I'm currently in the process of developing a mobile-first responsive website with forms. Here is the desired mockup I need to replicate after the 769px breakpoint: https://ibb.co/LQ0Gwt7. On the other hand, here is how it should look for 769px and bel ...

The mobile view is not displaying the footer in full width as expected

I am currently working on designing a website without using the meta viewport tag. My goal is to ensure that my website displays properly on both mobile and desktop devices. I have encountered an issue with the comparison between the home page (index) an ...

`When utilizing $routeParams, the CSS fails to load`

Whenever I use parameters in ngRoute and go directly to the URL (without clicking a link on the site), the CSS fails to load. All my routes are functioning properly except for /chef/:id. I utilized yeoman's angular generator, and I am running everythi ...

Conceal mobile button

Welcome to my website: Is there a way to hide the button on mobile phones? I want to create different buttons specifically for mobile devices. Below is the HTML code for the buttons. HTML <a href="http://site9171756.91.webydo.com/Info.html" target="p ...