A div layout with two columns where the right column overlaps the left column

I want to create a simple portfolio website with a two-column layout. The left column will house the navigation links, while the right column will display the content.

Below is the HTML and CSS code I am using:

HTML

<div id="container">
    <div id="nav">
        <ul>
          <li><a href="/">Home</a></li>
          <li><a href="about.jsp">About</a></li>
          <li><a href="portfolio.jsp">Portfolio</a></li>
          <li><a href="contact.jsp">Contact</a></li>
        </ul>
    </div>
    <div id="content">
        <p>Some content</p>
    </div>
</div>

CSS

html, body {
    height: 100%;
    font-size: 16px;
    margin: 0;
    padding: 0;
}
#container {
    max-width: 900px;
    position: relative;
    margin-left: auto;
    margin-right: auto;
}
#nav {
    width: 20%;
    height: 100%;
    float: left;
    background-color: #FFAD73;
    top: 0;
    left: 0;
}

#content {
    width: 80%;
    height: auto;
    float: left;
    top: 0;
    right: 0;
    background-color: #73C5FF;
}

li { list-style: none;
}

JSFiddle: http://jsfiddle.net/rcode74/m8w4yj8o/

The challenge I am facing with my current HTML/CSS setup is that when the browser window is resized too narrow, the navigation column overlaps with the content column. I tried setting a min-width for the navigation div, but it caused the content column to move below the navigation column when the browser is made narrow.

Answer №1

To prevent the overlapping issue, adjust the min-width property of your #container element. Without a set min-width, the columns may appear to overlap when attempting to maintain a 20-80 column ratio. This is especially noticeable when content is present in the left column.

For a live example, visit: http://jsfiddle.net/obna91x1/1/

#container {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    min-width: 500px; /* Adjust this value as needed */
}

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

Translate HTML form into PDF and send via email using PHPMailer

I've been doing some research on converting a filled-in HTML form to PDF and sending it via email, but I can't find a tutorial that explains how to do it. For example, take this form: <form id="contact-form" method="post" action="contact.php ...

The function $(window).scrollTop(); does not trigger fast enough

I have been working on creating a header that shrinks as you scroll down, stopping at a certain point. The header also includes a logo that moves up with it. However, I'm facing an issue where $(window).scrollTop(); doesn't respond quickly enoug ...

"Employing a Backend Task Runner for a jQuery-Based Mobile Application

Currently, I am utilizing jQuery Mobile in conjunction with HTML5 to provide support for Android and iOS devices. Is there a control or technology that functions similarly to a background worker? My goal is to send data to the server without interrupting t ...

Div that scrolls independently without affecting the position of other elements

Visit this link for reference <div class="col-10 content" id="content"> <ul> <li>News</li> <li>News</li> <li>News</li> <li>News</li> < ...

jQuery for validating input fields with positive integers only using regular expressions

I currently have two input fields in my HTML that look like this: <input type="text" class="txtminFeedback" pattern="^\d+([\.\,][0]{2})?$" placeholder="Minimum Feedback"> <input type="text" class="txtmaxFeedback" pattern="^\d ...

What is the best way to display a button one minute after the page has been loaded?

I am attempting to create a button that will appear in the middle of the page after 1 minute of it loading, but this button should only show up when text1 is displayed. I want to divide the page into two parts, where text1 and text2 together make one ful ...

Combining existing CSS classes with node labels in Cytoscape JS for Angular: A Guide

My project follows a consistent CSS theme, but the node's CSS style doesn't match. I'm looking to adjust the label colors in the CSS based on whether it's day mode or night mode. How can I accomplish this? this.cy = cytoscape({ con ...

One specific JS file fails to load only when using Internet Explorer Browser in conjunction with the debugger

I am encountering an issue with a project that utilizes angular JavaScript controllers to populate fields. Unfortunately, a specific page, members.cshtml, is not loading properly in Internet Explorer 11, despite working perfectly on Chrome and Firefox. Af ...

Avoid displaying a popup menu on the webpage during page refresh

How can I prevent a popup menu from appearing again after refreshing the page? I have tried using some javascript but haven't been successful. If anyone has a solution, such as a video tutorial or code snippet, please let me know. ...

How can we use JavaScript to add a class to the <html> element?

What is the method to apply a class to the root element <html> in JavaScript? ...

The single controller can now showcase various notification styles for operations such as insertion, updating, or error handling

I need to display notifications to the user based on three different scenarios using a controller. When data is successfully inserted When data is successfully updated In case of an error For each scenario, I want to show a different style of notificati ...

Bootstrap-enhanced JavaScript table filter functionalities

Hello, I am facing an issue with the table filter functionality. It seems to be working fine, but when I search for a name like "John" and there are multiple instances of "John" in the table, there is some blank space between the tables. I suspect the prob ...

Populate a secondary dropdown menu using the selection from a primary dropdown menu and retrieve the corresponding "value" instead of displaying the value as a dropdown option

I am attempting to create two dropdowns that are populated by another dropdown. Below is the code: HTML: <form type=get action="action.php"> <select name="meal" id="meal" onChange="changecat(this.value);"> <option value="" disabled select ...

Showing local storage on a webpage using Jquery

I have encountered an issue where I can successfully add and remove items from local storage, but the added item does not display on my HTML page. The expected behavior is that when an item is added to local storage, it should be visible on a favorites pag ...

Positioning the dropdown menu on the right with Boostrap 5.2 Navbar

After grappling with this problem for the past 72 hours, I've exhausted all my options and still can't seem to resolve it. I am currently working with Bootstrap 5.2 and have implemented a Navbar with a dropdown menu. My objective is to position i ...

What are the steps for retrieving values from list boxes?

I'm exploring the use of a two-sided multiselect box, also known as list boxes, within a Shiny app. After some research, I came across a jQuery multiselect library that looks promising: . I have integrated this library into my Shiny app. While the fu ...

Jquery form calculation not matching up

I've been struggling to make this jQuery math function work with my form. The snippet works fine, but when I try to integrate it into the actual form, I can't seem to get it aligned properly to perform the required calculations. Any suggestions ...

Select the element to emphasize it and reduce the visibility of others

I'm currently facing an issue with a block that contains multiple divs representing products. My goal is to have the selected product highlighted while the rest appear less prominent when clicked. I've managed to achieve this functionality, howev ...

Flask application unable to show segmented image

I am currently developing an image segmentation application that segments images into 'k' different colors Here is the code snippet for the Flask application: ##not revealing standard starting code app.config['template_path'] = r' ...