Maintain the basic structure while ensuring divs are properly aligned

Behold, my div structure!

ONE // at the top level

TWO THREE // two divs side by side in the middle level

FOUR // residing at the bottom

<div id="ONE">
  <div></div>
  <div><img src="logo.png"></div>
</div>

<div id "FIVE">
  <div id="TWO">
    <div></div>
    <div></div>
  </div>
  <div id="THREE">
    <div></div>
    <div></div>
    <div></div>
  </div>
</div>

<div id="FOUR">
  <div></div>
</div>

The burning question: How can I make TWO align with the bottom level of THREE without disrupting the rest of the layout?

I attempted to apply position :relative; to "FIVE" and position: absolute to "TWO" and "THREE". However, this caused "FIVE" to overlap with "ONE".

EDIT: Check out the Fiddle!

#ONE{
    width: 100px;
    height: 50px;
    background-color: #ff0000;
}
#FIVE{
    width: 100px;
    height: 50px;
    background-color: #cdb79e;
    position:relative;
}
#TWO {
    display: inline-block;
    background-color: #9e0b0f;
    position:relative;
    width: 50px;
    height: 10px;
    float: left;
}
#THREE{
    display: inline-block;
    background-color: #088da5;
    position:relative;
    width: 50px;
    height: 50px;
}

Answer №1

Check out the jsfiddle link below to see examples using display: table; and display: table-cell;

#TABLE{
    display: table;
    width: 100px;
}
#CELL_ONE {
    display: table-cell;
    background-color: #333;

    width: 50%;
    height: 20px;
}
#CELL_TWO{
    display: table-cell;
    background-color: #666;

    width: 50%;
    height: 40px;
}

https://jsfiddle.net/user123/example3945/

Answer №2

To achieve the desired layout, utilize float properties and ensure proper CSS styling. More detailed instructions can be found in this fiddle.

Code Snippet

<div id="ONE">
  <div style="background: none repeat scroll 0% 0% red; width: 50%; float: left; height: 100%;">&nbsp; DIV 1</div>
  <div style="width: 50%; float: left; background: none repeat scroll 0% 0% blue; height: 100%;">&nbsp; DIV 2</div>
</div>

<div id="FIVE">
  <div id="TWO">
    <div  style="width: 50%; float: left; background: none repeat scroll 0% 0% green; height: 100%;">&nbsp; DIV 3</div>
    <div  style="width: 50%; float: left; background: none repeat scroll 0% 0% yellow; height: 100%;">&nbsp; DIV 4</div>
  </div>
  <div id="THREE">
    <div style="width: 33.33%; float: left; background: none repeat scroll 0% 0% red; height: 100%;">&nbsp; DIV 5</div>
    <div style="width: 33.33%; float: left; background: none repeat scroll 0% 0% grey; height: 100%;">&nbsp; DIV 6</div>
    <div style="width: 33.33%; float: left; background: none repeat scroll 0% 0% pink; height: 100%;">&nbsp; DIV 7</div>
  </div>
</div>

<div id="FOUR">
  <div>&nbsp; DIV 8</div>
</div>

CSS Styles

#ONE{
    width: 500px;
    height: 60px;
    background-color: #ff0000;
    float:left;
}
#FIVE{
    width: 500px;
    height: 200px;
    background-color: #cdb79e;
    float:left;
}
#TWO {
    display: inline-block;
    background-color: #9e0b0f;
    width: 500px;
    height: 100px;
    float: left;
}
#THREE{
    display: inline-block;
    background-color: #088da5;
    width: 500px;
    height: 100px;
    float:left;
}
#FOUR{
    display: inline-block;
    background-color: #eeeeee;
    width: 500px;
    height: 50px;
    float:left;
}

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 could be causing my website to automatically adjust the CSS height on its own?

My code looks like this: <li style = "height: 250px;"> <p>Foo</p></li> Despite my efforts, when I visit the website, the height doesn't seem to change. After inspecting the element in Chrome, I discovered that it's s ...

Adjustable div height: reduce until reaching a certain point and then begin expanding once more

Incorporating a hero section to display content is my current approach. The design adapts responsively utilizing the padding-bottom percentage strategy, along with an inner container that is absolutely positioned for central alignment of the content. The ...

Attaching an SVG chart to a node causes it to malfunction, indicating a fundamental element is absent

I've been attempting to display a d3fc graph on an svg node within my react.js component and return the entire structure. However, it crashes when I try to apply .datum(my_data) to the d3 selection. I suspect that I'm overlooking something fundam ...

I am unable to make any changes to the CSS in the WordPress code that is already integrated

I have created a static web page to serve as my primary homepage. The page is built using HTML and CSS, with some PHP code pulled from My WordPress integrated into it. One of the functionalities I've added is to display the three most recent posts on ...

Can you please provide the CSS code that would style this table in a similar manner?

I am interested in utilizing the design of this table, but how can I update it to meet CSS standards and HTML5 equivalents? <html> <head></head> <body> <table border="1" bordercolor="#000000" style="background-color:#ffffff" w ...

Receive the innerHTML of an Element after appending additional Elements - Selenium

When working with my table in HTML, I have noticed that the <td> tag can be accessed in two different ways: 1. <td><font size="4" face="Arial"><i>Google</i></font></td> 2. <td>Google</td> I am curr ...

Is it possible to create an <h1> heading that can be clicked like a button and actually do something when clicked?

I am currently designing a web page that includes <div class="cane-wrap"> <h1 class="mc">christmas tic tac toe</h1> </div> located at the top center of the webpage, with autoplay running in the backgroun ...

What methods can be utilized to ensure that my wistia video player/playlist is responsive on different devices

I need some assistance with making my Wistia player responsive while using a playlist. I want the video player to adjust its size based on the screen size. Here is an example: My current code utilizes their iframe implementation: <div id="wistia_1n649 ...

Generating dynamic DOM elements using AngularJS can cause issues with the proper functionality of the Jquery .tab() method

My goal is to dynamically generate a list of elements - the first loop is dedicated to listing tabs for the menu, while the second loop involves the div with the tab contents. When I write it statically, everything works perfectly. However, the dynamic app ...

What is the secret behind Redactor JS's ability to display properly indented code snippets?

If you take a look at the Redactor JS demo and click on the button to show the HTML source code of the displayed content... ...you will notice that the code is properly indented: Most rich text editors or wysiwyg editors typically display code in a singl ...

Is the HTML5 capture attribute compatible with wkwebview?

Is it supported as stated in the title? For more information, you can check out the MDN documentation (Incomplete) and the Caniuse list of supported browsers. Surprisingly, none of them mention wkwebview. Does this attribute have support in wkwebview? Kno ...

Problem with displaying fonts in web browsers

I decided to create a React App using the Material UI library, but I wanted to customize it by changing the default font from Roboto to Overpass. I successfully imported the fonts using their library. <link rel="preconnect" href="https:// ...

Highlighted Navigation Options

When visiting , take note of the top navigation bar. The background color on this page is white, but as you navigate to other pages, the tab changes to a different color. How can you modify this behavior and change the class? Is PHP or jQuery necessary f ...

Is there a way to programmatically access the title of a TitledPane in JavaFX without using CSS?

Is there a way to set the title of a TitledPane to bold in Java code without using CSS? I created a TitledPane and I want the title's font weight to be bold. This is what I tried: TitledPane Rootpane = new TitledPane(); Rootpane.setText("Options"); ...

When a link is right-clicked, the window.opener property becomes null

Currently, I am utilizing the window.opener property in JavaScript to update the parent window from a child window. The parent window simply consists of a table with data and a link to open the child window. When the child window is launched, a JavaScript ...

Is it feasible in Vue to import an scss file with deep selectors into the scoped styles of a component?

Is it possible to extract a Vue component's scoped SCSS with deep selectors into a separate file and then import it back in? For example: // Main.vue <template> <div id="main"> <h1>Title</h1> <span>Text< ...

Utilizing jQuery to extract the `h1` element from a dynamically loaded external page within the

I am facing a challenge in selecting an h1 element from a remote page that I have loaded into $(data). Despite several attempts, I am struggling to write the correct code. When I use this code: console.log($(data)); The output is as follows: [text, meta ...

The li elements within a 960.gs layout will not extend to fill the entire width of the

I am still learning about this and I have been following some tutorials online. I managed to make the columns work with paragraph tags, but when I use ul > li tags, the image takes up the entire space. I'm not sure what's causing this issue. ...

Encountered a Socket.io issue: CONNECTION_TIMED_OUT_ERROR

I'm in the process of developing a simple HTML chat program. I've set up a node server for testing, but encountering a socket error when trying to access the HTML page. This is my first experience with Node.js and setting up a server, so it' ...

Creating an engaging user experience with a Django form

Creating a dynamic calculator <div id="calculator"> <h2>Calculate the price of sawing materials</h2> <form method="post" action="{% url 'products' %}"> {% csrf_token %} & ...