Is it possible to have two grids within a grid at varying heights?

Seeking assistance with adjusting the height of the red div in relation to the green box. Here is the current setup:

  • What I have now:
  • What I need here is to have the red div height lower, just after HELLO 2 of the green box, like this:

<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet"/>

<div class="grid grid-cols-4 gap-6">
      <div class="grid gap-4 bg-red-500">
        <span>HELLO 1</span>
        <span>HELLO 2</span>
      </div>

      <div class="grid gap-4 col-span-3 bg-green-500">
        <span>HELLO 1</span>
        <span>HELLO 2</span>
        <span>HELLO 3</span>
        <span>HELLO 4</span>
        <span>HELLO 5</span>
        <span>HELLO 6</span>
      </div>
</div>

Answer №1

To achieve the desired layout, consider utilizing the auto-rows-min property and enclose both instances of HELLO within a div.

Check out this example.

Answer №2

My interpretation is that the left column should remain unaffected by the height of the right column, am I correct? If that's the case, then I would have approached it in this manner.

<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css' media='all' />

<div class="bg-gray-400 min-h-screen flex items-center justify-center ">

  <div class="grid grid-cols-2 gap-2 w-1/2">    
    
    <div class="row-span-2  rounded ">
      <div class="bg-white p-10 rounded bg-green-100 mb-2">Block A</div>
      <div class="bg-white p-10 rounded bg-green-100 ">Block B</div>
    </div>    
    <div class="row-span-2 bg-white p-10 rounded">lorem lorem lroem lorem lorem lroem lorem lorem lroemlorem lorem lroemlorem lorem lroem lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem  lorem lorem lroem 
    lorem lorem lroem lorem lorem lroem lorem lorem lroem  
    </div>
  </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

When transitioning from HTML to PHP include, the CSS 'active' class does not function properly

I have noticed a similar question was asked, but the approach taken by the other user differs from mine. My goal is to implement an HTML navigation on my PHP pages for easier future modifications. I want buttons to be highlighted when hovered over and have ...

unusual occurrences with CSS and JavaScript when hovering over TEXTAREA or A elements

Lately, I've been facing an unusual issue in my web application (php) that was fine just a month ago. Upon hovering over a specific < TEXTAREA > or two buttons (add, exit) within a DIV, the background color of the DIV fills up, rendering the IN ...

Jimdo: Generate a spinning sliced circle with the click of a button

I'm attempting to achieve a spinning CD/Disk effect when the play button is clicked. I have a sample code below that represents the player's state during playback. What I envision is an image with a play button on top. Upon clicking the button, ...

Error: TweenLite has not been recognized

/justincavery/pen/mPJadb - this is a link to CodePen After copying the code from CodePen and running it, I encountered an error: "Uncaught ReferenceError: TweenLite is not defined". The image only draws once and there is no animation unless I press "F5 ...

Styling elements with CSS can sometimes lead to unexpected behavior in Safari on iOS devices, especially

Ever since the release of iOS 14, I've noticed that content within a div element with an 'overflow-y: scroll' property no longer functions properly on Safari. Does anyone happen to have a solution for this? (Or maybe my code just needs some ...

The arrangement of columns is not correctly aligned

My website layout is giving me trouble. I want to create a three column design, but unfortunately, it's not aligning properly. Each subsequent column is being pushed down slightly more than the previous one. Is there any way to fix this issue? Interes ...

Having trouble positioning the right side image on the Bootstrap 4 Landing page

Struggling to incorporate bootstrap 4 into my sample project for the right side background. I'm facing some conflicts and attempts to align it on the right side are not successful. Does anyone know how to do this correctly? Thank you // Navbar scr ...

How to align a div with embedded tweets in the center

I am looking to include a series of tweets from Twitter in a div on a basic webpage. The challenge is centering this div horizontally on the page. I have tried using: <div style="text-align:center"> and also: <div style="width: 900px; display ...

Having Trouble Positioning Button at Bottom of Browser with Absolute Positioning in HTML and CSS

I am encountering an issue with positioning an element (<button id="foo">FAQ</button>). The CSS code I have for the button is: #foo { position: absolute; bottom: 0px;/* I have also tried using different units */ left: 0px;/* same t ...

Display the input field once the label is clicked

I am encountering an issue with the following code: .input { display: flex; flex-direction: column; border: 1px solid #000; height: 50px; justify-content: flex-end; } .input > * { padding: 5px; } #login { visibility: hidden; height: ...

The topbar on Foundation seems to be malfunctioning - where did I go wrong?

I am trying to implement the Topbar feature of Foundation for my website's navigation. However, all I see is a plain bulleted list with no formatting whatsoever. Currently, I have only included basic external dependencies like jQuery and Foundation in ...

Is using transform scale in CSS to scale SVG sprites a valid method of scaling?

I have been using an SVG sprite as a CSS background image in this manner: .icon-arrow-down-dims { background: url("../sprite/css-svg-sprite.svg") no-repeat; background-position: 16.666666666666668% 0; width: 32px; height: 32px; display: inline-b ...

What is the best way to control the visibility of content using CSS based on the screen size?

Similar to Bootstrap, Ionic (specifically Ionic 3) allows for resizing column widths based on screen size using classes like col-sm-8, col-md-6, col-lg-4. Bootstrap also includes classes such as visible-xs, hidden-sm, etc. for displaying or hiding conten ...

HTML - Table Layout Overlap

I'm struggling with a table layout issue in HTML and could use some assistance. The table below is displaying as overlapping in IE (please refer to the image), but it appears correctly in FF. Can anyone offer some guidance? <div> <table> ...

Use Jquery to swap out text without the need for a separate update button

Looking to replace "Gastos de envío: " with "Shipping costs" on the English page. I currently have this jQuery code (which is working), but it only replaces the text the first time you visit the page. If you update the shipping costs, the jquery does not ...

Having trouble with clearing floats in Twitter Bootstrap CSS - any help appreciated!

Today, in an effort to learn CSS and apply it practically by creating simple themes, I decided to delve into the proper ways of clearing floats in CSS. My research led me to explore how Twitter handles this issue, so I dug into Bootstrap's CSS file an ...

The shading of the box isn't displaying the correct color in Microsoft Edge and IE 11

I have a unique pattern consisting mainly of white and grey hues. To add a touch of color, I am using the box shadow property in CSS to apply a blue filter effect. This technique successfully displays the desired result in Firefox and Chrome browsers. Howe ...

How can I resize the border to match the size of the text inside it?

Check out the following image to see how it appears:https://i.sstatic.net/RkMqI.png Here is an example code snippet of a message: .allMsg { width: 100%; } .self { border-radius: 1rem; background-color: #28a745; text-align: right; padding-lef ...

What's causing my React app's slideshow to malfunction?

Struggling with styling my React app after importing w3.css and attempting to create a slideshow with 3 images in the same directory as the component being rendered. As someone new to React and web development, I'm facing challenges in getting the des ...

Fixed columns with horizontal scrolling to prevent Datatables columns from overlapping

I'm facing an issue with my data table created using datatables. I need to fix the first two columns, but when I do so, the other two columns overlap them while scrolling horizontally. If I remove the fixed columns, the scrolling works correctly witho ...