Managing rows and columns layout with CSS

I am working on creating a layout using CSS where the header is at the top and colored in blue, yellow, and green parts aligned from left to right. Here is an example image of what I'm trying to achieve:

https://i.sstatic.net/IATwR.jpg

However, I am having trouble getting the Blue - Yellow - Green sections to align as desired.

I have attempted the following code:

Header

Blue

Yellow

Green

Answer №1

To achieve the desired effect of having the lower row expand and contract without wrapping, you can use the following HTML and CSS:

        <html>
<head>

<style>
.container {
  width: 100%;
  height: 300px;
  display: flex;
  flex-direction: column;
}

.header {
display:inline-block;
  flex: 1;
  background-color: brown;
}

.group {
text-align:center;
  flex: 5;
  background-color: grey;
  flex-direction: row;
}

.blue {
display:inline-block;
  flex: 1;
  width:33%;
  background-color: blue;
}

.yellow {
display:inline-block;
  flex: 3;
  width:32%;
  background-color: yellow;
}

.green {
display:inline-block;
  flex: 1;
  width:31%;
  background-color: green;
}
</style>
</head>
<body>
<div class="container">
  <div class="header">
    <h3>header</h3>
  </div>
  <div class="group">
    <div class="blue">
      <h3>blue</h3>
    </div>
    <div class="yellow">
      <h3>yellow</h3>
    </div>
    <div class="green">
      <h3>green</h3>
    </div>
  </div>

</div>

</body>
</html>

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 steps should be followed in order to integrate two themes within a single DOM element while utilizing a ThemeProvider?

<ThemeProvider theme={theme}> My goal is to utilize two themes simultaneously on a single DOM element using a theme provider. style={theme.flexRowLeft} Struggling with incorporating multiple themes at once, I am currently restricted to applying on ...

Begin the ul element from the left-hand side

Check out my latest JSFiddle creation: http://jsfiddle.net/alonshmiel/Ht6Ym/2409/ I'm attempting to align the ul element on the left side of the page: I've experimented with the following CSS rules: margin-left:0px; float: left; Unfortunatel ...

What is the best way to assign a unique color to two overlapping cells in an HTML table using HTML and jQuery?

I have a task to highlight a row or column when a checkbox is selected, similar to the example shown in the image below. How can I adjust the code so that the overlapping cell gets a different color instead of green or yellow? For instance, in the image b ...

When I'm working on iPhone css hover effects, I find that I need to include a

Why do I have to add a touch event to my element in order for it to trigger hover styles? Is this typical behavior? It seems a bit unconventional. This is the code I need to include to make :hover work; without it, no hover style is applied. Apologies f ...

Are Windows Gadgets the Next Big Testing Ground?

Are there any tools or resources that offer a console, error logging, etc. for testing Windows Gadgets? I've looked around but haven't had any luck finding something like this. Appreciate any help you can provide! ...

Images and CSS are functioning properly when viewed locally, but are not displaying as expected on GitHub pages

There seems to be some issues with transferring my website from a custom domain on Hover. When I try to import it to anthematics.github.io, only the HTML loads while images and CSS are missing. <link rel="stylesheet" href="theme.css" type="text/css"> ...

Distinguishing appearances among various web browsers

How come the menus look different in Firefox compared to Chrome, Safari, and IE? I've tried adjusting the CSS but can't seem to get it just right. Any suggestions on how to fix this? In Firefox, there's an overlapping part at the bottom of ...

Examining website design on an IOS device from a Windows computer

Is there a way for me to test HTML files from Windows on iOS8 (Local Files)? I have tried Adobe Edge Inspect, but it only works with servers. Are there any free cloud hosts that allow for HTML, CSS, and JS files? Edit: I apologize if my question was not c ...

Issue with Bootstrap columns being misaligned on mobile devices

On my website, I've implemented a Bootstrap Grid design with three columns under the container-fluid BS attribute, along with .row .no-gutters. While the boxes are perfectly aligned in the desktop view, they stack vertically on mobile and tablet devi ...

CSS animations - transitioning opacity in and out

Looking to add some CSS animations to a menu but running into some issues. I've got the code below for the menu to fade in on hover, but can't quite figure out how to make it fade out smoothly as well. I've tried a few approaches, but all I ...

Problem with adjusting the height of divs in CSS and HTML

Welcome to my JSFiddle project: https://jsfiddle.net/mkdjetkq/1/ I am currently working on developing a website that showcases a stunning region as part of a personal challenge. I have put in a lot of effort trying to consolidate everything I've acc ...

Rotate the text 180 degrees on hover using either jquery or css

One of our clients is requesting a flip effect on the menu items of their website. When hovered over, the items should flip upside down on the horizontal axis and then return to their original position. An example similar to what they're looking for c ...

The issue with the page not appearing correctly on IE9 is currently being resolved

I am utilizing bootstrap alongside a bootswatch theme and HTML5 boilerplate to design a webpage. While it appears correctly on Chrome and Firefox, the display is off on IE9 and IE8 mode. However, everything works fine when compatibility mode is enabled in ...

Unexpected behavior from Internet Explorer - Span contents remain unchanged despite valid input

I have a simple question because I'm feeling a bit lost. Check out this JSFiddle link It seems that in Internet Explorer, the contents of my span won't update even though the input is valid. However, in other browsers, the span content changes ...

Fixing the problem of horizontal labels in Bootstrap - a step-by-step guide

I am struggling to display the form label on a single line, as it currently appears on two lines. Any suggestions for showing the form label in a single line? https://i.sstatic.net/cXddd.png <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm ...

Exploring the world of real-time search functionality using jQuery for instant suggestions

I have a live search feature with jQuery on my website. The search works fine and displays results, but when I click on a result, I want the value to be shown in my input field. Additionally, once I click outside of the input field, the result should hide ...

Why do child elements of a collapsing parent div not collapse with it in CSS transitions?

Just diving into the world of css transitions and experimenting with collapsing a fixed popover div using CSS transition. I managed to collapse the outer div successfully, but the elements inside it did not collapse along. Is this the expected behavior? ...

The ReactBootstrap flexbox feature does not automatically adjust its height to match the content within

My struggle is with getting the height of this flexbox column to match that of its content. When the window width is less than 576 pixels, only one column is displayed per row. However, in this scenario, one of the columns (the teal one) ends up being too ...

Angular Delight: Jaw-Dropping Animation

After setting up my first Angular project, I wanted to incorporate Angular Animations to bring life to my content as the user scrolls through the page. I aimed to not only have the content appear on scroll but also implement a staggering animation effect. ...

What is the best way to align multiple form elements both horizontally and vertically within a frame?

Issue I have checked out various resources, like this one and this one, but I am still struggling to center my form elements both vertically and horizontally on the screen. I have tried using flex, padding, and stretching but nothing seems to work. Even a ...