Guide to making a single row beneath two columns using CSS Grid

My goal is to utilize CSS Grid in order to design a blurb layout featuring 2 columns at the top and a full row below. This will allow for an FA Icon and Title, accompanied by a full description below, similar to the image provided.

I believe I have successfully set up the grid layout, however, I am uncertain of how to ensure that the width of the top 2 columns (icon and title) adjust together and automatically fit the content?

Would utilizing firebox make this task easier?

Thank you,

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

CodePen Link

HMTL

<div class="main_description_container">
<div class="description_gridwrapper">
    <div id="icon"><i class="fas fa-info-circle"><!--tr--></i></div>
    <div id="title"><h3>Title Text</h3></div>
    <div id="text">Long Paragraph Text</div>
</div>
</div>

CSS

.main_description_container{
display: block;
height: 100%;
width: 100%;
padding: 0px;
margin: 0px;
}

.description_gridwrapper {
display: grid; 
grid-template-rows: 1fr 1fr 1fr;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
gap: 0px;
height: 100%;
}
  
.description_gridwrapper #icon {
   background-color: #68dd99; 
   grid-row-start: 1;
   grid-column-start: 1;
   grid-row-end: 2;
   grid-column-end: 2;
}

.description_gridwrapper #icon i.fas{
color: #B1DDF1;
font-size: 36px !important;
max-width: 36px !important;
width: 36px !important;
}

.description_gridwrapper #title {
   background-color: #D75DDC; 
   grid-row-start: 1;
   grid-column-start: 2;
   grid-row-end: 2;
   grid-column-end: 3;
color: #31324E;
}

.description_gridwrapper #text {
   background-color: #9FDABB; 
   grid-row-start: 2;
   grid-column-start: 1;
   grid-row-end: 3;
   grid-column-end: 3;
}

Answer №1

To make the text-block span across both columns, use grid-column: span 2. Refer to comments in the CSS below:

/* Create a 2 column grid where the first column for the icon takes up required space and the 2nd column takes up remaining space */
.description_gridwrapper {
  display: grid;
  grid-template-columns: min-content auto;
}

/* Remove default margin of the title to align with the icon */
#title h3 {
  margin: 0;
}

/* Allow the text-block to span both columns */
#text {
  grid-column: span 2;
}
  
<div class="main_description_container">
<div class="description_gridwrapper">
    <div id="icon"><i class="fas fa-info-circle">ICON</i></div>
    <div id="title"><h3>Title Text</h3></div>
    <div id="text">Long Paragraph Text</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

Implementing the @media rule using Javascript

I'm trying to use JavaScript to add an image dynamically, but I want to remove it when the viewport is 600px or wider. This is my approach so far: var img = document.createElement('img'); // (imagine here all the other fields being defined ...

Tips for updating the appearance of material-ui table pagination

I'm looking to enhance the way table pagination is presented in material-ui. The current default display by material-ui looks like this: https://i.stack.imgur.com/d4k4l.png My goal is to modify it to look more like this: https://i.stack.imgur.com/A ...

Elements floating in space, stretching across the entire width

In my design, I have a fixed size layout with a centered content container. My goal is to have the menu (home, about, contact, login) span 100% of the screen width. You can view the current setup in this jsfiddle: http://jsfiddle.net/Hxhc5/1/ I am aimin ...

While reviewing my HTML code, I couldn't locate a particular line of code responsible for changing the display of my webpage. However, upon inspecting the element, I discovered that

<h2><a class="label label-info" target="_blank" href="http://www.avis.com.pk/"> Avis</h2> </a> <h4> <span class="label label-primary"> Rent A Car Service</span></h4> There is an Inspect Element image attach ...

Vanishing Span in CSS3 Flexboxes

I came across this particular HTML code: <div class="panel panel-info"> <div class="panel-heading">Person</div> <div class="panel-body"> <div class="data"> <p class="keys"> ...

An error has occurred in the Shadow Dom due to the inability to access the property 'style' of an

While working on a component using shadow DOM, I encountered the following error in the console: "Cannot read property 'style' of undefined". This issue seems to be related to my HTML code in PHP. The main challenge I am facing is figuring out ho ...

Positioning elements in CSS using percentages allows for flexible and responsive

I am new to web design and I am trying to create a webpage similar to the one shown in this image. However, I want to set the height and width of the divs using percentage values instead of pixels. Whenever I attempt this, the boxes end up overlapping or ...

Do frameworks typically result in redundant CSS declarations?

Working on my latest Wordpress theme project, I have integrated the Bootstrap framework. One of the styles included in the Bootstrap CSS file is: input, textarea, .uneditable-input { width: 206px; } This style rule is causing issues with how my search ...

Change the default direction of content scrolling in CSS and JavaScript to scroll upwards instead of

I am currently working on a website where the navigation bar spans the entire width and remains fixed in place. Below the navigation bar is a cover image, followed by the main content section. As you scroll down, the navigation bar covers the image from t ...

I'm having trouble figuring out the issue with the HTML code I wrote to include a favicon on my website

Take a look at this code: <link rel = "shortcut icon" type = "image/x-icon" href = "C:/Users/SOMEBODY/Desktop/SOME FOLDER/ANOTHER FOLDER/favicon.ico"/> Even though I have the favicon in the same folder as my website, ...

"When trying to access a jQuery ID, it is coming back as undefined even though the

I'm attempting to obtain the ID of a specific element, save it as a variable, and then utilize that ID value to interact with other elements in the same section bearing the identical ID. <div class="mainContent"> <div class="articleContent"& ...

Creating a visible block in ReactJS: Step-by-step guide

Hello and thank you for all the hard work you do on this platform. I am relatively new to working with ReactJS and have been encountering some difficulties trying to integrate it with sandbox environments like JSFiddle. I have a div element named "app-con ...

jQuery now enables the number field to accept not only one period but multiple periods

I need to update a number field in a form to accept multiple periods, specifically for entering software version numbers. Currently, the code I am using only allows for one period to be entered, resulting in an error when two periods are added to the fie ...

When the height of the window decreases, scrolling is not implemented

Having trouble adjusting the height of my Responsive Modal when the window height decreases. The content is slipping under the window and the scroll bar isn't adjusting accordingly. It seems like the nested div structure is causing issues. https://i.s ...

Viewing content below a clear, fixed element

Check out the image regarding the issue I'm currently working on a page that features a fixed header with a transparent background. My goal is to make the content below this fixed header disappear when scrolled under it, similar to how it would behav ...

Tips for displaying Ajax response in a modal popup

I have a link that, when clicked, sends an AJAX request and successfully receives a response in the form of an HTML file, which I then append to a div. However, I want to display this div as a modal popup and I have attempted the following: In the HTML fi ...

What causes HTML validator errors in all head meta-tags?

After running my HTML through a validator, I was shocked to discover around 80 errors even though the site appeared to be functioning properly. Here is an excerpt of the code: <!DOCTYPE html> <html lang="da-DK"> <head> <meta charset=" ...

Why does the Select2 Drop down eliminate the mandatory border color?

Within my application, I have implemented a feature where required fields are designated with a red border. To achieve this effect, I utilized the following CSS code: input[data-val-required], select[data-val-required] { border: 1px solid #EFA4A4 !imp ...

How can you make an object float above an image using CSS?

Is CSS capable of positioning an object over an image? I am trying to overlay a form on top of an image that is not a background. Floating the form doesn't achieve the desired effect, so I'm wondering if there is another way to accomplish this. ...

Can you provide guidance on how to use Javascript to submit a form specifically when the input name is labeled as "submit"?

Query: How can I use Javascript to submit a form when one of the form inputs is named submit? Scenario: I need to send users to another page using a hidden HTML form. Unfortunately, I cannot modify the names of the inputs in this form because it needs to ...