I'm reproducing a site in order to practice CSS and HTML, but I got stuck on something. I tried for hours and searched everywhere for a solution in order to split a section in half and add a row with two columns inside, like you can see in this image:
Also tried to look at their source, but they have tons of classes in all kind of files, which makes it pretty hard to figure out how they did it.
/**** Standard stuff ****/
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html,
body {
background-color: #fff;
color: #555;
font-family: 'Lato', 'Arial', sans-serif;
font-weight: 300;
font-size: 20px;
text-rendering: optimizeLegibility;
overflow-x: hidden;
}
.section {
clear: both;
padding: 0px;
margin: 0px;
}
.clearfix {
zoom: 1;
}
.clearfix:after {
content: '.';
clear: both;
display: block;
height: 0;
visibility: hidden;
}
/**** Row ****/
.row {
max-width: 1140px;
margin: 0 auto;
}
.row:before,
.row:after {
content: "";
display: table;
}
.row:after {
clear: both;
}
/**** Cols ****/
.col {
display: block;
float: left;
margin: 1% 0 1% 1.6%;
}
.col:first-child {
margin-left: 0;
}
.span-1-of-2 {
width: 49.2%;
}
/**** Styling ****/
.first-half {
width: 50%;
background-color: #ff0000;
height: 500px;
float: left;
}
.second-half {
width: 50%;
float: right;
height: 500px;
}
.section-split {
position: relative;
}
.section-split .row {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.left-text {
padding-right: 15%;
}
.right-text {
padding-left: 15%;
}
.right-text,
.left-text {
color: #fff;
}
<section class="section-split clearfix">
<div class="first-half"></div>
<div class="second-half">
<img src="http://placehold.it/950x500" alt="">
</div>
<div class="row">
<div class="col span-1-of-2">
<div class="left-text">
<p>Case Study - Macaw Mobile App We recently restructured Macaws strategy which lead to an increase in sales and traffic for the brand. Downloads and turnover skyrocketed. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
eu fugiat nulla pariatur. Play Showcase</p>
</div>
</div>
<div class="col span-1-of-2">
<div class="right-text">
<p>Case Study - Macaw Mobile App We recently restructured Macaws strategy which lead to an increase in sales and traffic for the brand. Downloads and turnover skyrocketed. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
eu fugiat nulla pariatur. Play Showcase</p>
</div>
</div>
</div>
</section>
Here's what I've managed to do: http://codepen.io/anon/pen/jyvBvo. Even though it's similar to what I want, I highly doubt that that's the proper way to do it. I think the code is pretty "ugly".
I'm also trying to make it responsive, which makes it even more challenging.
Any help and guidance will be appreciated!
Thank you!