Having three adjacent divs with a full height and scrolling layout may not be compatible with all web browsers

After experimenting with various samples, I have managed to create a layout that works well in Chrome. However, I am facing compatibility issues with FireFox and IE.

My goal is to set up 3 side-by-side divs with a height of 100% and a width around 30%. These divs should display a scroll bar when their content exceeds the height.

Despite some margin problems related to floated divs, my main concern lies in the cross-browser compatibility issue. What could be causing my layout to not work consistently across different browsers?

On a secondary note, is there a more efficient way to evenly distribute the divs across the page without relying on spacer divs?

Take a look at the code here

html,body{
    height:100%;    
    margin:0;
    padding:0;
}

.content{
    display:table;
    width:100%;
    border-spacing:10px;
    border-collapse:separate;
    background:#A36;
    height:100%;
}

.Col
{
    float: left;
    border-radius:5px;
    background:#fff;
    width:31%;
    overflow: auto; 
    overflow-x:hidden;
    height:100%;
}

.spacer
{
    float: left;
    border-radius:5px;
    background:#ccc;
    width:2%;
    overflow: auto; 
    overflow-x:hidden;
    height:100%;
}
.clearfix
{
    display:block;
    clear: both;
    float:none;
}

HTML

<div class="content">
    <div class="Col">search</div>
    <div class="spacer"></div>
    <div class="Col"></div>
    <div class="spacer"></div>
    <div class="Col">
        Testing scrolling<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
        // More test content for scrolling...
    </div>
    <div class="clearfix"></div>
</div>

Answer №1

It is important to use HTML markup for structuring content and not rely on unnecessary markup for styling, as that should be left to CSS. Here's a suggested approach:

HTML

<div class="col col1">
  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test<br>  test
</div>
<div class="col col2"></div>
<div class="col col3"></div>

CSS

html, body{
  height:100%;
  margin:0;
  padding:0;
}

body {
  overflow: auto; /* clear float */
}

.col {
  float: left;
  width: 30%;
  height: 100%;
  overflow: auto;
}

.col1 { background-color: red; }
.col2 { background-color: green; }
.col3 { background-color: blue; }

http://codepen.io/anon/pen/qAGFd

I highly recommend checking out the CSS tutorials available on lynda.com, they are incredibly informative and helpful!

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

What are the steps to include media queries?

My website looks good on big monitors, but not on smaller ones or on mobile phones. I need help with adding media queries to my CSS Reset so it works across all devices. Here's the website link and the CSS Reset code: html, body, div, span, applet, o ...

The distance from the edge of my tilted svg icon to the svg artboard

I'm currently working on developing a basic web icon system using SVG sprites. However, I have encountered a spacing issue in my code around one specific icon (between the Smash Magazine icon and the red border). I am trying to figure out how to remov ...

The total sum displayed after decoding JSON always varies in count

I am a beginner when it comes to using APIs and I am facing an issue with counting the data and displaying it in an HTML view. When I use count($data) to count it in the HTML view, the result is different from the actual data received from the API. Below a ...

The use of Angular's ngClass directive does not work within the link function

I have a straightforward directive that renders an element, and this is the template: <div class="nav-item"></div> The .nav-item class looks like this: .nav-item { height: 50; } Here's the directive in action: angular.module('m ...

What steps are involved in creating a table using Bootstrap framework?

Hey there! I need your expertise on how to create a specific layout using bootstrap: codepen.io/anon/pen/bqJdQJ <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <div cl ...

Utilizing Javascript to Open a New Tab from Drupal

I'm attempting to trigger the opening of a new tab when a specific menu link is clicked within a Drupal website. My initial approach was to incorporate JavaScript directly into the content of the page, but unfortunately this method has not been succes ...

Bootstrap causing issues with multinavibar functionality

Hi everyone, I have been using multinavbar but when I view it on mobile, the toggle and menu are not working properly. Below is the code snippet for reference: <div class="navbar navbar-default navbar-static-top" role="navigation" style="height: 114px ...

What is the process for updating the CSS style of every other piece of data (such as an image) retrieved

Is it possible to utilize PHP code when retrieving data from a MySQL database in order to have every other record display with unique CSS formatting? For instance, I am incorporating images similar to this in my comment system: http://prntscr.com/3hpiep ...

The validator on the W3 Schools website flagged an error for me

Has anyone encountered this particular validation error from W3 School before? I have a basic IMG element that is throwing an unusual error on line 43, column 112. I am completely baffled. Error Line 43, Column 112: Attribute target is not allowed on the ...

The size of the search input and textarea in HTML decreases when viewed on an iPad device

Currently utilizing Bootstrap 3 and AngularJs for this project. Implementing the following markup for the input field with type 'search': <input type="search" class="form-control" id='roomSearch' placeholder="Search" ng-model=&apo ...

Error in Jquery click function not being triggered

I'm in the process of developing an eCommerce platform where users can choose options and have their shopping carts automatically updated using jQuery. Users will be presented with a few radio buttons to select from, and as they make their choice, th ...

Steadfast item securely fastened to its guardian

How can I ensure a fixed object within a relatively positioned parent is clipped to its parent's boundaries as it moves with scrolling down the page? I have been trying to find a solution for this issue, but haven't had any luck so far. ...

CSS-exclusive dropdown menu elements peeking out

I have been working on a CSS-only drop-down menu and I am encountering an issue where other content seems to be showing through. Despite my efforts, I can't figure out why this is happening. If you would like to take a look, here is the link: http:// ...

Incorporate a dynamic animation feature into the Morris Chart

I have successfully created a chart using Morris JS. However, the chart currently loads on the screen without any animation effect. I am interested in enhancing the visual appeal of the chart by adding an animation effect to it. Below is the script I am u ...

Tips for utilizing flexbox to establish a maximum width and prevent abrupt layout changes when incorporating media queries

I am facing an issue with my responsive design using flexbox. On mobile, my 3 boxes containing products named Ragnar, Thor, and Odin look great. However, when I switch to tablet or desktop view, the boxes suddenly grow larger due to the media query set wit ...

What is causing the resistance in changing the color of my current navigation items?

I've encountered a small challenge with my header section. Despite multiple attempts, I'm struggling to change the color of the 'current' menu item. It seems that overriding Bootstrap's default color is proving to be more difficult ...

The dropdown in the HTML tbody section is displayed above the thead

I'm experiencing an issue where my tbody element is appearing above the thead section in my table. I've been unable to identify the cause of this problem. <table id="myTable" class="table table-inverse table-hover"> <thead id = "h ...

Creating unsightly class names using Node.js

Is it possible to automatically create random and unattractive class names? For example, is there a tool or plugin that can substitute the .top-header class with something like .a9ev within my CSS code? It would also be ideal if the class name in the HTML ...

Generating grid-style buttons dynamically using jQuery Mobile

I am in need of assistance to create a dynamic grid using jQuery Mobile. The grid should consist of buttons with either 'onclick' or 'href' functionality. The number of buttons should be generated dynamically at runtime. Specifically, I ...

Guide on shifting an element into a different one with the help of jQuery

I'm attempting to relocate an element within another in order to enable a css :hover effect. <ul> <li id="menu-item"> //move into here </li> </ul> <div class="tomove">...</div> 'tomove' is set to dis ...