CSS problem, column does not remain in position unless filled with content

I am facing an issue with three floats in my layout. Two sections are exactly the same, but one of them loses its shape unless text is added to it.

Here is my HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>test</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <link rel="stylesheet" href="css.css" type="text/css" />
</head>

<body>
<div id="pagewidth" >
    <div id="header"><h2>Head</h2></div>
        <div id="twocols"> 
            <div id="maincol"><h1>Main Content Column</h1><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p> <p>Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus.</p> </div>
            <div id="rightcol"><p>a</p></div>
        </div> 
        <div id="leftcol"></div>
</div>
</body>
</html>

The issue lies in my CSS as rightcol won't show properly.

html, body{ 
 margin:0; 
 padding:0; 
 text-align:center; 
} 

#pagewidth{ 
 width:100%; 
 hight:100%;
 text-align:left; 
 margin:0 auto; 
} 

#header{
 position:relative; 
 height:3%; 
 background-color:#000000; 
 width:100%;
 display:block;
 overflow:auto;

} 

#leftcol{
 width:5%; 
 height:97%;
 float:left; 
 position:absolute; 
 background-color:#000000; 

 }

 #twocols{
 width:90%; 
 height:97%;
 float:right; 
 position:relative; 
  }

#rightcol{
 width:5%; 
 float:right; 
 position:relative; 
 background-color:#000000;
 }


#maincol{
 background-color: #FFFFFF;  
 float: left; 
 position: relative; 
 width:94%; 
 }

Answer №1

#rightcol lacks a specified height, causing it to default to 0 and remain invisible until content is added.

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

Upon clicking the button within the user control, the dynamic user control located inside the update panel vanishes

When I click the button inside the user control, it doesn't seem to trigger its event (button click). I simply want to reload the update panel so that this user control can take on the new effect in the button click event. I have added a user control ...

Disabling Highchart datalabels when the window is resized

While attempting to implement a pie chart using Highcharts, I have encountered an issue with the datalabels getting cropped on very low resolutions. I tried adding a windows.resize within the formatter function but it did not work. Below is the current c ...

List application now includes the capability of adding three items in one go, rather than just one

Furthermore, when the script is placed in the same file as the html, it results in the addition of two items simultaneously instead of three. var itemNum = 1; $("document").ready(function() { $("#addCL").click(function() { var itemId ...

What could be the reason for my SVG not getting generated?

Here is how my code is structured: Index.html <head> <script type="text/javascript" src="d3/d3.js"></script> </head> <body> <script type="text/javascript" src="Fuel_Plan.js"></script> <div class= ...

Sorry, but sessionStorage is not functioning correctly

So I created an input called "textmoney" that calculates the user's potential yearly earnings. Upon pressing enter, a link appears directing to another page with a more accurate estimation of the initial answer. I wanted to store and retrieve the "tex ...

Whenever I minimize the screen, certain column text is unable to be seen within the Td element

I have incorporated an HTML table inside a responsive-table div tag. In the numeric column of the table, there are decimal numbers. However, when I reduce the page size to fit smaller screens, some parts of the numeric values become invisible. The visibili ...

Achieving the perfect alignment for a slideshow in CSS and HTML

Greetings everyone! I am looking to center my slideshow on my website and would greatly appreciate any assistance. ISSUE I am trying to center the logo and the entire slideshow, but as you can see, it is slightly off-center to the right. VIEW ISSUE(IMG) ...

Bootstrap grid is not aligning correctly and is unresponsive to the .css file

I've been working through the exercises in the Jump Start Bootstrap book and following along with the examples provided. In chapter 02, we're focusing on creating a grid system. I've copied the code for the index.html and style.css files as ...

The children elements in the Flexbox div are not lined up inline with the text

Review the snippet below: div { display: flex; flex: 0 0 45%; max-width: 45%; } <div>Lorem ipsum dolor sit amet, <strong>dolor sit</strong>tempor incididunt ut la.tempor incididunt ut la.tempor incididunt ut la.tempor incididunt ut ...

The sub menu in IE 8 does not stay open while hovering over it

My website has a navigation menu with a sub-menu that appears when hovering over the parent element. While this works smoothly on modern browsers, Internet Explorer 8 presents an issue. When hovering over the parent li element in IE 8, the sub-menu is disp ...

What is the best way to deactivate the second selection option?

<select id="title0"> <option value="0">--- disable</option> <option value="1"> books</option> </select> <button id="save" type="submit">Save</button> <select id="title1"> <option value="0"& ...

Click event for jQuery horizontal accordion

I'm attempting to create a simple horizontal accordion-style element. My setup includes three 'banner' divs and three 'area' divs. Ideally, when I click on a banner, the corresponding area should animate - expanding in width to au ...

"Looking to add some movement to your elements on the webpage? Learn how to animate elements

I am looking to use jquery and css3 to animate the movement of a div tag to a different spot on the page, rather than shifting it instantly. Let's say I have the following: <div> <div class='item' style='float:left;' ...

What is the best way to ensure jQuery loads before CSS code on a website

I am currently working on a blog project that allows visitors to customize the background color by simply clicking on one of five available buttons. $(function(){ //Checking if a color scheme has already been selected var chosenColor = ...

When performing web scraping with Puppeteer, employing a single selector to target various types of data

As a budding web developer, I have recently delved into coding. My current knowledge is limited to HTML, CSS, JS, and NODE. Currently, I am working on a project involving page scraping and utilizing puppeteer. CHALLENGE - In scenarios like the o ...

How can I adjust the size of my elements to be responsive in pixels

While browsing through Quora and Facebook feeds, I noticed the fixed size of user display pictures: width: 40px; height: 40px; Even when resizing the browser window for a responsive design, these pictures maintain their size at 40px x 40px. What other f ...

Footer covering up content on small screen display

I've encountered an issue with a footer that won't stick to the bottom of the page. I'm pretty sure it's just a small oversight on my part, as I've successfully implemented this feature before. I've cleaned up the page to make ...

Extract the content within a div element and make changes to it

Here is a scenario: I need to retrieve the content of a div and then make modifications to it before inserting it into another div. See the code below: $("#loupe").on("click", function(){ $('#divBody').empty(); $('#divTitle').e ...

Experience the feeling of releasing momentum by click and dragging the scroll

One feature I am looking for is the ability to control the scroll speed when dragging, and have the scroll continue moving slightly after release instead of stopping instantly. CodePen: https://codepen.io/rKaiser/pen/qGomdR I can adjust the speed adequat ...

Applying the document height to window height ratio to create a scale ranging from 1 to 100

My goal is to create a scroll bar using two divs with heights of 110px and 10px. The smaller one will be nested inside the taller one, allowing for adjustment of its margin-height from 0 to 100px while still fitting within the larger div. When I refer to ...