The layout with a simple and structured DIV display table-row-cell is not functioning properly

UPDATED: I have included a demo image showing the desired layout design for the site.

The 3 column layout table I am trying to achieve in the demo is not functioning as expected. I have provided an image of the desired outcome and a demo link with my current result. Below is the code along with the accompanying CSS:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>title</title>
</head>

<body>


<div style="display:table;width:100%;height:100%:min-width:1000px;">

<div style="display:table-row">
  <div style="display:table-cell;width:100%;min-width:1000px;height:23px;min-height:23px;"> only 1 TD 100% width only 23 height </div>
</div>

<div style="display:table-row">
  <div style="display:table-cell;width:200px;min-width:200px;height:77px;min-height:77px;"> left 200 px width </div>
  <div style="display:table-cell;width:100%;min-width:800px;height:77px;min-height:77px;"> middle 100% of screen width </div>
  <div style="display:table-cell;width:200px;min-width:200px;height:77px;min-height:77px;"> right 200 px width</div>
</div>

<div style="display:table-row">
  <div style="display:table-cell;width:200px;min-width:200px;height:100%;min-height:100%;"> left 200 px width but height 100% </div>
  <div style="display:table-cell;width:100%;min-width:800px;height:100%;min-height:100%;"> middle 100% of screen width but height 100%  </div>
  <div style="display:table-cell;width:200px;min-width:200px;height:100%;min-height:100%;"> right 200 px width but height 100% </div>
</div>


<div style="display:table-row">
  <div style="display:table-cell;width:100%;min-width:1000px;height:12px;min-height:12px;"> only 1 TD 100% width only 12px height </div>
</div>

</div>




</body>
</html>

Shown below is the image representing the desired layout:

For a live demonstration, you can view the Fiddle here: https://jsfiddle.net/yzr3v04u/

If CSS tables are meant to be versatile and easy to manipulate, why am I facing challenges getting the output I require? Are there alternative methods to achieve the layout displayed in the image demo?

Answer №1

Here's a tip: avoid using Tables to construct a website layout as it is not recommended for responsive design, especially on mobile devices. Instead, opt for CSS for better results.

If you wish to extend the column height to reach the bottom of the page, consider utilizing the new CSS3 measurement units known as Viewport-Percentage (or Viewport-Relative) Lengths.

To achieve this, simply include height: 100vh; in your CSS under .content-wrapper.

.header {
    width: 100%;
    height: 21px;
    background-color: orange;
}
.sub-header {
    width: 100%;
    height: 79px;
    background-color: brown;
}
.content-wrapper {
   width: 100%;
   height: 100vh; 
}
.left-column {
    display: inline;
    float: left;
    width: 200px;
    height: 100%;
    background-color: purple;
}
.middle-column {
    display: inline;
    float: none;
    height: 100%;
    background-color: white;
}
.right-column {
    display: inline;
    float: right;
    width: 200px;
    height: 100%;
    background-color: purple;
}
.footer {
    width: 100%;
    height: 12px;
    background-color: pink;
}
<div class="header"></div>
<div class="sub-header"></div>
<div class="content-wrapper">
    <div class="left-column">1</div>
    <div class="middle-column">2</div>
    <div class="right-column">3</div>
</div>
<div class="footer"></div>

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

Bootstrap Datepicker allows you to set a maxdate of 2 days from the initial date selected

Imagine this scenario: when I choose a date for Check-In on May 10th, I want the Check-Out section to automatically show May 10th selected as well, with the following 2 days available and the rest disabled. If you're looking for documentation, you ca ...

Beginner Inquiry: Implementing an Overlay Div with Text on Top of an Animated Element

Looking to create a stacked div layout but facing some challenges due to being new at this. // Particle Animation !function(a){var b="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===glo ...

Choose only the li elements that have been specifically clicked on

As a beginner, I am working on a project where I need to select the specific li element that is clicked using jQuery. However, I am facing an issue where clicking on one li selects all of them at once. Here is the link to my code snippet: JS FIDDLE This ...

Incorporating Mmenu into Bootstrap to enhance navigation

Is there a way to seamlessly integrate JQuery Mmenu into Bootstrap so that when the screen size changes, instead of the default top vertical responsive menu, it transitions smoothly to a sliding left-side menu with responsive design? Does anyone have any ...

JavaScript is causing a complete failure of CSS position transition functionality

Here are the tasks I want to accomplish: Show a div element; Move it to an initial position; Set transition properties; Move it to the target position using CSS transition. Below is a minimal example: function modifyElement() { /* var obj = ...

Issue with connecting Drupal 8 theme styling to website pages

Although the theme is functioning properly, the CSS styles are not being applied. Even when inspecting the developer console in Firefox, there seems to be a disconnect with the page. I verified that manually applying the CSS through the developer console i ...

Why is my navigation bar not centered like the rest of the elements on the page?

Just trying to make everything centered and clean. Everything seems to be, apart from my nav bar at the top which seems to stick to the right? I can't figure out why? Thank you html .............. <div id="nav"> <ul> ...

How to Dynamically Change the Background Color of an h1 Element using C# ASP

Is there a way to dynamically change the background color of my h1 header line based on the environment? For example, if the webpage is running in production or development mode, I want the background color of the H1 header tag to be adjusted accordingly. ...

Flipped the dimensions of an image for better responsiveness

Trying to implement this particular design on a responsive website. Wondering if there's a way to establish an inverse resizing technique using jQuery / Javascript so that as the viewport shrinks, the text size increases. Attempted to use jQuery to a ...

Displaying a table in Chrome/Firefox with a mouseover feature

Hovering over the rows of this table triggers a display of descriptions. html: <tr title="{{transaction.submissionLog}}" class="mastertooltip">... JavaScript: $('.masterTooltip').hover(function(){ // Hover functionality ...

vertical-align applied to table cells creating a floating effect

I have discovered that by adjusting the display property of the containing block to table and enclosing descendant block boxes in boxes with display property set to table-cell and vertical-align property set to top, it produces the same effect as if the fl ...

Navigation menu extending all the way to the far right of the webpage

This particular Angular 8 MVC C# application has been giving me a run for my money. I find myself caught in a cycle of fixing one issue only to have another one pop up in its place. Within the css file, I am setting *, html, body { font-size: 12px; font- ...

Maintain the anchor's appearance when it lacks an href attribute

I have created an anchor element that I'm using with a button role, so I haven't included the href attribute. <a (click)="doSomething()" role="button">Some data></a> When no href is set on an anchor element in Bootstrap, it lose ...

Using a Node.js module to shrink HTML files

Is there a way to minify HTML before rendering it? I'm aware of console minifiers like: html-minifier However, I am looking for a solution that can be implemented in the code itself. Something along the lines of: var minifier = require('some- ...

Display a Loading Indicator within a Bootstrap 4 Modal Dialog

I have a question regarding Bootstrap 4 and a simple trick I am trying to implement. I am looking to display a Loading indicator similar to Twitter every time the user opens the modal. I have some code that is working well, but I seem to have misplaced som ...

I am looking to extract the content of the title within an HTML table

Check out my code snippet below: <td class="text-left"><div class="ettn" data-toggle="tooltip" title="7f5e5b03-7d30-4001-acd9-c993d6c24301">ETTN</div></td> I am looking to extract the value ...

What alternative method can I use to open a mail with an HTML body if the mailto protocol is unavailable?

I recently added a button on my website for visitors to easily share my content via email. While the mailto protocol works, I'm not happy with the plain text format of the emails that are sent. I know that HTML emails allow for more customization and ...

What causes materialui styles to vanish upon refreshing in nextjs?

After consulting the materialui documentation (https://material-ui.com/guides/server-rendering/), I was able to find a solution, but I am still unsure of the underlying reason. Why does the style work initially during rendering but disappear upon subs ...

My current layout consists of side-by-side div containers, where two divs are nested within one container. Unfortunately, I am facing an issue where the right side of the layout is not aligning properly with the top when

I have successfully arranged my two sections to display side by side in my div container. The left portion, which contains a slideshow, looks exactly the way I want it to, but the right portion is not aligning correctly at the top. I attempted to add extr ...

Easily Update Your Div Content by Simply Clicking a Single Link/Button

I am in need of assistance here. My goal is to display dynamic content within a div. Below you will find the code I currently have: <script type="text/javascript"><!-- function AlterContentInContainer(id, content) { var container = documen ...