Skip to content Skip to sidebar Skip to footer

HTML5 CSS : Rows And Resizing

This code below is responsive and resizes etc. But I'm looking for some real simple CSS to resize when on desktop and mobile. I get that I can muck with the CSS from the header lin

Solution 1:

You can use media query. Then you can handle the style for every pixel

@media only screen and (min-width: 320px) and (max-width: 575px) {
//Use  your styling here
}
@media only screen and (min-width: 576px) and (max-width: 767px) {
//Use  your styling here
}

Solution 2:

You can use media queries for that. Give each one of them around 33% width on desktop and around 100% width on mobile.

@media only screen and (min-width:320px) and (max-width: 600px) {
    .w3-third {
        width: 100%
    }
}

@media only screen and (min-width:600px) {
    .w3-third {
        float: left;
        width: 33.33%;
    }
}

That way, you can adjust the sizing of the columns easily using different media queries.

Btw, make sure to include clearfix on the parent (.w3-row in this case).

Edit: centering involves a little bit of math. i've created a fiddle for you with some explaination.

https://jsfiddle.net/zmvphaj0/4/

The way width is calculated is that you first count the number of times the empty space (or gutter) occurs (2 in our case), so if you were to take the full available width and subtract 2 times gutter, you'll have the remaining space that the columns should cover. So you divide the remaining space by 3 (note that the parentheses in that formula make it work). Now you give a margin-left to all but the first (or margin-right to all but last) column.

Same logic works for all other column widths in a 12 column grid layout.

Edit 2: Updated fiddle link with media queries.

Thx Rav... Working Fiddle: jsfiddle.net/w648ng81/36


Post a Comment for "HTML5 CSS : Rows And Resizing"