Aligning 2 div elements side by side

Posted by

css file

[code]

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

.clearfix:after{
content: "";
display: table;
clear: both;
}

body {
font-size: 18px;
font-family: Helvetica Neue, Arial;
}

h1,
h2 {
color: #019801;
}

h1 {
font-size: 40px;
margin-bottom: 20px;
}

h2 {
font-size: 25px;
margin-bottom: 10px;
}

.main-text {
text-align: justify;
margin-bottom: 20px;
}

#author-text {
font-size: 22px;
}

.container {
width: 1140px;
margin-left: auto;
margin-right: auto;
}

.blog-post{
background-color: #000ff0;
width: 75%;
float: left;
}

.other-posts{
background-color: #00ff00;
width: 25%;
float: left;
}

.author-box{
background-color: #ffff00;
}

[/code]

html file

[code]

<div class="container">
<div class="blog-post">
<h1>My first blog post</h1>
<h2>This is my first blog post</h2>
<p class="main-text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>

<img src="logo.jpg" alt="This is HTML5 logo">

<a href="http://www.udemy.com" target="_blank">Link to Udemy</a>
<a href="logo.jpg" target="_blank">HTML logo</a>

<h2>HTML is amazing</h2>

<p class="main-text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>

<div class="other-posts">
Dummy text
</div>
<div class="clearfix"></div>
<div class="author-box">
<img src="author.jpg" alt="Author Photo">
<p class="main-text"> Florence Smith</p>
</div>
</div>

[/code]

Leave a Reply

Your email address will not be published. Required fields are marked *