Sophisticated CSS layout positioning

I've been struggling to achieve a specific positioning using CSS:

However, after numerous attempts over several days, the best result I could obtain looks like this:

Could you lend me a hand in achieving the desired positioning, considering these factors:

  • The red comments in the "try" picture (refer to JSFiddle below) that highlight some major constraints
  • The need for the positioning to work on IE8+, FF10+, Chrome, Opera, Safari (with CSSPie and selectivizr for IE8 compatibility)

Here is the JSFiddle along with the following code snippets:

HTML

<body>body (all divs may have some padding, margin, and border. All divs adjust their height to their content.)
<div id="globalcontainer"><span class="important">#globalcontainer (fixed width, not really centered into body : see center)</span>
  <div id="header">#header (100%)</div>
  ...
  <DIV class="bloc" style="width:90px;">bloc</div>
      </div>
  </div>
</div>
<div id="footer">#footer (100%)</div>
</div>
</body>

CSS

* {
    font-family:Arial;
    font-size:11px;
    border:1px solid black;
    padding:10px;

    box-sizing:border-box;
    -moz-box-sizing:border-box;
    -webkit-box-sizing:border-box;

    background-color:rgba(125,125,125,0.1); 
}
...
-webkit-border-radius: 0px;
    -moz-border-radius: 0px;
    border-radius: 0px;
}

Answer №1

Opting for the border-box box model is definitely the way to go.

Check out this layout structure that I frequently use: demo

It involves using wrapper divs with position: relative;, custom padding, and absolutely positioned elements with height: 100%; and overflow :auto;.

Some adjustments might be necessary, but you'll grasp the concept.

HTML

<div id="globalcontainer">
    <div id="global-wrapper">
    <div id="header"></div>
    <div id="middle">
        <div id="middle-wrapper">
            <div id="left">
                <div class="bloc"></div>
                <div class="bloc"></div>
                <div class="bloc"></div>
            </div>
            <div id="center-wrapper">
                <div id="center">
                    <div id="center-middlerow"></div>
                    <div id="center-bottomrow"></div>
                </div>
            </div>
            <div id="right">
                <div class="bloc"></div>
                <div class="bloc"></div>
                <div class="bloc"></div>
            </div>
        </div>
    </div>
   <div id="footer"></div>
  </div>
</div>

CSS

*,
*:before,
*:after{
    box-sizing:border-box;
    -moz-box-sizing:border-box;
    -webkit-box-sizing:border-box;
}
div{
    border: 1px solid black;
    padding: 10px;
}
html,
body{
    height: 100%;
}
#globalcontainer{
    height: 100%;
}
#global-wrapper{
    padding: 100px 10px;
    position: relative;
    border: none;
    height: 100%;
}
#header,
#footer{
    position: absolute;
    width: 100%;
    height: 100px;
    left: 0;
}
#header{
    top: 0;
}
#middle{
    height: 100%;
}
#middle-wrapper{
    position: relative;
    padding: 0px 200px;
    border: none;
    height: 100%;
}
#left,
#right{
    position: absolute;
    width: 200px;
    height: 100%;
    top: 0;
    background:#F0F0F0;
    overflow: auto;
}
#left{
    left: 0;
}
#right{
    right: 0;
}
#center{
    height: 100%;
}
#center-wrapper{
    border: none;
    padding: 0px 10px;
    height: 100%;
}
.block{
    background: #fff;
}

Answer №2

When dealing with a complex layout like this, it's crucial to not only utilize border-box, but also adjust the dimensions meticulously to achieve the desired appearance.

You can reference this fiddle for an example that mimics your screenshot: http://jsfiddle.net/SXJuT/

To view the layout in full screen, click here: http://jsfiddle.net/SXJuT/embedded/result/

CSS:

html, body { margin:0; padding: 0; height: 100%; width: 100%; overflow: hidden; font-size: 9px; }
div { border: 1px solid blue; box-sizing: border-box; padding: 2px; margin: 4px; }
#globalcontainer { width: 99%; height: 98%; background-color: #deebf7; }
#header { height: 5%; background-color: #d1e4f3; }
#middle { height: 86%; background-color: #d1e4f3; display: table; border-spacing: 4px; width: 99%; }
#footer { height: 5%; background-color: #d1e4f3; }
#left, #center, #right { display: table-cell; background-color: #c4ddf1; }
#left { width: 14%; }
#center { width: 68%; }
#right {  width: 14%; }
#center-middlerow { height: 80%; background-color: #bad5eb; }
#center-bottomrow { height: 20%; background-color: #bad5eb; }
#pageReceiver { height: 78%; background-color: #b1d0ec; }
#tip { height: 16%; background-color: #b1d0ec; }
#page { height: 95%; background-color: #a7cbe9; }
#pageHeader { height: 14%; background-color: #2e75b5; }
#pageContent { height: 62%; background-color: #2e75b5; }
#pageFooter { height: 14%; background-color: #2e75b5; }
.bloc { height: 20%; background-color: #2e75b5; }
#left > .bloc:nth-child(1), #right > .bloc:nth-child(1) { width: 50%; }
#left > .bloc:nth-child(2), #right > .bloc:nth-child(2) { width: 70%; }

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

Steps to utilize a variable in the form action for sending an email

I successfully retrieved the email_id from the first form using jQuery. However, I am struggling to figure out how to use it in the second form's action:mailto: attribute. Any suggestions on how to accomplish this? <form id="sForm" action="mailto: ...

Dynamic addition of CSS classes to HTML elements using PHP

I'm working on developing an application that includes multiple courses. Each course is completed over a certain number of days, such as 14 days or 20 days. To visually track progress, I've implemented a step progress bar that looks like this:htt ...

Convert the icon into a monochrome color scheme

Here is an icon included in my code: HTML: <a href="#" id="PickUp" class="PickUpIcon"></a> CSS: width: 24px; height: 24px; background: url(../images/Icons/Answer.jpg) no-repeat; cursor: pointer; This icon appears as described. Is it poss ...

What are the steps to resolve issues with my dropdown menu in IE9?

I have a cool CSS built hover-over drop-down menu that I want to add to my website. It works perfectly on all browsers except for IE9. Here is the code and stylesheet I am using: Check out the code and sheet here If anyone has any insights on what might ...

Assign a value to the cookie based on the input from the form

I recently asked a similar question, but it seems like I missed providing some context, which is why I couldn't get it to work. My goal is to set a cookie value of a form entry when clicking on it (using the carhartl jquery plugin), but nothing happen ...

"The dynamic row is experiencing issues with the live function not functioning as expected

I have a table with a CheckBox and 2 columns. When the CheckBox is clicked, I want to change the row color to Black, and also change the name attribute of <input type="hidden" name=old to <input type="hidden" name=new. When unchecked, the row should ...

What is the best way to center a paragraph vertically around a particular word?

Within this div, I have a paragraph. I am trying to position a specific word within the paragraph to be centered vertically, but my attempts using a span have been unsuccessful. Is there an easy way to achieve this? div { width: 300px; height: 250px ...

Which font, Helvetica or Verdana, has optimal support across all popular browsers?

When it comes to web design, the age-old debate between Helvetica and Verdana arises. Both fonts render differently on major browsers like IE and FF, making it difficult to determine which is better supported. So, which font is the best choice for ensurin ...

Django SlideShow: Immersive Presentation of Images with Varying Display Times

Hey everyone, I could really use some assistance with creating an image slideshow: I have a couple of Django template variables named "ImagesVar" and "ImagesDurationVar". What I'm trying to achieve is to display "ImagesVar[0]" for the duration speci ...

Implement custom styles to enhance the appearance of users' Magento websites

Is it possible to add additional CSS only to users/customers who are logged into our webshop? If so, how should I go about it - through XML or PHTML? Stian ...

Encase a group of child elements within a parent container using

Currently, I am able to wrap an entire li-element in an ordered list with a link: $(e).wrap('<a href="#" onclick="window.open(\'/xyz/\');return false;"></a>'); This is the HTML construct: <li class=""> ...

Issues arise when trying to integrate Bootstrap modal with bootcards

I am currently implementing a modal with bootstrap: <div class="modal" id="contact-update-view"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-head ...

Automated downloading based on operating system recognition

1067/5000 How can I use JavaScript to automatically determine the user's operating system on a webpage and then download the correct installation file? Here is the code I have: HTML <!DOCTYPE html> <html> <body> <iframe id=" ...

How can I display different divs based on a selected option?

I'm encountering difficulties while attempting to develop the code for this specific task. My goal is to display or hide divs based on the selection made in a select option, with a total of 4 options available. There are 2 select elements <select ...

Upon clicking a button on page 1, the data is transmitted to page 2 before redirecting the user to page 3

When a user enters information into a text field on page1.php and clicks the submit button, the data is sent to page2.php where it is used to query a database and save it in an XML file. <Form name="search_form" method="POST" action="page2.php"> ...

Position the textAngular toolbar at the bottom of the text editing interface

I want to position the textAngular toolbar at the bottom of the texteditor-div instead of the top. Despite trying various CSS modifications, I haven't been successful in achieving this. JS: var app = angular.module('myApp', ['textAngu ...

Creating a persistent hover effect

Utilizing primarily CSS, along with background images and adjacent selectors, I am creating a page that displays unique human-readable text information when the user hovers over horizontally stacked images. The textual information is presented in a div on ...

PHP - Trouble with onClick event triggering "echo" to output Video and Image SRC using PHP tags

I am facing an issue with calling the data that I need to retrieve on a video src and image src. When I try to display them, they are not showing up. Can someone please provide me with the correct syntax? Thank you. I have a couple of questions, do I need ...

Troubles with border-image in CSS

I am currently experimenting with CSS's border-image property to create a custom border for a div element. Despite having what I believe to be the correct code, my image is not displaying as the border. Can someone please review this HTML/CSS code and ...

Prevent jQuery from scrolling once the fixed image reaches the bottom of the page

I am struggling to figure out how to keep an image fixed at the top of the footer div while scrolling to the bottom of a webpage. My approach involved calculating the height of the footer in order to adjust the scrolling behavior by subtracting it from th ...