CSS 2 column layout with variable heights and different mobile/desktop layout - html

Is there a way to build a 2 column layout so that each item can be of dynamic height and has a different order on mobile as can be seen here?
I've been able to partially achieve this by wrapping the left and right elements in their own div however, there doesn't seem to be a way to re-order elements outside of their column div for the mobile view:
.parent {
display: grid;
grid-template: auto / 1fr;
}
.column-left {
align-self: start;
grid-row: 1;
}
.column-right {
align-self: start;
grid-row: 2;
}
#media screen and (min-width: 600px) {
.parent {
grid-template: auto / repeat(8, 1fr);
}
.column-left {
grid-column: 1 / 4;
grid-row: auto;
}
.column-right {
grid-column: 4 / 9;
grid-row: auto;
}
}
.item {
border: 1px solid black;
text-align: center;
font-size: 2rem;
}
#item-a {
height: 140px;
background-color: red;
}
#item-b {
height: 180px;
background-color: blue;
}
#item-c {
height: 220px;
background-color: green;
}
#item-d {
height: 300px;
background-color: yellow;
}
<div class="parent">
<div class="column-left">
<div id="item-a" class="item">A</div>
<div id="item-b" class="item">B</div>
</div>
<div class="column-right">
<div id="item-c" class="item">C</div>
<div id="item-d" class="item">D</div>
</div>
</div>

I don't think you can in css since you want to move an item from a column to an other one. It may not be what you want but this is the solution I found :
.container{
width:100px;
display:flex;
flex-wrap: wrap;
border:1px solid black;
}
#a{
background-color:red;
}
#b{
background-color:blue;
}
#c{
background-color:green;
}
#d{
background-color:yellow;
}
.item{
width:100%;
text-align:center;
}
.order-1{
order: 1;
}
.order-2{
order: 2;
}
.order-3{
order: 3;
}
.order-4{
order: 4;
}
#media screen and (min-width: 992px) {
.item{
width:50%;
}
.order-lg-1{
order: 1;
}
.order-lg-2{
order: 2;
}
.order-lg-3{
order: 3;
}
.order-lg-4{
order: 4;
}
}
<div class="container">
<div id="a" class="item order-2 order-lg-1">A <br> A</div>
<div id="b" class="item order-3 order-lg-3">B</div>
<div id="c" class="item order-1 order-lg-2">C <br> C <br> C</div>
<div id="d" class="item order-4 order-lg-4">D <br> D </div>
</div>
Check Full Page to see the difference in larger screen

Related

Move central div to bottom on mobile

On desktop side columns will take a max-width of 175px leaving the center dynamic but on mobile I want to have a 2x1 grid. Also top columns will be 50% width but the height will depend on their content.
How could I move this center element to the bottom taking 100% of the width and leave the side columns next to each other taking each 50% of the width? I don't want to have hidden and duplicated elements.
#container {
display: flex;
}
.column.left,
.column.right {
max-width: 175px;
}
.column.center {
flex: 1;
text-align: center;
background-color: red;
}
.column.left,
.column.right {
text-align: center;
}
<body>
<div id="container">
<div class="column left">this is a long long long long label</div>
<div class="column center">center</div>
<div class="column right">short label</div>
</div>
</body>
You can use flex-wrap and the order property:
#container {
display: flex;
}
.column.left,
.column.right {
max-width: 175px;
}
.column.center {
flex: 1;
text-align: center;
background-color: red;
}
.column.left,
.column.right {
text-align: center;
}
#media all and (max-width: 600px) {
#container {
flex-wrap: wrap;
}
.column.left, .column.right {
max-width: none;
width: 50%;
}
.column.left {
order: 1;
}
.column.right {
order: 2;
}
.column.center {
order: 3;
width: 100%;
}
}
<body>
<div id="container">
<div class="column left">this is a long long long long label</div>
<div class="column center">center</div>
<div class="column right">short label</div>
</div>
</body>
You can do this easily enough with CSS grid and a media query. See the snippet below
#container {
display: grid;
grid-gap: 1rem;
grid-template-columns: var(--gridColTemplate, 1fr 1fr);
}
.column { text-align: center }
.column.left, .column.right { max-width: var(--sideMaxWidth, none) }
.column.center {
grid-column: var(--centerCol, 1/-1);
grid-row: var(--centerRow, 2);
background-color: red;
}
#media only screen and (min-width: 600px) {
:root {
--gridColTemplate: auto 1fr auto;
--centerCol: 2/3;
--centerRow: 1;
--sideMaxWidth: 175px;
}
}
<div id="container">
<div class="column left">this is a long long long long label</div>
<div class="column center">center</div>
<div class="column right">short label</div>
</div>

In a flexbox grid, how do I prevent the first row from pushing down the second? [duplicate]

This question already has answers here:
Make a div span two rows in a grid
(2 answers)
Is it possible for flex items to align tightly to the items above them?
(5 answers)
Closed 2 years ago.
I have a flex design that looks kinda like this:
.columns {
flex-wrap: wrap;
display: flex;
}
.column {
display: block;
}
.column.is-8 {
flex: none;
width: 66.66667%;
}
.column.is-4 {
flex: none;
width: 33.33333%;
}
.box-1 {
background-color: red;
height: 200px;
}
.box-2 {
background-color: yellow;
height: 400px;
}
.box-3 {
background-color: blue;
height: 800px;
}
*, *::before, *::after {
box-sizing: inherit;
}
<div class="columns">
<div class="column is-8 box-1">
Box 1
</div>
<div class="column is-4 box-2">
Box 2
</div>
<div class="column is-8 box-3">
Box 3
</div>
</div>
<!-- on desktop: box 1, 2 and 3 -->
<!-- on mobile: box 1, 2 and 3 -->
How can I prevent box 2 from pushing down box 3? So it would look like this:
Update
I would like to add that on mobile, the boxes should be in the same order (e.g. 1, 2 then 3)
You need to setup your template a bit differently as box 1 and 3 is in the same column. You can achieve the desired layout by wrapping box 1 and 3 in a div.
.columns {
display: flex;
width: 100%;
}
.column {
width: 100%;
}
.column.is-8 {
width: 66.66667%;
}
.column.is-4 {
width: 33.33333%;
}
.box-1 {
background-color: red;
height: 200px;
}
.box-2 {
background-color: yellow;
height: 400px;
}
.box-3 {
background-color: blue;
height: 800px;
}
*,
*::before,
*::after {
box-sizing: inherit;
}
<div class="columns">
<div class="column is-8">
<div class="box-1">Box 1</div>
<div class="box-3">Box 3</div>
</div>
<div class="column is-4">
<div class="box-2">Box 2</div>
</div>
</div>
here is another possibility with grid and auto-fit (see comment in CSS for the setting)
Snippet to run in full page and resize to see behavior.
.columns {
display: grid;
/*Below : 400px for minmax is more than a third of 1000px width of the container
to draw at most 2 columns */
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
width: 800px;
margin: auto;
max-width: 100%;
}
.column {
border: solid;
}
.box-1 {
background-color: red;
height: 100px;
}
.box-2 {
background-color: yellow;
min-height: 100px;
grid-row: span 2;
}
.box-3 {
background-color: blue;
height: 300px;
}
<div class="columns">
<div class="column is-8 box-1">
Box 1
</div>
<div class="column is-4 box-2">
Box 2
</div>
<div class="column is-8 box-3">
Box 3
</div>
</div>
You can try using this, using the grid layout. It lets you make grids (surprise, surprise) and it gives you more control over everything inside it. So something like this:
.columns {
display: grid;
width: 100%;
grid-gap: 0;
grid-template-columns: 2fr 1fr;
}
.column {
display: block;
}
.box-1 {
background-color: red;
height: 200px;
grid-column: 1;
grid-row: 1;
}
.box-2 {
background-color: yellow;
height: 400px;
grid-column: 2;
grid-row: 1 / 3;
}
.box-3 {
background-color: blue;
height: 200px;
grid-column: 1;
grid-row: 2;
}
*, *::before, *::after {
box-sizing: inherit;
}
<div class="columns">
<div class="column is-8 box-1">
Box 1
</div>
<div class="column is-4 box-2">
Box 2
</div>
<div class="column is-8 box-3">
Box 3
</div>
</div>
<!-- on desktop: box 1, 2 and 3 -->
<!-- on mobile: box 1, 2 and 3 -->
Edit: to make it responsive, you can quite easily pop this at the end of your css:
#media (max-width: 700px) {
.columns {
display: block;
}
}
.columns {
display: grid;
width: 100%;
grid-gap: 0;
grid-template-columns: 2fr 1fr;
}
.column {
display: block;
}
.box-1 {
background-color: red;
height: 200px;
grid-column: 1;
grid-row: 1;
}
.box-2 {
background-color: yellow;
height: 400px;
grid-column: 2;
grid-row: 1 / 3;
}
.box-3 {
background-color: blue;
height: 200px;
grid-column: 1;
grid-row: 2;
}
*, *::before, *::after {
box-sizing: inherit;
}
#media (max-width: 700px) {
.columns {
display: block;
}
}
<div class="columns">
<div class="column is-8 box-1">
Box 1
</div>
<div class="column is-4 box-2">
Box 2
</div>
<div class="column is-8 box-3">
Box 3
</div>
</div>
<!-- on desktop: box 1, 2 and 3 -->
<!-- on mobile: box 1, 2 and 3 -->

change block order with flex

How to do this kind of markup? So when the resolution is lower than 640px the container number 2 goes to the bottom.
I know that I should use #media (max-width:600px) {}
but I don't really understand how to get the block #2 to bottom from "column right"
Thanks
My example fiddle is https://jsfiddle.net/benderlio/tewzvLxf/3/
#container {
display: flex;
}
.column.left {
width: 60%;
flex: 0 0 1;
background-color: red;
}
.column.right {
padding-top: 30px;
text-align: center;
width: 40%;
flex: 0 0 1;
}
.box {
border: 1px solid red;
margin: 20px;
padding: 20px;
}
<div id="container">
<div class="column left">
</div>
<div class="column right">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
</div>
</div>
I would use grid with a media query and removing the column divs:
* {
box-sizing: border-box;
}
#container {
width: 100%;
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-areas:
"a b"
"a c"
"a d";
}
.box {
border: 1px solid red;
margin: 20px;
padding: 20px;
}
.box1 {
grid-area: a;
}
.box2 {
grid-area: b;
}
.box3 {
grid-area: c;
}
.box4 {
grid-area: d;
}
#media (max-width:640px) {
/* adding the commented out areas will allow box1 to keep it's height like in your images so there is a space below box 4 */
#container {
/* grid-template-rows: 1fr 1fr 1fr; */
grid-template-areas:
"a b"
"a d"
/* "a ." */
"c c";
}
}
<div id="container">
<div class="box box1">
1
</div>
<div class="box box2">2</div>
<div class="box box3">3</div>
<div class="box box4">4</div>
</div>
You can do it without changing your structure, like this
#media only screen and (max-width: 640px) {
#container {
flex-direction: column-reverse;
}
}
You can set the flex-direction to have a reverse outcome on columned box.
EDIT
So after the confusion was set out, this is the least I can think of to closely produce what you want. You need to set the container's position to be relative and set the 2nd box's position to be absolute, but this rather a dirty way to do it.
body {}
#container {
display: flex;
}
.column.left {
width: 60%;
flex: 0 0 1;
background-color: red;
}
.column.right {
padding-top: 30px;
text-align: center;
width: 40%;
flex: 0 0 1;
}
.box {
border: 1px solid red;
margin: 20px;
padding: 20px;
}
#media only screen and (max-width: 640px) {
#container {
position: relative;
}
.box:nth-child(2) {
width: 90%;
position: absolute;
bottom: -100px;
left: -20px;
}
}
<div id="container">
<div class="column left">
1
</div>
<div class="column right">
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
</div>
</div>

Displaying divs on multiple rows with custom limitations

I am trying to place 6 boxes, as a small exercise to understand how to do it. I want these 6 boxes to be divided in 4 boxes on a row and then 2 on the second one, and I want to do it with the display feature in CSS so that is not applicable only for this case. This is what I have been trying.
https://gyazo.com/f64788cdf85d263e56452c1412fdcfb0?token=f6c45c6813c3fc47addb63483cee3f6a
.parent{
display: flex;
flex-wrap: wrap;
}
.parent-wrapper {
height:100%;
width:100%;
border: 1px solid black;}
.child {
width: 300px;
height: 200px;
background-color: green;
border: 1px solid red;
margin: 5px;
flex: 1 0 21%;
}
You could use display: flex.
HTML:
<div class="flex">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
CSS (EDITED):
.flex {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.flex div {
height: 200px;
background-color: green;
border: 1px solid red;
box-sizing: border-box;
/*flex: 1 0 23%;*/
width: 24.1%;
margin: 5px;
/*margin-bottom: 5px;*/
}
The output is the following:
Not sure if you mean this but what I understood from your question:
HTML:
<div class="divTable">
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell"></div>
<div class="divTableCell"></div>
</div>
<div class="divTableRow">
<div class="divTableCell"></div>
<div class="divTableCell"></div>
</div>
<div class="divTableRow">
<div class="divTableCell"></div>
</div>
<div class="divTableRow">
<div class="divTableCell"></div>
</div>
</div>
</div>
CSS:
.divTable{
display: table;
width: 100%;
}
.divTableRow {
display: table-row;
}
.divTableHeading {
background-color: #EEE;
display: table-header-group;
}
.divTableCell, .divTableHead {
border: 1px solid #999999;
display: table-cell;
padding: 3px 10px;
}
.divTableHeading {
background-color: #EEE;
display: table-header-group;
font-weight: bold;
}
.divTableFoot {
background-color: #EEE;
display: table-footer-group;
font-weight: bold;
}
.divTableBody {
display: table-row-group;
}
If you want to use the display: grid the solution could look like this:
https://jsfiddle.net/uvrjs7op/
<div class='Wrapper'>
<div class='Item-A'></div>
<div class='Item-B'></div>
<div class='Item-C'></div>
<div class='Item-D'></div>
<div class='Item-E'></div>
<div class='Item-F'></div>
</div>
.Wrapper {
Display: grid;
grid-template-columns: 25% 25% 25% 25%;
grid-template-rows: 50px 50px;
Background: orange;
}
.Item-A{
grid-column-start: 1;
grid-column-end: 2;
Background: Green;
}
.Item-B{
grid-column-start: 2;
grid-column-end: 3;
Background: blue;
}
.Item-C{
grid-column-start: 3;
grid-column-end: 4;
Background: red;
}
.Item-D{
grid-column-start: 4;
grid-column-end: 5;
Background: brown;
}
.Item-E{
grid-column-start: 1;
grid-column-end: 3;
grid-row-start: 2;
Background: yellow;
}
.Item-F{
grid-column-start: 3;
grid-column-end: 5;
grid-row-start: 2;
Background: purple;
}
An easy solution will be
Solution
#wrapper {
display:grid;
grid-template-columns: repeat(4, 1fr);
grid-auto-rows: 1fr;
grid-column-gap: 5px;
width:100%;
}
#wrapper > div {
margin:10px;
background-color:#bada55;
}
<div id="wrapper">
<div id="first">first</div>
<div id="second">second</div>
<div id="third">third</div>
<div id="fourth">fourth</div>
<div id="fifth">fifth</div>
<div id="sixth">sixth</div>
</div>

How can I use flexbox to achieve a complex, responsive HTML layout?

I have looked into Flexbox to achieve a responsive layout like pictured below. Unfortunately I still have not figured out how to achieve a desktop layout like Figure 1 which rearranges itself to Figure 2 on viewports smaller than 414 pixel.
Figure 1 (desktop viewports)
Figure 2 (mobile viewports)
(scaled version)
Click here for image in original size
My code so far :
.flexbox {
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
flex-wrap: wrap;
width: 100%;
margin: 0;
flex-direction: row;
}
.content-flexbox.one {
flex-basis: calc(66% - 1rem);
order: 2;
}
.content-flexbox.two {
flex-basis: calc(30% - 1rem);
order: 1;
}
.content-flexbox.three {
order: 3;
}
.content-flexbox.four {
order: 4;
}
.content-flexbox {
margin: 1rem;
-webkit-box-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
}
#media only screen and (max-width: 959px) {
.flexbox {
-flex-direction: column;
padding-top: 1rem;
}
.content-flexbox {
margin: 1rem;
flex: 1;
flex-basis: 100%;
}
.content-flexbox.one {
flex-basis: 100%;
order: 1;
}
.content-flexbox.two {
flex-basis: 100%;
order: 2;
}
}
<div class="flexbox">
<div class="content-flexbox one">
<h1 class="posttitle">Lorem ipsum</h1>
<h2 class="subtitle">dolor sit amet</h2>
</div>
<div class="content-flexbox two">
<img src="http://placehold.it/300x300" />
</div>
<div class="content-flexbox three">
<span>Lorem ipsum dolor</span>
</div>
<div id="container-voting" class="content-flexbox four">
<div class="inner-container set">
<span>Lorem ipsum dolor</span>
</div>
<div class="inner-container get">
<span>Lorem ipsum dolor</span>
</div>
</div>
</div>
My question
Is this even possible with flexbox? Is there a better alternative more suited for this layout?
You’re looking for the experimental grid syntax. Flexbox is good for smaller, widget or component layout systems. Grid is for overall page layout, and it’s awesome.
Thing is, grid is only supported in IE, Edge, and the upcoming Safari browsers right now, but Firefox and Chrome support is allegedly just around the corner, and you can start trying it out today by enabling the right developer flag in those browsers.
Here is some sample code, but again, it will only work if your browser supports the new grid syntax.
*{
box-sizing: border-box;
}
.flexbox{
width: 320px;
display: grid;
grid-template-columns: calc(50% - 0.5ch) calc(50% - 0.5ch);
grid-gap: 1ch;
}
.one{
order: 2;
background-color: red;
}
.two{
grid-column: 1 / 3;
order: 1;
background-color: green;
}
.three{
order: 3;
background-color: pink;
}
.four{
display: grid;
grid-column: 1 / 3;
grid-gap: 1ch;
order: 4;
background-color: lavender;
}
.inner-container{
background-color: violet;
}
#media screen and (min-width: 500px){
.flexbox{
width: 500px;
grid-template-columns: calc(33.333% - 0.333ch) calc(33.333% - 0.333ch) calc(33.333% - 0.333ch);
}
.one{
grid-row: 1 / 3;
order: 1;
}
.two{
order: 2;
grid-column: 2 / 4;
}
.three{
order: 3;
}
.four{
grid-column: 3 / 4;
order: 4;
}
}
<div class="flexbox">
<div class="content-flexbox one">
<h1 class="posttitle">Lorem ipsum</h1>
<h2 class="subtitle">dolor sit amet</h2>
</div>
<div class="content-flexbox two">
<img src="http://placehold.it/300x300" />
</div>
<div class="content-flexbox three">
<span>Lorem ipsum dolor</span>
</div>
<div id="container-voting" class="content-flexbox four">
<div class="inner-container set">
<span>Lorem ipsum dolor</span>
</div>
<div class="inner-container get">
<span>Lorem ipsum dolor</span>
</div>
</div>
Although this question explicitly asked for a flexbox approach, there is another way to achive it using simple floats.
A media query allows to rearange the elements in the desired order on viewports less than 414px wide:
.wrap {
background: #d0d0d0;
padding: 1%;
}
.wrap:after {
content: '';
display: block;
clear: both;
}
.el {
float: left;
margin: 1%;
}
.el1 {
width: 31.33%;
padding-bottom: 31.33%;
background: #FF7676;
}
.el2 {
float: right;
width: 64.66%;
padding-bottom: 14.66%;
background: #C2FF76;
}
.el3 {
width: 31.33%;
padding-bottom: 14.66%;
background: #FF9BF7;
}
.el4 {
width: 31.33%;
padding-bottom: 6.33%;
background: #9BA4FF;
}
#media (max-width: 414px) {
.el2, .el4 {
width: 98%;
padding-bottom: 31.33%;
}
.el1, .el3 {
width: 48%;
padding-bottom: 48%;
}
}
<div class="wrap">
<div class="el el2"></div>
<div class="el el1"></div>
<div class="el el3"></div>
<div class="el el4"></div>
<div class="el el4"></div>
</div>
Note that I used padding-bottom to keep the aspect ratio of the elements in this example (more info in this answer).
I don't know what content you intend to put in the blocks but you will need to use absolute positionnig for it if you want to stick with the "padding technique". For plain text content, you can check this fiddle.
The problem is that, if you want to be able to rearrange all items, they must be flex items of the same flex container. But Flexbox does not provide any direct way to make an element occupy more than one flex line.
However, you can use multiple containers and display: contents:
The element itself does not generate any boxes, but its children and
pseudo-elements still generate boxes as normal. For the purposes of
box generation and layout, the element must be treated as if it had
been replaced with its children and pseudo-elements in the document
tree.
/* Desktop */
.container {
display: flex;
flex-wrap: wrap;
}
.container > * {
flex-grow: 1;
}
.item {
margin: 2px;
}
.column {
flex-direction: column;
}
.fill {
width: 100%;
}
/* Mobile */
#media (max-width: 414px) {
.container > .container {
display: contents;
}
.i2 {
order: -1;
}
.i4 {
width: 100%;
}
}
/* Pretty */
.i1 { background: #FF7676; }
.i2 { background: #C2FF76; }
.i3 { background: #FF9BF7; }
.i4 { background: #9BA4FF; }
<div class="container">
<div class="item i1">1</div>
<div class="container">
<div class="item i2 fill">2</div>
<div class="item i3">3</div>
<div class="container column">
<div class="item i4">4a</div>
<div class="item i4">4b</div>
</div>
</div>
</div>
The only problem is that display: contents is not widely supported yet, but you can see it working on Firefox.
I don't think this is possible to do with pure css, but you could use some js and change html structure on resize with wrapAll() and unwrap(). You also need to use media queries to change order and some css when window is < 414px.
$(window).on("resize", function() {
var windowW = $(window).width();
if (windowW < 414) {
if ($('.right, right-inner').length) $('.two, .four').unwrap();
if (!$('.top').length) $('.one, .two, .three').wrapAll('<div class="top"></div>');
} else {
if ($('.top').length) $('.one, .two, .three').unwrap();
if (!$('.right, .right-inner').length) {
$('.three, .four').wrapAll('<div class="right-inner"></div>');
$('.two, .right-inner').wrapAll('<div class="right"></div>');
}
}
}).resize();
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body,
html {
margin: 0;
padding: 0;
font-family: sans-serif;
}
.flexbox {
display: flex;
min-height: 100vh;
color: white;
font-size: 50px;
}
.one {
flex: 1;
background: #FF7676;
margin: 10px;
}
.right {
flex: 2;
display: flex;
flex-direction: column;
margin: 10px;
}
.two {
height: 40%;
display: flex;
margin-bottom: 20px;
margin-right: 10px;
}
.two img {
width: 100%;
margin: 0;
}
.right-inner {
display: flex;
flex: 2;
}
.three,
.four {
flex: 1;
}
.three {
background: #FF9BF7;
margin-right: 10px;
}
.four {
display: flex;
flex-direction: column;
}
.set,
.get {
background: #9BA4FF;
flex: 1;
margin: 5px;
}
.set {
margin-top: 0;
}
.get {
margin-bottom: 0;
}
#media(max-width: 414px) {
.flexbox {
flex-direction: column;
}
.flexbox > * {
flex: 1;
margin: 10px;
}
.get,
.set {
margin: 0;
margin-bottom: 10px;
}
.two {
order: -1;
flex: 0 0 100%;
margin-bottom: 0;
}
.two img {
height: 100px;
}
.one,
.three {
width: 50%;
margin: 0;
}
.one {
margin-right: 10px;
}
.top {
display: flex;
flex-wrap: wrap;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<div class="flexbox">
<div class="content-flexbox one">
<span class="posttitle">1</span>
</div>
<div class="right">
<div class="content-flexbox two">
<img src="http://placehold.it/300x300/C2FF76" />
</div>
<div class="right-inner">
<div class="content-flexbox three">
<span>3</span>
</div>
<div id="container-voting" class="content-flexbox four">
<div class="inner-container set">
<span>4a</span>
</div>
<div class="inner-container get">
<span>4b</span>
</div>
</div>
</div>
</div>
</div>
I see that you can make two containers with floats and like mentioned before use liquid style page with width %. If you aproche mobile viewport use media querys to declair breakpoints.