Ensure that FlexBox Columns have a height of 100% and vertically align their content

Having scoured through numerous questions and answers, I'm still stuck on why I can't achieve 100% height for certain flexbox columns. Specifically, trying to make the "Genre" column with one line of text match the height of the "Song & The Artist" column with two lines, all while centering the text vertically:

https://i.sstatic.net/2L0XY.png

Codepen Link: https://codepen.io/bluedogranch/pen/ZEYXGmx

HTML Markup:

<div class="Rtable Rtable--4cols Rtable--collapse">

<div class="Rtable-cell genre-cell">Genre</div>
<div class="Rtable-cell song-cell">Song<br /><span class="artist">The Artist</span></div>
<div class="Rtable-cell flag-cell">Length</div>
<div class="Rtable-cell link-cell"><a href="#">Link</a></div>

<div class="Rtable-cell genre-cell">Genre</div>
<div class="Rtable-cell song-cell">Song<br /><span class="artist">The Artist</span></div>
<div class="Rtable-cell flag-cell">Length</div>
<div class="Rtable-cell link-cell"><a href="#">Link</a></div>

</div>

CSS Styling:

html, body {
     min-height: 100%;
     margin: 0 auto;
}    

.Rtable {
         display: flex;
         height: 100%;
         flex-wrap: wrap;
         justify-content: center;
         align-items: center;
         margin: 0;
         padding: 0;
    }
     .Rtable-cell, .genre-cell, .song-cell, .flag-cell, .link-cell {
         box-sizing: border-box;
         flex-grow: 0;
         width: 100%;
         height: 100%;
         padding: 0.5em 0em 0.5em 0em;
         overflow: hidden;
         list-style: none;
         color: #000;
         font-size: 12px;
         text-align: center;
    }

     .genre-cell {
         width: 20% !important;
         font-weight: bold;
    }
     .song-cell {
         width: 40% !important;
    }
     .flag-cell {
         width: 30% !important;
    }
     .link-cell {
         width: 10% !important;
    }

     .Rtable--4cols > .Rtable-cell {
         width: 25%;
    }

     .Rtable {
         position: relative;
         top: 1px;
         left: 1px;
    }
     .Rtable-cell {
         margin: -1px 0 0 -1px;
         border: solid 1px #000000;
    }

Answer №1

html, body {
     min-height: 100%;
     margin: 0 auto;
}    

.Rtable {
     display: flex;
     height: 100%;
     flex-wrap: wrap;
     justify-content: center;
     align-items: stretch;
     margin: 0;
     padding: 0;
}
 .Rtable-cell, .genre-cell, .song-cell, .flag-cell, .link-cell {
     display: flex;
     box-sizing: border-box;
     justify-content: center;
     align-items: center;
     width: 100%;
     padding: 0.5em 0em 0.5em 0em;
     overflow: hidden;
     list-style: none;
     color: #000;
     font-size: 12px;
     text-align: center;
}

 .genre-cell {
     width: 20% !important;
     font-weight: bold;
}
 .song-cell {
     width: 40% !important;
}
 .flag-cell {
     width: 30% !important;
}
 .link-cell {
     width: 10% !important;
}

 .Rtable--4cols > .Rtable-cell {
     width: 25%;
}

 .Rtable {
     position: relative;
     top: 1px;
     left: 1px;
}
 .Rtable-cell {
     margin: -1px 0 0 -1px;
     border: solid 1px #000000;
}
<div class="Rtable Rtable--4cols Rtable--collapse">

<div class="Rtable-cell genre-cell">Genre</div>
<div class="Rtable-cell song-cell"><div>Song<br /><span class="artist">The Artist</span></div></div>
<div class="Rtable-cell flag-cell">Length</div>
<div class="Rtable-cell link-cell"><a href="#">Link</a></div>

<div class="Rtable-cell genre-cell">Genre</div>
<div class="Rtable-cell song-cell"><div>Song<br /><span class="artist">The Artist</span></div></div>
<div class="Rtable-cell flag-cell">Length</div>
<div class="Rtable-cell link-cell"><a href="#">Link</a></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

Discovering the meeting point where two dives converge

Is there a method to change the color of the overlapped common part of two animated circles? ...

Prevent the bootstrap header in a table from scrolling by enclosing it in

I am encountering an issue with fixing the headers of multiple tables in a page within their dedicated divs. Despite trying various methods, I haven't been successful as the fixed header overflows the div. I want to confine it within the div. Additio ...

How can I disable the background color in Chrome autocomplete? Is there a way to make the background

There's a form on my website where the autocomplete feature shows a blue background color. The form itself has a semi-transparent white background. I managed to change the autofill color to white using this CSS property: -webkit-box-shadow: 0 ...

Update the class name of an element depending on the URL

Hey there! I'm working on customizing the style of some elements (specifically tds within a table) based on the current URL. Here are the pages I'm targeting: http:\\domain\site\welcome.html http:\\domain\site& ...

I'm not sure if I'm doing this right, the image seems to be overlapping the border

Just dipping my toes into the world of HTML/CSS, so feel free to point out any major errors in my code. The issue I'm facing is illustrated in this image (Apologies for the black boxes covering up some content; focus is on the top image). Check out ...

Chic and perfectly aligned stripe button design

I need assistance with centering and styling the Stripe checkout button labeled "update card." Additionally, I want to adjust the appearance of the card number input field to be normal but readonly. How can I achieve this without relying on Bootstrap' ...

Adjust the color of the button upon hovering with CSS

I'm having trouble changing the text color from white to black when hovering over the button. The code seems fine, but the text color isn't changing. Can anyone help me figure out how to make it work? .main__btn { font-size: 1.2rem; back ...

Modify the location of the input using jQuery

Hey there, I've got this snippet of HTML code: <div class='moves'> <div class='element'><input type='text' value='55' /></div> <input class='top' type='text&apo ...

What is the best way to eliminate the gap between header, content, and footer sections when in mobile view?

This issue seems to only occur in mobile mode, where the blueviolet line is coming from the background color. https://i.stack.imgur.com/VBhIp.png link to the image body { background-color: blueviolet; } header, main, footer { background-color: #ff ...

The hover effect in CSS brings life to list items when filled with content

I am attempting to create an animation for an <li> element that gives the illusion of a fill effect moving from left to right when hovered over. This is my current progress: ul { list-style-type: none; } .hoverTest { float: left; margin-right: 1 ...

What happens if I define both the left and right properties for spans?

This is a class for span with the CSS properties position:absolute; top:0px; left:0px; right:0px; .textStyle1 { font-size:24px; font-family:'Arial'; position:absolute; top:0px; left:0px; right:0px; } #div1 { position:absolute; lef ...

Compiling a list of products, but the user interface needs some adjustments

Currently, I have designed a product list menu that includes a hover dropdown feature. This means that when a user hovers over a specific menu item, the corresponding list will automatically appear. However, I am facing two issues with this setup. Firstly, ...

Differences in background-size among various browsers

Having some trouble with scaling backgrounds on different browsers. Initially designed website on Google Chrome, but background doesn't scale properly when viewed on iPhone or older versions of IE. Started with: background-size: 100% 150%; Then c ...

Toggle button in VueJS that dynamically shows/hides based on the state of other buttons

In my table, I have included options for the days of the week such as Everyday, Weekdays, and Weekend. Each row contains 2 select items to choose start and end times for updates. Additionally, there is a toggle button at the end of each row that enables or ...

Having trouble adjusting the width and height of images to a full 100% scale

I'm currently working on an Angular and Bootstrap application where I am trying to integrate a Bootstrap carousel. However, I've encountered some resizing issues with the width and height of the images/graphs. You can view a demo of the issue he ...

Tips for making a div expand to take up the available space on the left side of a taller div

Could you take a look at the scenario below? I'm attempting to position my yellow div beneath the red div and on the left side of the lower part of the green div. When I apply clear: left, it moves down but leaves empty space above it. Is there a way ...

Can you explain the process of NuxtJS css extraction for creating static websites?

I am currently working on creating a static website using my minimal code with Nuxt. This code includes integration of the tailwindcss toolkit and vue2-leaflet. When I run nuxt generate I end up with two CSS files - one for the tailwindcss styles and an ...

Designing a toggle button interface with Material UI

Looking to add a toggle button to my page. Here is an image of what I have in mind: https://i.sstatic.net/tiQAP.png Unable to find any material-ui component or API for this specific toggle button design. Considering building a custom toggle button with CS ...

Techniques for preventing background layering using CSS

I have implemented a background image on the <input type="submit"> element to give it the appearance of a button. My CSS code looks like this: input.button { background-image:url(/path/to/image.png); } Furthermore, I would like to display a dif ...

Using Google Fonts in a Typescript React application with JSS: A step-by-step guide

How can I add Google fonts to my JSS for use in styling? const styles = ({palette, typography}: Theme) => createStyles({ time: { flexBasis: '10%', flexShrink: 0, fontSize: typography.pxToRem(20) }, guestname: ...