Having trouble with centering a div in IE8?

Although I've never had issues with centering divs before, I'm facing a challenge in achieving 100% height columns (which seems to work on most browsers). It appears that the 100% height is causing problems with centering the div in IE8.

Currently, I'm attempting to align #wholewrap in the center using margin: 0 auto;, but it's not working as expected in IE8. Any suggestions on why this bug is happening and how to resolve it?

If you test this code, it should function correctly in Firefox, Chrome, and Opera, although I haven't tested it in IE9.

Interestingly, the results vary for IE8 between JSFiddle and actual testing, with discrepancies in what is displayed.

HTML

<html>
<head>
    <link rel="stylesheet" type="text/css" href="newcss.css"/>
</head>
<body>

<div id='wholewrap'>

    <div class='ttc'>
       <p>
          Left Column<br />
          Left Column<br />
          Left Column<br />
       </p>
    </div>

    <div class='otc'>
       <p>
          Right Column<br />
          Right Column<br />          
       </p>
    </div>

    <br style='clear:both;' />
</div>

</body>
</html>

CSS

div{border:1px #000 solid;}

html{height: 100%;}

body{height: 100%;}

#wholewrap{width:500px;margin:0 auto;min-height: 100%;height: 100%;}

.ttc{width:45%;float:left;min-height: 100%;height: 100%;}
.otc{width:45%;float:right;min-height: 100%;height: 100%;}

Answer №1

This issue may be associated with the doctype declaration. Consider placing either

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
or the HTML5 version <!DOCTYPE HTML> before the opening <html> tag.

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

Is there a way in PHP to output a blank or null value for an HTML date within an if/else statement?

As a novice programmer, my goal is to develop an invoice writer that utilizes an HTML form to collect four mandatory weekly date ranges and an optional fifth one for a "five week month". The first four dates require a "required" tag, but when the fifth dat ...

How to center content vertically between two divs using Twitter Bootstrap CSS

Seeking assistance in vertically aligning two divs using the table cell method. My goal is to have a single-slider div vertically aligned in the middle, but my attempts have been unsuccessful. Can anyone provide guidance on this issue? I am feeling confuse ...

Hover over the full-width sticky navbar to reveal a dropdown menu that stays at

I am new to using Bootstrap techniques and I am attempting to combine two different styles in a navbar. One involves a sticky navbar and the other a full-width dropdown navbar, both found on an educational website. https://www.w3schools.com/howto/tryit.as ...

PHP Alert: mysqli_stmt_bind_param() expects the first parameter to be of type mysqli_stmt, but a boolean was provided

Seeking assistance to troubleshoot an error in my code, which is also affecting the subsequent lines. At first, suspected issue with the query, but it seems accurate. Another point of concern could be related to 's' in mysqli_stmt_bind_param. Any ...

Sticky header in an Angular Material table

Using Angular 7 with Angular material design templates, my current result looks like this: https://i.sstatic.net/G4W78.jpg However, I am aiming for a result similar to the following - with a scrollbar under the sticky header. https://i.sstatic.net/WgjVh ...

Creating an image dynamically at runtime from a section of HTML code as it appears in the browser

Is there a way to use Java API or Jquery library to create an image from input HTML code? Alternatively, how can I capture a screenshot of a section of HTML code as it appears in the browser? For example: If I have the following HTML code: <h1>Logo& ...

I am currently experiencing issues with my logo not aligning properly within the navigation bar

I am struggling with the whole concept of bootstraps. If there is anyone out there who can provide some guidance, I would greatly appreciate it. Unfortunately, my style sheet is unable to connect to this website. The appearance of my navigation bar curre ...

Two divs positioned to the right on top of each other

I want to align two divs on the right side of their parent div, one above the other. Here's a visual representation: div#top |-------------------------------------||------------| |div#parent ||div#menu | | ...

The body content of the webpage needs to be updated without altering the header and footer, all while avoiding a page

On my website, I have a header menu that includes buttons for "home" and "about us." The default page is set to the home page. Within the home page, there is a specific link. When this link on the home page or the "about us" button is clicked, I want the ...

Tips for changing the order of a child element within a parent element that is positioned above its own parent element

I have a unique setup with two parent elements, one black and one red. Each parent element contains its own child element - the black parent has a gray div child, while the red parent has a pink div child. There are some constraints to consider: I am no ...

Fascinating CSS rendering glitch observed on zooming in: all browsers create a noticeable gap between containers except for Firefox

I'm experiencing a rather intriguing and peculiar issue with css styles when zooming in and out on the browser. Specifically, I've created a material ui card where the background-color changes upon clicking with an animation effect. The animati ...

What could be the reason for Chrome's failure to display flexbox positioning in an embedded Twitter timeline?

Could someone help explain why Chrome (Version 78.0.3904.97) doesn't adhere to flexbox css rules when trying to center a Twitter timeline on a web page? I've encountered an issue where attempting to center the Twitter timeline using the code pro ...

Conquering the Challenge of Unstyled Texts in Single Page Applications with Vue

Dealing with FOUT in SPAs using FEFs can be quite a challenge. :) It's an ongoing issue that I am currently trying to address. I have a dynamic component that loads various components, each requiring specific styling and fonts unique to them. The f ...

How to line up scrollable tables columns with the header using CSS

Link to JsFiddle : http://jsfiddle.net/gfy4pwrr/1 <table cellspacing="0" cellpadding="0" border="0" width="325" > <tr> <td> <table cellspacing="0" cellpadding="1" border="1" width="300" > <tr> ...

How come only half of my website is inaccessible when utilizing a sticky navigation menu, and what can be done to remedy this issue?

I've successfully implemented a menu on my website that stays fixed at the top of the page while scrolling. However, there is an issue where I am unable to click on the top 50% of the screen, rendering the website unusable. You can view a test copy of ...

Moving in a single direction while the class is being removed

I'm attempting to design a sidebar similar to this: function show_menu(){ document.querySelector('#sidebar').classList.toggle('sidebar_open'); document.querySelector('#blackscreen').classList.toggle('blacks ...

Position the previous and next buttons next to the thumbnail images

I've implemented the cycle2 jQuery plugin on my website successfully, but I'm facing an issue with positioning the prev and next buttons next to my thumbnails. I want them to be aligned with the first and last thumbnail without relying on absolut ...

Create three div elements that mimic the appearance and functionality of a video to the fullest extent possible

Dear all, I am currently working on a project where I aim to achieve a layout similar to the one featured in this video. The goal is to have 3 divs aligned horizontally, with an image div positioned at the center while the other two divs contain random let ...

Easy Registration Page using HTML, CSS, and JavaScript

In the process of creating a basic login form using HTML and CSS, I'm incorporating Javascript to handle empty field validations. To view my current progress, you can find my code on jsfiddle My goal is to implement validation for empty text fields ...

Unexpected issue with sliding menu toggle implementation

I have been struggling to make a menu slide to the left when a button is clicked, and then slide back to its original position when the same button is clicked again. Although I have been using the toggle method, it doesn't seem to be working for me. I ...