div layout; sidebar movements occur after appending div to the header

Having trouble mastering layouts, I am attempting to create a full-width header that includes a left sidebar and a right sidebar. The body is split into 5 sections: full width, left and right sidebars, center content with 3 columns, and the footer mirroring the header. The sidebars have fixed widths, so the center content will adjust based on screen size. I've tried multiple approaches to achieve this without success! My current best attempt involves adding 'commented' code which creates the left header sidebar as intended, but unfortunately shifts the left sidebar into the center section where the left sidebar should be.

I believe I am very close to the desired layout but missing something crucial. Can someone guide me in the right direction?

Html

<body>
<div class="container">
    <div class="header">
        <!--<div class="headerleft">
            <div class="headerleftcon">leftcon</div>
            </div>-->
        <div class="header-content">Header
        </div>
    </div> 
    <div class="body">body
        <div class="left-sidebar">
            <div class="left-content">left sidebar</div>
        </div>
        <div class="right-sidebar">
            <div class="right-content">right sidebar</div>
        </div>
        <div class="content">Content
        <div class="left-col">
            <div class="left-colcontent">left col</div>
        </div>
        <div class="right-col">
            <div class="right-colcontent">right col</div>
        </div>
        </div>
    </div> 
    <div class="footer">
        <div class="footer-content">Footer</div>
    </div>
</div> 
</body> 

CSS

html, body {
 height: 100%;
 width: 100%;
 padding: 0px;
 margin: 0px;}
.header, .footer{
 height: 80px;
 background-color: #EFEFEF;
 position: relative;}
.header-content{
 padding: 20px;
 text-align: center;}
/*.headerleft{
 height: 100%;
 background-color: red;
 width: 200px;
 float: left;}
.headerleftcon{
 padding: 0px 0px 0px 0px;}*/
.footer-content{
 padding: 20px;
 text-align: center;}
.container{
 height: 100%;}
.body{
 height: 100%;
 margin-top: -80px;
 margin-bottom: -80px;
 background-color: #C7DFFA;} 
.content{
 padding: 0px 0px 0px 0px;}
.left-sidebar{
 height: 100%;
 background-color: gray;
 width: 200px;
 float: left;} 
.right-sidebar{
 height: 100%;
 background-color: gray;
 width: 200px;
 float: right;}
.right-col{
 height: 500px;
 background-color: blue;
 width: 150px;
 float: right;} 
.left-col{
 height:500px;
 background-color: blue;
 width: 150px;
 float: left;} 
.left-content{
 padding: 100px 10px 100px 10px;
}
.left-colcontent{
 padding: 100px 10px 100px 10px;} 
.right-content{
 padding: 100px 10px 100px 10px;
 text-align: right;}
.right-colcontent{
 padding: 100px 10px 100px 10px;
 text-align: right;

JSFiddle

Answer №1

Check out this jsfiddle for more information: http://jsfiddle.net/Ab2LT/

I'm uncertain if this matches your expectations. I included a

<div style="clear:both"></div>
at the end of the div header to clear the floated elements.

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

Style Vue slots one by one

I am a beginner delving into the world of vue (specifically, vue 2) and aiming to grasp the concept of utilizing slots in the most effective manner. Below is the code I'm working with: <template> <div> <button cla ...

The curious case of looping and peculiar Vue actions

I've been working on a project where I am looking to dynamically add more input fields upon clicking a button. My initial attempt using jQuery.append ran into issues with detecting v-model. Switching gears, I decided to try achieving the same outcom ...

The browser is able to cache the selected state of a select tag and will disregard any instances where selected=

When rendering a drop down box, I include a currently selected value using selected="true". <select id="dropDown"> <option selected="true" value="1">value2</option> <option value="2">value3</option> <option va ...

Implementing a dual hover effect on a Div element

I am working with HTML code that includes an image and text <div class="subcontainer1"> <img src="a.png" alt="" class="imgcolumn"> <h3 class="header3">Hello</h3> </div> This setup places the content above the image. ...

Utilize BootStrap framework to embed Twitch player, ensuring it fills the entire width of its parent element

I'm new to web development and struggling to make my embedded Twitch player use its parent's full width. The height is fine, but using the d-flex class from Bootstrap makes the player extremely thin. Please review my code here: https://jsfiddle. ...

Is there a way to adjust the font color when the expiration date passes?

My goal is to change the color of text to green when the expiration date has not been reached yet. If the expiration date has passed, then the text should be red. .curentDate { color: rgb(54, 168, 54) } .expirationDate{ color: red; } <div cl ...

Eliminating specific text and images from WordPress articles

I am working on a Wordpress website where the post's content is displayed using <?php the_content(); ?> The content includes images and text that are all outputted within < p > tags. My goal is to style the margins/padding of the image ...

Tips for positioning your side navigation menu parallel to the page edge

Im looking to have the side navigation floated to the left as I scroll down the page. I tried using the sticky property, but it didn't work out. Here's a snippet of the code: .sticky-class { position: sticky; top: 30px; } This is how my HTML ...

Picture appears to be off-center

I created a loginPage.php file with the following content: <?php //some php stuff ?> <!DOCTYPE html> <html> <head> <title>Login Form Design</title> <link rel="stylesheet" type="text/css" href="stylelogin.c ...

Tips for customizing the appearance of dayMouseover in Fullcalendar

While working on my Angular application, I encountered an issue with the Fullcalendar plugin. Specifically, I want to dynamically change the cell color when hovering over a time slot in AgendaWeek view (e.g. 7.30am-8.00am). I am striving for something like ...

Tips for creating a smooth transition effect using CSS/JavaScript pop-ups?

Looking for some assistance in creating a CSS pop-up with a touch of JavaScript magic. I've managed to trigger the pop-up box by clicking a link, and while it's visible, the background fades to grey. But I'm struggling to make the pop-up fad ...

A helpful tip on how to designate a specific color to the helperText in Material UI in order to emphasize

Is there a way to customize the color of helperText in material-UI for highlighting errors in a TextField? I've been struggling to change the color of helperText with no success. I attempted using MuiFormHelperText-root-406 to add CSS styles, but it ...

Implementing the Upload Feature using AngularJS

Currently, I'm facing a challenge in implementing an upload button on my webpage using AngularJS and Bootstrap. Specifically, I am having trouble assigning the (upload) function to that button in AngularJS. The goal is for the button to enable users t ...

Achieving Vertical Alignment in a Bootstrap 4 Image Overlay Card

I am facing a challenge in trying to vertically center a FontAwesome icon within an Image Overlay Card. Despite attempting various methods like using d-flex and justify-content-center, none of them seem to be effective. What could I be overlooking? < ...

Failure to update content with new text in Ajax when GET/POST variables are included

I've been following a tutorial on Ajax functionality, and I have set up my code exactly like mmtuts. However, the new value isn't displaying until I make an adjustment to my test.js file: The original code that is not functioning as expected: $ ...

Tips for locating a specific HTML element within a string

Trying to convert a website into a phonegap app is proving to be challenging for me. When I send a request to the server, it responds with the HTML content as text. My goal is to extract certain HTML elements from this text and then append them to a div in ...

hover-triggered keyframe animation

Recently, I've been experimenting with CSS keyframe animation using the code below: .pulse-animation { margin: 50px; display: block; width: 52px; height: 52px; border-radius: 50%; background: #ff8717; cursor: pointer; animation: pul ...

How to center multiple divs in a row using HTML and CSS

I've been attempting to achieve a pretty basic task, but unfortunately my efforts have fallen short thus far. I have an image and a title that need to be centered within their parent div element. However, I'm struggling to find the proper way to ...

Is it necessary to include the Roboto font when using MUI?

After reviewing the Material UI documentation, it appears that users are responsible for loading the Roboto font: Material UI is designed to use the Roboto font by default. You may add it to your project with npm or yarn via Fontsource, or with the Googl ...

Adding the Setting component to the Style Manager

I'm struggling to add component settings (traits) into the Style Manager panel section because of insufficient documentation. The way it is demonstrated in the demo is not clear to me. Is there a specific block of code that I should be using? I' ...