Parallel with one <div> and subsequently another <div>

I have been challenged by HTML and CSS to embrace humility:

Attempting to replicate the following design:

Here is my effort:

<div>
  <div style="width:800px;">
    <div style="float:left;width:25%;background-color:red;">Facility #: COMPANY10</div>
    <div style="float:left;width:50%;background-color:green;text-align:center;">FACILITY_112</div>
    <div style="float:left;width:25%;background-color:blue;text-align:right;">Facility Code: 4071</div>
  </div>
  <div style="width:800px;">
    <div style="float:left;width:25%;background-color:red;">Date: Jul 17, 2014</div>
    <div style="float:left;width:50%;background-color:green;text-align:center;">Custom Assessment (UDA) Report</div>
    <div style="float:left;width:25%;background-color:blue;text-align:right;">User: John Wayne</div>
  </div>
  <div>
    Time: 12:59:11 ET
  </div>
  <div>
    <hr/>
    Assessment Type: 1 - Braden Scale for Predicting Pressure Sore Risk
    <hr/>
  </div>
</div>

This leads to:

In need of assistance on how to fix this. Please help.

Answer №1

Keep the maximum width of your main <div> element restricted to 800px.

Answer №2

Relocate the width: 800px setting to the main container:

<div style="width:800px;">
  <div>
    <div style="float:left;width:25%;background-color:red;">Facility #: COMPANY10</div>
    <div style="float:left;width:50%;background-color:green;text-align:center;">FACILITY_112</div>
    <div style="float:left;width:25%;background-color:blue;text-align:right;">Facility Code: 4071</div>
  </div>
  <div>
    <div style="float:left;width:25%;background-color:red;">Date: Jul 17, 2014</div>
    <div style="float:left;width:50%;background-color:green;text-align:center;">Custom Assessment (UDA) Report</div>
    <div style="float:left;width:25%;background-color:blue;text-align:right;">User: John Wayne</div>
  </div>
  <div>
    Time: 12:59:11 ET
  </div>
  <div>
    <hr/>
    Assessment Type: 1 - Braden Scale for Predicting Pressure Sore Risk
    <hr/>
  </div>
</div>

...and refrain from using inline CSS styles

Answer №3

If you need to ensure that a floating div appears on a new line, simply apply the clear property:

<div style="clear:both">

By doing this, any existing left-floating elements will be disregarded and any future float left elements will start on a new line.

Answer №4

Make sure to add the following code inside the third div

clear:both;

This will result in something similar to:

<div style="clear:both;">
   Time: 12:59:11 ET
</div>

Check out the demo here: http://jsfiddle.net/EZ7wU/

Answer №5

Consider refraining from using inline css styles and focusing on a more organized html layout.

To display the content for the second row, place it within its own separate div:

<div style="clear: both;">
  <time>Time: 09:32:45 PT</time>
  <div>
    <hr/>
    Description: Specialized equipment for medical procedures
    <hr/>
  </div>
</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

Exploring the impact of JavaScript tags on website performance in accordance with W3

While researching website optimization strategies today, I came across an article discussing the benefits of moving JavaScript scripts to the bottom of the HTML page. I am curious if this approach aligns with W3C's recommendations since traditionally ...

Ways to stylize bullet points in lists with CSS in HTML document

I am currently working on a Q&A page using simple HTML. This is the current appearance of my page. Check it out here on JSFIDDLE. My task involves adding an 'A' to the answer for each question. Some answers have multiple paragraphs, so the ...

When clicking on a different tab, the Bootstrap tab will shift to the left, outlining the new selection

While working with Bootstrap, I created a small footer with a tab. However, whenever I click on the second value, the entire div shifts to the left. How can I keep it in place? Below is my code along with two images depicting how the first tab aligns corr ...

How to display only the thumbnail on WordPress archive page and remove the post excerpt

I am currently in the process of revamping my category archive to resemble a grid layout by utilizing custom CSS. I have successfully eliminated the elements I desired using code like this: .archive .entry-footer { display: none; } Now, I only have t ...

Issues with Navigating through a Scrollable Menu

I'm having a difficult time grasping the concept and implementing a functional scrolling mechanism. Objective: Develop a large image viewer/gallery where users can navigate through images by clicking arrow keys or thumbnails in a menu. The gallery an ...

Define the width and height of images specifically for screens with a maximum device width using @media queries

Having some trouble with the sizing of images on mobile devices. Using the code below, but for some reason, the height remains at 13em on smartphones, despite setting it differently for other devices. Any ideas why this might be happening? @media only sc ...

What is the best way to integrate JavaScript with my HTML command box?

I'm having some trouble with an HTML command box that is supposed to execute commands like changing stylesheets and other tasks. I thought I had everything set up correctly, but it doesn't seem to be working at all. Below is the HTML code with th ...

Preventing Adjacent Text from Moving Due to a Floated i Element

I have a div with a bootstrap icon positioned at the top right corner. However, I want to center the text horizontally without shifting the position of the icon. Is there a way to achieve this? See my sample code here: https://jsfiddle.net/x1Lvyu6t/3/ ...

What could be causing one of my images to not appear on my Gatsby page?

Hey there, I could use some help with this issue: Recently, I created a website using Gatsby.js and deployed it to my web server (which is running NGINX on Ubuntu 20.04). The site uses Gatsby Image for querying and displaying images, and everything seems t ...

Troubles with Placing Image on WordPress

Working on a Wordpress component for a website where I placed a "SOLD OUT" image over text. However, the issue arises when viewing the site on mobile devices, as the images are smaller and not in their correct positions due to using absolute positioning. ...

What could be causing these "areas" or "panels" to intersect with each other?

As I work on constructing a website, I'm facing an issue with the top two sections. They appear correctly when my screen is full size, but as soon as I adjust the screen size, they jump down and create white space. It seems like I may have approached ...

PHP do-while loop triggers out of memory error while running SQL query code

While running the code below, the website crashes with the error: "Allowed memory size of 268435456 bytes exhausted (tried to allocate 254643 bytes)" $queID = "LCGQ00" . $ID; $sqlquecheck = "Select QueryID FROM Questions Where QueryID = & ...

How come inactive links are still able to be clicked on?

I have been experimenting with various methods to disable links, but I seem to be unable to prevent them from being clickable. While I was successful in changing the cursor to 'not-allowed' when hovering over the disabled link, it still remains c ...

I'm still trying to figure out the property position. Why won't my page scroll? (My first time using HTML)

I'm having an issue with my webpage where it doesn't scroll even when the content exceeds the page length. I've tried adjusting the position settings for the body, html, and div elements but haven't seen any changes. Here is the HTML ...

Leveraging tailwind for achieving dynamic height responsiveness

My Tailwind-built page currently has a table in the bottom left corner that is overflowing, and I would like it to adjust its size to fit the available space and scroll from there. I want it to fit snugly in the bottom left corner of the browser viewport ...

How can I receive user input in JavaScript while incorporating three.js?

I am currently exploring the functionalities of this three.js example () and I am interested in enabling users to input specified X, Y, and Z positions for boxes dynamically. Initially, I considered utilizing a JavaScript prompt like below: var boxes = p ...

Creating a clickable navigation menu item with a clickable caret located on the same line

I've been developing a solution using Twitter Bootstrap to create a main navigation menu that expands upon hover on desktop, while the menu expands when clicking the caret on mobile (caret hidden on desktop). Additionally, I aimed to make the top-leve ...

Column Alignment Problem in Bootstrap

I'm currently working on a blog template project that resembles the design of this particular page However, I've encountered an issue with aligning the grids in a way that meets my requirements. To showcase my problem, I have shared my version o ...

CSS - Apply a captivating background to specific columns within a grid layout

Wow, I'm really struggling with CSS and this particular issue has me perplexed. I need to add background colors to specific columns but not all of them. The problem is that the padding gets messed up when I do this. Imagine having a headache while try ...

"Troubleshooting: Fixing the issue with jQuery datepicker not

After implementing the jQuery Datepicker on a field, I noticed that even though assigning a value to the field shows in Chrome's developer tools... Unfortunately, the assigned value does not show on the front end. I am aware that we can set a defaul ...