Trouble with intersecting DIV (and picture)

I'm facing an issue with a DIV overlap on my webpage.

When the window is maximized, here's how the webpage looks:

And this is how it appears when the window is resized:

What happens is, when users scroll to the right (indicated by the red arrow) to view the content, the text/image overlaps the sidebar (as shown by the blue arrow).

So, my question is, how can I prevent this from happening or what should be the correct approach?

Below is the HTML/CSS code. I haven't provided a Fiddle link as the issue can't be replicated that way:

<!DOCTYPE html>
<head>
...

Note: The reason why the sidebar has a position: fixed is because without it, this issue occurs:

Answer №1

The reason for this is that the sidebar is fixed in place. To accomplish your desired layout, you can try floating both the sidebar and the content to the left.

Here is a simple example to demonstrate: Code Sample

#sidebar
{
    float:left;
    background-color:#56B7BF;
    width:150px;
    height:400px;
}
#content
{
    float:left;
    background-color:#BF5E56;
    width:400px;
    height:400px;
}

Answer №2

To achieve the desired position for the side bar, use the position absolute property. You can find more information here: https://developer.mozilla.org/en-US/docs/Web/CSS/position

  <!DOCTYPE html><head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="apple-mobile-web-app-capable" content="yes" />
... (omitting the rest of the code for brevity) ...

</head>
<body>
<section><div id="sidebar">
<div id="logo"><img src="http://dummyimage.com/200x89/000/fff&text=Logo" width="200" height="89" alt="" /></div>
<ul id="menubar">
      <li ><a href="#">Link 1</a></li>
       <li ><a href="#">Link 2</a></li>
      <li ><a href="#">Link 3</a></li>
      <li ><a href="#">Link 4</a></li>
      <li ><a href="#">Link 5</a></li>

    </ul> 
    </div></section>
... (omitting the remaining body content for brevity) ...
</body>

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

The fixed header in IE8 is preventing the absolute positioned menu from displaying correctly

Here is some HTML and CSS code that showcases a fixed header and a menu that appears on hover: <style type="text/css"> .header { position: fixed; top: 0; width: 100%; height: 50px; background: #AAA; } ...

The layout of my website is perfect when my laptop's zoom is set to 90%, but at 100% it starts overflowing

Currently, I am in the process of building a website on my laptop while following an instructor's video tutorial. It has been important for me to set the same pixel measurements as the instructor in order to replicate the design they provided. However ...

Mastering the art of utilizing particles.js

Particles.js doesn't seem to be functioning properly for me—I'm struggling to pinpoint the issue. Any guidance or suggestions would be greatly welcomed, as I'm unsure whether it's related to an external dependency... HTML: <div ...

Create an animated effect using JavaScript to toggle the classList

As I delved into the world of CSS and HTML, I stumbled upon an interesting tutorial for creating a responsive navbar. You can check it out here. The tutorial showcases the mobile version of the navbar using the javascript function classList.toggle. I was ...

When using JQuery's html() function on a table cell, it may result in an error message stating "undefined is not a function."

I've been experiencing some issues with my use of JQuery. In my HTML table, I have elements with the class name .ulName. When I select these elements using $('.ulName'), everything works fine. However, when I try to iterate over them using ...

Unable to locate element by index using XPath

When using XPath in the Console to locate an icon element like $x("//mat-icon"), a list of elements is retrieved: 0: <mat-icon class="mat-icon notranslate mat…-color ng-star-inserted" _ngcontent-cvb-c17="" aria-hidden="false" aria-label="start" role= ...

What is the best way to position the section and footer to the left side of the sidenav?

I am relatively new to the world of html and css, trying my hand at constructing html layouts. I have encountered a bit of trouble in aligning the footer and section to the left of the nav bar. No matter what percentage widths I use, they always end up ove ...

What methods can I employ to utilize the name attribute for POST requests instead of the ID attribute in TinyMCE?

My inline TinyMCE form sends content to qry.php with the key "edit_me". I prefer the default behavior of sending content using the name attribute instead. <script type="text/javascript"> tinymce.init({ selector: '#edit_me', ...

Issue with website header disappearing

I'm currently struggling with an issue - I can't seem to pinpoint the problem. The header of a website template is functioning perfectly in 1280*800 resolution, but it's breaking on larger monitors (1900*1440). The header consists of three d ...

Sliding left and right with the help of jQuery

Hey there! I'm currently working on designing a sliding menu bar that can move left or right based on user interaction with arrow buttons. When the user hovers over the right arrow, the navigation bar smoothly slides from right to left until it reache ...

Scroll bar displayed on a non-editable text box

The TextArea is currently set to readonly mode using "ng-readonly," which is causing the scrollbar-thumb not to appear. It's important to note that I am not utilizing webkit in this scenario. Below is the HTML code being used: <textarea dataitemfq ...

How can I adjust the height of an iframe dynamically using AngularJS?

I wrote a function that resizes the height of an iframe element to always be 100% after it loads: app.directive('iframeAutoSize', [function() { return { restrict: 'A', link: function(scope, element, attrs) { ...

A step-by-step guide to showcasing dates in HTML with Angular

I have set up two datepickers in my HTML file using bootstrap and I am attempting to display a message that shows the period between the first selected date and the second selected date. The typescript class is as follows: export class Datepicker { ...

Styling columns with full height using CSS Flexbox

I'm currently experimenting with Flexbox to design a basic two-column webpage that stretches across the entire width and height. The left column has a fixed width of 200px, while the right column uses up the rest of the space. Here's what I have ...

Achieve a new line break when the user hits the "Enter" key using HTML and JavaScript

I'm in the process of developing a Chrome Extension that allows users to create a to-do list. My goal is to enable users to submit their task by pressing the "Enter" key, which should move the task to the next line after submission. I am currently fac ...

CSS properties are ineffective in scaling the image strip

I have a large image strip measuring 130560 x 1080. My goal is to load it into an image tag and use the parent div as a viewport, showing only one section of the image at a time. However, I'm encountering a problem when specifying the height and widt ...

In order to work with the optionSelectionChanges property of the MdSelect directive in Angular Material2, it

Within my application, there is a Material2 select dropdown widget containing several options. app.component.html <md-select placeholder="Choose an option" [(ngModel)]="myOption" (optionSelectionChanges)="setOptionValue(myOption)"> &l ...

Gain command over the underline style of text without relying on the border property

Ingredients: just a simple text input field. Question: Is there a way to customize the size, color, and position of the underline styling on an input tag? I noticed that the property text-decoration-color is supported in the moz browser engine, but I&apos ...

Contrast between Identification and Category

As I delved into the topic of CSS :Class and ID, I couldn't discern any noticeable differences between them when I attempted the provided examples. <!DOCTYPE html> <html> <head> <style> #para1 { text-align:center; color:red; } ...

How can we efficiently parse HTML without downloading the entire page source while being smart about it?

My application requires parsing a webpage, but I'm facing a major issue with the amount of data involved. The webpage varies in size from 400-500kb and needs to be parsed multiple times a day. On average, it should be parsed around 10-20 times daily b ...