Need help creating a table. Div - html

Forget how to code a div style table.
I haven't coded html in years and am pretty rusty. I'm trying to create a responsive div style table with the first div spans the entire column with 2 more divs next to it. A div with 2 cells on top and a div that spans the 2 cells on bottom.
I'm trying to create something that looks like this image.
<div class="table">
<div class="row">
<div class="cell">cell 1</div>
</div>
<div class="row">
<div class="cell">cell 1</div>
<div class="cell">cell 2</div>
</div>
<div class="row">
<div class="cell colspan">
<div><div>
cell 3
</div></div>
</div>
<div class="cell"></div>
</div>

Use flexbox. By assigning display: flex; to the .table, .row, and .column elements, child elements of each all become flexible and can easily be controlled to take up certain percentages of space within the table, and grow to fill all the available space like a table would.
The flex property takes a little getting used to. Here I used it to tell flex items to grow (the first value, flex-grow), and starting widths (the third value, flex-basis). This resource makes it pretty easy to understand: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
* { box-sizing: border-box; }
.table,
.row,
.column {
display: flex;
}
.column {
flex: 1 0 50%;
flex-direction: column;
}
.first-column {
flex-basis: 33%;
}
.cell {
flex: 1 0 100%;
padding: 20px;
border: 1px solid dodgerblue;
}
.first-row .cell {
border-left: none;
}
.second-row .cell {
border-top: none;
border-left: none;
}
<div class="table">
<div class="column first-column">
<!-- just the one cell in this column -->
<div class="cell">cell 1</div>
</div>
<div class="column">
<!-- need 2 rows here -->
<div class="row first-row">
<!-- first row will have 2 columns -->
<div class="column">
<div class="cell">cell 2</div>
</div>
<div class="column">
<div class="cell">cell 3</div>
</div>
</div>
<div class="row second-row">
<div class="cell">cell 4</div>
</div>
</div>
</div>

Related

HTML FLEXBOX(Make a evenly perfect square)

How to make the box size to be evenly as perfect square and make the words inside of it to shrink. I want to make it square and the inside word to shrink to small size based on the square, but they just flexing because of the contents.
This is my code, what should I change/remove/add?
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.mainbox {
background: grey;
display: flex;
margin: 5px;
}
.mainbox div {
flex: 1;
border: 2px solid black;
}
#row {
display: flex;
flex-direction: row;
}
#column {
display: flex;
}
<!DOCTYPE html>
<html>
<head>
<title>FlexSpiral</title>
</head>
<body>
<div class="mainbox">
<div>box 1</div>
<div>
box 2
<div id="row">
<div id="column">
<div id="row">
<div>box 5</div>
<div>
<div>box 6</div>
<div id="row">
<div>
<div id="row">
<div>box 9</div>
<div>box 10</div>
</div>
<div>box 8</div>
</div>
<div>box 7</div>
</div>
</div>
</div>
<div>box 4</div>
</div>
<div>box 3</div>
</div>
</div>
</div>
</body>
</html>
I didn't quite understand the question, but here goes
You can take the margin from the ".mainbox" that it is giving margin on all sides of the mainbox class.
To leave the div box occupying its own content you can use in the styling: display:inline-block
Note: a good practice is to use class instead of id to identify the styling, and id more for future interaction when using script and interactions.

CSS Flexbox - How do I create a flexbox of items inside a <p> tag that wraps on overflow but starts the new row after the initial text in the <p> tag

I am trying to create a flexbox, that wraps on overflow, and when it moves to a new row due to horizontal overflow, I would want it to start the new row aligned with the start of the first row's items. The flexbox would be within a tag, and there would be some text before the flexbox is created, but I would want the start of the next row of the flexbox to be after the text. I will show a simple drawing of how it should look like.
text...... *flexbox starts* *end of row*
*next row starts if horizontal overflow*
I am new to CSS and flexbox, do guide me along if I am missing anything! Thanks all!
Try using flex-wrap on the container of the wrappable items. Also make sure the text isn't in the flexbox. Here's an example:
<div class="outer-container">
<div>Here's some text...</div>
<div class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</div>
.item {
width: 200px;
height: 200px;
background-color: pink;
margin: 5px;
}
.container {
display: flex;
flex-wrap:wrap;
width:800px;
}
.outer-container {
display: flex;
}
Codepen: https://codepen.io/annaazzam/pen/LYGeQag
You can use two different div for your text and your flex-items.
.wrapper {
display:flex;
flex-direction:row;
}
.container {
display:flex;
flex-wrap : wrap;
width:600px
}
.container .box {
width: 10rem;
height: 10rem;
background-color: yellow;
margin: 3px;
}
<div class="wrapper">
<div>
<p>Some text...</p>
</div>
<div class="container">
<div class="box box1"></div>
<div class="box box2"></div>
<div class="box box3"></div>
<div class="box box4"></div>
<div class="box box5"></div>
<div class="box box6"></div>
</div>
</div>

Make flexbox item width equal to combined width of brother elements

I have a row of fixed width flex items, and a footer element that should span the width of the combined elements above. How can I go about doing this?
Here is what I have so far, however, the bottom row is wider than the width of the first row.
<div class="container">
<div class="container" style="flex-basis: 100%">
<div style="width: 50px;">Div 1</div>
<div style="width: 50px;">Div 2</div>
<div style="width: 50px;">Div 3</div>
</div>
<div style="width: 100%">Div 4</div>
</div>
.container {
display : inline-flex;
flex-flow: row wrap;
}
.container > div {
border: 1px solid black;
background: #ececec;
}
https://jsfiddle.net/y1kham4u/1/
you better reset flex-direction than flex-wrap:
.container {
display: inline-flex;
flex-flow: column;/* no wrapping needed */
}
.container .container {
flex-direction: row;/* reset */
}
.container>div {
border: 1px solid black;
background: #ececec;
}
* {
box-sizing: border-box;
}
<div class="container">
<div class="container" style="flex-basis: 100% /* not really needed , but does not hurt */">
<div style="width: 50px;">Div 1</div>
<div style="width: 50px;">Div 2</div>
<div style="width: 50px;">Div 3</div>
</div>
<div style="width: 100%">Div 4</div>
</div>
https://jsfiddle.net/qm9o27ed/ (with also an inline-grid)
OKay first of all
https://flexboxfroggy.com/
play this game this game will help you to learn flex-box its pretty funnier way to learn flex-box properties
and for your problem and Use following jsfiddle
https://jsfiddle.net/dupinderdhiman/4d58c2nh/2/
.container {
display: inline-flex;
flex-flow: column;
border: 1px solid black;
background: #ececec;
}
.innerContainer{
display: flex;
flex-grow: 1;
}
.innerContainer > div {
border: 1px solid black;
background: #ececec;
}
<div class="container">
<div class="innerContainer" style="">
<div style="width: 50px;">Div 1</div>
<div style="width: 50px;">Div 2</div>
<div style="width: 50px;">Div 3</div>
</div>
<div style="width: 100%">Div 4</div>
</div>
https://jarodpeachey.github.io/breeze_css/layout.css
If you use this framework, you can easily create rows. The col-4 means it's 4 out of 12 grid spaces. If we set the width of the row to 150, each div will take up 50 pixels. (*Note: I would recommend using the framework to understand how it works, and then copy the code onto your local machine, as this framework is for my personal use, and the code may change)
<div class="container">
<div class="row m-auto" style="width: 150px">
<div class="col col-4">Div 1</div>
<div class="col col-4">Div 2</div>
<div class="col col-4">Div 3</div>
<div class="col col-12">Div 4</div>
</div>
</div>
Hope this helps!!

"Flexible" Responsive table using divs. Where a full column stretches if able

Well Consider I have a table with 3 columns. "Normally" each column should take 1/3rd of the page. However if one of the column's data gets too large, and the other columns have extra space it should "flex", and the column should occupy the remaining space.
However it should still be a "table": as in column & row borders need to align.
When using naive flex boxes I tried both a row and column first approach. However both have the problem that the "inner" flexbox might stretch, but that information is lost on the other flex boxes.
I've tried to solve it below using both methods: but as you can see it's not working:
.bordered{
border-width: 1px;
border-color: black;
border-style: solid;
}
.main {
display: block;
position: relative;
}
.row {
display: flex;
position: relative;
width: 100%;
}
.cell {
flex: 1 1 auto;
max-width: 75%;
}
<div class="main bordered">
<div class="row">
<div class="cell bordered">
first
</div>
<div class="cell bordered">
second
</div>
<div class="cell bordered">
third
</div>
</div>
<div class="row">
<div class="cell bordered">
first
</div>
<div class="cell bordered">
This is text that will increase the width of the cell.
</div>
<div class="cell bordered">
third
</div>
</div>
<div class="row">
<div class="cell bordered">
first
</div>
<div class="cell bordered">
This is text that will increase the width of the cell. Not only that, but due to the amount of text it also increases the height of a row. This isn't a problem with this setup. But had we chosen to use a column-first approach this cell would destroy any "row" layout.
</div>
<div class="cell bordered">
third
</div>
</div>
</div>
Can this be done? Or should I give up on this?
Flexbox is probably not the best-suited solution for this. I would recommend looking to use CSS Grid Layout. There are many ways to accomplish this, but here's a start.
Use a 3 column, 3 row grid, with auto width cells (using an optional min-width to preserve some space).
.main {
display: grid;
position: relative;
grid-template-columns: auto auto auto;
grid-template-rows: auto auto auto;
}
.bordered {
border-width: 1px;
border-color: black;
border-style: solid;
}
.cell {
grid-column-end: span 1;
}
.cell:nth-child(3n+1) {
grid-column-start: 1;
min-width: 50px;
}
.cell:nth-child(3n+2) {
grid-column-start: 2;
}
.cell:nth-child(3n+3) {
grid-column-start: 3;
min-width: 100px;
}
<div class="main bordered">
<div class="cell bordered">
first
</div>
<div class="cell bordered">
second
</div>
<div class="cell bordered">
third
</div>
<div class="cell bordered">
first
</div>
<div class="cell bordered">
This is text that will increase the width of the cell.
</div>
<div class="cell bordered">
third
</div>
<div class="cell bordered">
first
</div>
<div class="cell bordered">
This is text that will increase the width of the cell. Not only that, but due to the amount of text it also increases the height of a row. This isn't a problem with this setup. But had we chosen to use a column-first approach this cell would destroy any
"row" layout.
</div>
<div class="cell bordered">
third
</div>
</div>
</div>

Align content of boxes vertically in responsive grid (set same height for all boxes)

I am using a responsive grid and I want each box to have all its contents vertically aligned. Each box will have a different position of the content (structure). In this case (for now), I have two boxes and they work fine separately. When I include them in the grid, the grid is no longer responsive.
For example, the first box will look like this:
and the second box will look like this:
So, far... I have built the main grid and I am trying to align the items using the first box template. I am trying to find the best solution. I am guessing the change is related to the .example-feature-staggered-row:
h1,h2{letter-spacing:-.04em;text-align:center;line-height:1.2em}h1,h2,h3{text-align:center}h1,h2,h4{line-height:1.2em}h3,h4{margin-bottom:12px;letter-spacing:-.03em}h2,h5{margin-bottom:16px}h3,h5{line-height:1.3em;margin-top:0}h1,h2,h3,h4,h5,h6{font-family:'Circular Medium',sans-serif;font-weight:500}h6,p{margin-bottom:10px}h2,h3,h4,h5,h6{margin-top:0}h1{font-size:3.875em}h2{font-size:2.75em}h3{font-size:2em}h4{font-size:1.375em}h5{font-size:1.25em;letter-spacing:-.02em}h6{font-size:.875em;line-height:1.4em}.grid{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin-right:-16px;margin-left:-16px;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-align-content:flex-start;-ms-flex-line-pack:start;align-content:flex-start}.grid.gutter--small{margin-right:-8px;margin-left:-8px}.grid.no-gutter{margin-right:0;margin-left:0}.grid.justify--center{-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center}.example-body,.example-center{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;-webkit-flex-direction:column;-webkit-box-orient:vertical;-webkit-box-direction:normal}.example-body{display:flex;margin-bottom:64px;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-box-align:stretch;-webkit-align-items:stretch;-ms-flex-align:stretch;align-items:stretch;border-radius:6px;box-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 6px 12px 0 rgba(0,0,0,.1)}.example-body.orange{background-color:#F2987D;color:#fff}.example-body.green{background-color:#E9F0E0;color:#000}.example-body.lightblue{background-color:#00a7f7;color:#00a7f7}.example-center{display:flex;min-height:512px;padding:48px;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;color:#fff}.example-features-figure,.example-header{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox}.example-header{display:flex;margin-bottom:102px;padding-right:32px;padding-left:32px;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.example-features-figure{display:flex;width:60px;height:60px;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-box-flex:0;-webkit-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto;border-radius:999px;background-color:#a4d7a5}.example-feature-columns,.example-fluid{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox}.example-features-text{padding-left:16px;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.example-feature-title{margin-bottom:8px;text-align:left}.example-feature-subtitle,.example-logo{margin-bottom:0}.example-feature-title.reversed{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;text-align:right}.example-feature-title.centered{text-align:center}.example-feature-subtitle.reversed{text-align:right}.example-feature-subtitle.centered{text-align:center}.example-logo{margin-top:0;text-transform:uppercase}.example-wrapper{padding-right:32px;padding-bottom:32px;padding-left:32px;background-color:#eef1f3}.example-wrapper.cyan{background-color:#dff7fa}.example-wrapper.blue{background-color:#e2f2fe}.example-wrapper.orange{background-color:#fff3df}.example-wrapper.deeppurple{background-color:#ede7f6}.example-wrapper.purple{background-color:#f3e5f5}.example-wrapper.red{background-color:#ffebee}.example-wrapper.teal{background-color:#dff2f1}.example-wrapper.pink{background-color:#fde4ec}.example-wrapper.green{background-color:#e8f5e9}.example-wrapper.lightblue{background-color:#e0f5ff}.example-wrapper.amber{background-color:#fff8e0}.example-fluid{display:flex;min-height:600px;padding:16px;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.example-center-title{margin-bottom:0;text-align:center}.example-center-figure{margin-bottom:12px}.example-equal-height-caption{padding:16px;font-size:.875em;line-height:1.5em}.example-feature-columns{display:flex;padding:32px 16px;-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;-webkit-box-align:stretch;-webkit-align-items:stretch;-ms-flex-align:stretch;align-items:stretch}.example-feature-column,.example-feature-column-figure{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox}.example-feature-column{display:flex;padding-right:16px;padding-bottom:12px;padding-left:16px;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.example-feature-column.sibling{-webkit-box-flex:0;-webkit-flex:0px;-ms-flex:0px;flex:0px;border-left:1px solid #63bc66}.example-feature-column-figure{display:flex;width:100px;height:100px;margin-bottom:16px;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;border-radius:999px;background-color:#a4d7a5}.example-feature-staggered,.example-feature-staggered-row{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox}.example-feature-staggered{display:flex;padding:0 40px;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column}.example-feature-staggered-row{display:flex;padding-top:32px;padding-bottom:32px;-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;font-size:1.25em;line-height:1.4em}.example-feature-staggered-figure,.example-grid-container{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox}.example-feature-staggered-row.sibling{border-top:1px solid #63bc66}.example-feature-staggered-row.reverse{-webkit-box-orient:horizontal;-webkit-box-direction:reverse;-webkit-flex-direction:row-reverse;-ms-flex-direction:row-reverse;flex-direction:row-reverse}.example-feature-staggered-figure{display:flex;width:160px;height:160px;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-box-flex:0;-webkit-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto;border-radius:999px}.example-feature-staggered-text{padding-right:24px;padding-left:24px}.example-grid{padding:32px 32px 12px}.example-grid-container{display:flex;margin-right:-8px;margin-left:-8px;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap}.cover-wrapper{position:relative;z-index:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin-bottom:80px;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}#media (max-width:991px){.cover-wrapper,.section-header{margin-bottom:64px}.grid{margin-right:-12px;margin-left:-12px}.grid.tablet-vertical{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column}.example-center{min-height:480px}.example-header{padding-right:24px;padding-left:24px}.example-equal-height{min-height:400px;padding:48px 40px;font-size:14px;line-height:1.5em}.example-fluid,.example-hero{min-height:480px;line-height:1.5em}.example-equal-height-figure{height:140px}.example{padding-top:64px}.example-features-figure{width:48px;height:48px}.example-features-text{padding-left:12px}.example-wrapper{padding-right:24px;padding-bottom:0;padding-left:24px}.example-fluid{padding:12px;font-size:14px}.example-feature-columns{padding:24px 12px;font-size:14px;line-height:1.5em}.example-feature-column{padding-bottom:6px}.example-feature-column-figure{width:80px;height:80px}.example-feature-staggered{padding-right:24px;padding-left:24px;font-size:12px}.example-grid,.example-hero{font-size:14px}.example-feature-staggered-row{padding-top:24px;padding-bottom:24px}.example-feature-staggered-figure{width:120px;height:120px}.cover-item{-webkit-flex-basis:19%;-ms-flex-preferred-size:19%;flex-basis:19%}.example-hero{padding:12px}.example-hero-figure{width:128px;height:128px}}#media (max-width:767px){h3,h4,h5{margin-bottom:8px}body{font-size:14px;line-height:1.4em}h1{font-size:2.75em}h2{margin-bottom:12px;font-size:2em}h3{font-size:1.5em}.section-description,h4{font-size:1.25em}.section.padded{padding:48px 16px}.container.large.shifted,.container.medium.shifted{margin-top:-64px}.grid{margin-right:-8px;margin-left:-8px}.grid.mobilel-vertical{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.example-body{margin-bottom:32px}.example-center{min-height:320px;padding:22px}.example-header{margin-bottom:64px;padding-right:16px;padding-left:16px}.example-equal-height{min-height:0;padding:24px 16px;font-size:10px;line-height:1.4em}.example-equal-height-figure{height:120px}.cover-title{margin-bottom:16px}.cover-subtitle{margin-bottom:32px;font-size:1.25em}.section-header{margin-bottom:48px}.expander-body{margin-top:16px;margin-bottom:16px}.example-features-figure{width:32px;height:32px;padding:8px}.example-features-text{padding-left:8px}.example-feature-title{margin-bottom:4px}.example-wrapper{padding-right:16px;padding-left:16px}.example-fluid{min-height:320px;padding:8px;font-size:10px;line-height:1.4em}.example-center-figure{width:64px;height:64px}.example-equal-height-caption{padding:12px}.example-feature-columns{padding:16px 8px;font-size:11px}.example-feature-column-figure{width:64px;height:64px;margin-bottom:8px;padding:16px}.example-feature-staggered{padding-right:16px;padding-left:16px;font-size:10px}.example-feature-staggered-row{padding-top:16px;padding-bottom:16px}.example-feature-staggered-figure{width:96px;height:96px;padding:24px}.example-grid{padding:16px 16px 4px}.example-grid-container{margin-right:-6px;margin-left:-6px}.cover-item{-webkit-flex-basis:24%;-ms-flex-preferred-size:24%;flex-basis:24%}.logos-text{margin-bottom:12px;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center}.cover-logo{position:absolute;left:0;top:0;right:0;z-index:2000;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;width:120px;height:48px;margin-right:auto;margin-left:auto;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.cover-logo-image{opacity:.6}}#media (max-width:479px){h1{font-size:2em}h2{font-size:1.75em}.grid.mobile-vertical{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap}.cover{padding:1rem;-webkit-box-align:stretch;-webkit-align-items:stretch;-ms-flex-align:stretch;align-items:stretch}.example-body{margin-bottom:16px;border-radius:4px}.example-center{min-height:240px;padding:16px;font-size:12px}.example-header{padding-right:12px;padding-left:12px}.example-equal-height{padding:12px 8px;font-size:8px}.example-equal-height-card{margin-right:4px;margin-left:4px;border-radius:2px}.example-equal-height-figure{height:80px;padding-right:24px;padding-left:24px}.section-header{margin-bottom:48px}.example-features-text{padding-left:6px}.example-wrapper{padding-right:12px;padding-left:12px}.example-fluid{min-height:240px;padding:6px;font-size:6px}.example-equal-height-caption{padding:6px}.example-feature-columns{padding-top:12px;padding-bottom:12px;font-size:10px}.example-feature-column{padding-right:12px;padding-bottom:0;padding-left:12px}.example-feature-column-figure{width:48px;height:48px;padding:12px}.example-feature-staggered{padding-right:12px;padding-left:12px;font-size:8px}.example-feature-staggered-row{padding-top:12px;padding-bottom:12px}.example-feature-staggered-figure{width:64px;height:64px;padding:16px}.example-feature-staggered-text{padding-right:12px;padding-left:12px}.example-grid{font-size:12px}.example-grid-container{margin-right:-4px;margin-left:-4px}.cover-wrapper{margin-bottom:32px}}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="row">
<div class="col-xs-6 col-md-4">
<div class="example-body green">
<div class="example-feature-staggered">
<div class="example-feature-staggered-row">
<div class="example-feature-staggered-figure"><img src="https://cdn0.iconfinder.com/data/icons/simplicity/512/dollar-256.png" width="76"></div>
<div class="example-feature-staggered-text">
<p class="example-feature-title">111 111</p>
<h3 class="example-feature-subtitle">3.2M</h3>
</div>
<div class="example-feature-staggered-text">
<p class="example-feature-title">333</p>
<h3 class="example-feature-subtitle">-10%</h3>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="example-body green">
<div class="example-feature-staggered">
<div class="example-feature-staggered-row">
<div class="example-feature-staggered-text">
<h3 class="example-feature-subtitle">111</h3>
<h3 class="example-feature-subtitle">222</h3>
<h3 class="example-feature-subtitle">333</h3>
</div>
<div class="example-feature-staggered-text">
<h3 class="example-feature-subtitle"><b>AAA</b></h3>
<h3 class="example-feature-subtitle"><b>BBB</b></h3>
<h3 class="example-feature-subtitle"><b>BBB</b></h3>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="example-body orange">
<div class="example-feature-staggered">
<div class="example-feature-staggered-row">
<div class="example-feature-staggered-figure"><img src="https://cdn4.iconfinder.com/data/icons/dot/256/man_person_mens_room.png" width="96"></div>
<div class="example-feature-staggered-text">
<p class="example-feature-title">111 111</p>
<h3 class="example-feature-subtitle">105,306</h3>
</div>
<div class="example-feature-staggered-text">
<p class="example-feature-title">333333</p>
<h3 class="example-feature-subtitle">-44%</h3>
</div>
</div>
<div class="example-feature-staggered-row">
<div class="example-feature-staggered-figure"><img src="https://cdn4.iconfinder.com/data/icons/developer-set-3/128/arrowupright-256.png" width="76"></div>
<div class="example-feature-staggered-text">
<p class="example-feature-title">22222</p>
<h3 class="example-feature-subtitle">35.05%</h3>
</div>
<div class="example-feature-staggered-text">
<p class="example-feature-title">- </p>
<h3 class="example-feature-subtitle">+6%</h3>
</div>
</div>
</div>
</div>
</div>
</div>
I am trying to think of the best solution here. For example. the table might be a solution. Using two columns (for the first template). Each column will have two rows where the items (text and images) will be vertically aligned. The rows of the first column will have a sub-table. Each sub-table will have two columns. The first column will have the image. The second column will have two rows with the text. Is that a good idea? Or is it better to find a more responsive way to achieve that?
Separately, the boxes are fine. I just cannot make them work in the grid without problems (the height is not the same. If I make it the same, the content is not always vertically aligned).
With your current setup, you will need to add media queries at certain breakpoints to restyle the content.
You have giving a lot of elements fixed widths and set them to flex: 0 0 auto; which will stop them from shrinking below their given width.
Also, you could benefit from simplifying your code.
You can create this layout with flex containers. Below is a rough example of what this might look like.
.container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.wrap {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-pack: distribute;
justify-content: space-around;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
width: calc(50% - 40px);
background: #e9f0e1;
min-height: 100px;
min-width: 100px;
margin: 20px;
}
.one {
background: #f09880;
}
.three {
background: #e9f0e1;
}
.content {
padding: 10px;
margin: 10px;
background: seagreen;
color: white;
}
#media screen and (max-width: 500px) {
.wrap {
display: block;
}
}
#media screen and (max-width: 360px) {
.container {
display: block;
}
.wrap {
width: calc(100% - 40px);
}
}
<div class='container'>
<div class='wrap one'>
<div class='item'>
Icon
</div>
<div class='item'>
Text
</div>
<div class='item'>
Text
</div>
</div>
<div class='wrap two'>
<div class='item'>
<div class='content'>
one
</div>
<div class='content'>
two
</div>
</div>
<div class='item'>
<div class='content'>
one
</div>
<div class='content'>
two
</div>
</div>
<div class='item'>
<div class='content'>
one
</div>
<div class='content'>
two
</div>
<div class='content'>
three
</div>
</div>
</div>
<div class='wrap three'>
<div class='item'>
Icon
</div>
<div class='item'>
<div class='content'>
Text
</div>
<div class='content'>
Text
</div>
</div>
<div class='item'>
<div class='content'>
Text
</div>
<div class='content'>
Text
</div>
</div>
</div>
</div>