If the content within a <div> element exceeds the available width, a horizontal scrollbar will be displayed

I have a scenario where I am using an absolute div to overlap another div. The div that overlaps is the absolute one (.content), and if the overlapped div (.left) doesn't fit the screen width, a horizontal scroll bar does not appear. How can I automatically make the horizontal scroll bar visible when the content exceeds the given width? Here is the CSS:

.left {
    width: 70%;
    height:100%;
    float:left;
    overflow-x:auto;
}
.content {
    position: absolute; 
    width: 70%;
    height: 100%;
    margin-top: 0px;
    margin-bottom: 0px;
    margin-right: 0px;
    margin-left: 130px;
    background-color: #2b3e50;
    border-left-width:5px;
    border-left-style:solid;
    border-left-color:#153450;
    padding-left: 20px;
}

Any help in resolving this issue would be greatly appreciated.

EDIT
Here is the div structure:

<div class="topbar">
    <div class="fill">
        <div class="container">
            Home
            <ul class="nav">
                <li> One </li>
                <li> Two </li>
                <li> Three </li>
                <li> Four </li>
            </ul>
            <p align="right">Log-out </p>
        </div>                
    </div>
</div>
<div id="loader" class="left" style="border-right-width:15px;">

</div>

<div class="container">
    <div class="content">

        <div class="row">
            <div class="span14">
                @content
            </div>
        </div>

    </div>

</div>
<script>
$("#loader").html('<object data="@routes.Tags.map(false)" />');
</script>



EDIT
I surrounded the left div with a parent div.

<div class="parent">
            <div id="loader" class="left" style="border-right-width:15px;">

            </div>
        </div>  
        <div class="container">
            <div class="content">

                <div class="row">
                    <div class="span14">
                        @content
                    </div>
                </div>

            </div>

        </div>

Using the following CSS for parent:

.parent {
    width: 100%;
    position: relative;
}

However, the scrollbar still does not appear.

Answer №1

The left element in your HTML is not a child of the content element, so you won't be able to make it scroll. If you have a parent and child relationship, then simply apply position: relative to the parent block. Check out this example here: http://jsfiddle.net/98pQ2/

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

Implement the CSS display flex property for more flexible layouts

After working on some HTML code, I found the following: <section class = "personal_proyects"> <article> <div class = "personal_details"> <h3>Canal YT: Codigo RM</h3> < ...

How to rotate text direction using JavaScript and CSS

Despite my extensive efforts, I have been unable to find a solution to a seemingly simple problem. In JavaScript, I have generated dynamic text using the following code: context.fillText('name', 10, 10, 20); Now, I need this text to be ori ...

Ways to change the class attribute on button click with jquery

I attempted to change the class attribute here, but unfortunately was unsuccessful. Can anyone provide guidance on how to toggle the class value successfully? <button id="mybt" class="fa fa-plus"></button> <script> $("#m ...

The navigation bar text spills over the designated area

I'm facing an issue in the front end where the navbar does not adjust on narrow screens, causing text to overflow. Although it works fine on wide monitors and mobile screens, iPads in portrait view have the last section of the navbar extend outside of ...

The .on() function in Jquery seems to be malfunctioning when it comes to handling dynamically

Despite my efforts to find a solution after exploring other questions and attempting various possible fixes, I am still unable to correctly bind the click event. Any assistance would be greatly appreciated. My current project involves a webpage that intera ...

Hiding Div with JavaScript (Quick and Easy)

Hey there, I'm looking to make regStart and regPage alternate visibility based on a click event. I'm still getting the hang of JavaScript so any simple answers would be appreciated. <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/x ...

I am encountering an issue where the function send_mail is receiving multiple values for the argument fail_silently

https://i.sstatic.net/QUt2A.png My small program encountered an error when attempting to email information from a form. Here's the type of error I got: I'm writing a simple little program ... when I'm trying to email this info. from that fo ...

Passing a PHP variable through a URL using the GET method

I need to pass a value using the get method. The code snippet is as follows: <td><a href="cart-remove.php?id={$row['id']}" class="remove_item_link"> Remove</a></td> The value I want to send is stored in $row['id&a ...

lines stay unbroken in angular

I am encountering an issue when I execute the following code: DetailDisplayer(row) : String { let resultAsString = ""; console.log(row.metadata.questions.length); (row.metadata.questions.length != 0 )?resultAsString += "Questions ...

Please select the links located beneath the see-through triangular or polygonal shapes

Review the code snippet provided at the following link: http://jsfiddle.net/q8Ycz <div style="background-color: red; width: 200px;" onclick="alert('behind')"> <div><a href="test">test test test test test test test test test ...

Stop the creation of new div elements once the minimum height has been reached or when text is past

Here is the HTML code I am working with: <div id='parent' align='right' dir='rtl' style=padding:0px;margin:0px;font-weight:bold;width:300px;height:auto;min-height:300px; "'<div align='right' dir='rt ...

W3C validation issue: "Failure to immediately follow a start-tag with a null end-tag" and similar errors

Encountering validation errors with the following code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <hea ...

Set tab navigation widget with a fixed height

I am struggling with setting a fixed height for my tabs widget so that when I add more content, it will display a scrollbar instead of expanding endlessly. I have checked the CSS and JS files but cannot figure it out. It is important for me to contain this ...

Displaying Bootstrap 5 Cards in a Vertical Layout

My webpage currently displays a row of cards horizontally, but I would like them to align vertically on smaller screens. Currently, when the screen is shrunk, the cards go off the page instead of stacking vertically. I still want the cards to have equal sp ...

What is the best way to manage DOM modifications in a responsive design layout?

Developing a responsive website with only one breakpoint can be challenging, especially when restructuring the DOM to accommodate different screen sizes. It's important to consider not just CSS and media queries, but also how the elements are arranged ...

Limiting the size of textboxes in Twitter Bootstrap

I am currently working with bootstrap text boxes in the following manner: <div class="row"> <div class="col-lg-4"> <p> <label>Contact List</label> <select class="form-control" id="list" name="li ...

Issues with CSS animations and transformations on SVG files are not being resolved

I've been attempting to create a transform animation using an SVG file, but unfortunately, the animation or transform isn't functioning at all. I've taken the time to research this issue, however, I haven't found a solution yet. Can any ...

Guide on dragging and dropping without losing the item, allowing for continuous drag and drop functionality

function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev.dataTransfer.setData("text", ev.target.id); } function drop(ev) { ev.preventDefault(); var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementB ...

What is the best way to implement a slide-down animation on a stateless component in React JS using either ReactCSStransitionGroup or ReactTransition

I am looking to create an animation for a stateless component that starts off with display:none, and then becomes visible when the parent component's state changes. I want it to slide down like a dropdown menu effect. I am new to animations and have b ...

When the window is resized, the div containing a table is getting pushed beyond its original

I have been developing a 'calculadora de creditos' or credits calculator. For this project, I used a responsive layout. Despite searching extensively online for solutions to my issue, I came up empty-handed. CSS CODE: (CSS code here) HTML CO ...