I want to align these 3 divs next to each other, but instead of setting px or % as per the window I would like it to be as auto (is this possible?). Also in case the browser is narrower, the 3rd div should go below and occupy entire row, but somehow it does not do that. Media conditions are being set however.
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: "Arial", "Helvetica", sans-serif;
}
h1 {
text-align: center;
padding: 15px;
}
h3 {
border: 1px solid black;
margin: 1px;
font-weight: bold;
float: right;
}
p {
box-sizing: border-box;
margin-top: 35px;
margin-left: 10px;
margin-right: 10px;
margin-bottom: 10px;
white-space: normal;
overflow: overlay;
}
title {
float: left;
position: absolute;
clear: both;
}
container {
width: 100%;
margin: 10px;
}
.section {
float: left;
margin: 5px;
border: 1px solid black;
overflow: overlay;
}
.section:nth-child(1) {
background-color: aquamarine;
}
.section:nth-child(2) {
background-color: cadetblue;
}
.section:nth-child(3) {
background-color: forestgreen;
}
/* Large devices */
@media (min-width: 992px) {
.col-lg-4 {
float: left;
width: 33%;
}
}
/* Medium devices */
@media (min-width: 768px) and (max-width: 991px) {
.col-md-6 {
float: left;
width: 50%;
}
.col-md-12 {
clear: both;
}
}
/* Small devices */
@media max-width: 767px {
.col-sm-12 {
width: 100%;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/styles.css">
<title>Module 2 Assignment</title>
</head>
<body>
<header>
<h1>Our Menu</h1>
</header>
<div class="container">
<div class="section col-lg-4 col-md-6 col-sm-12">
<h3 id="item1" class="title">Menu Item 1</h3>
<p>Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text
Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here </p>
</div>
<div class="section col-lg-4 col-md-6 col-sm-12">
<h3 id="item2" class="title">Menu Item 2</h3>
<p>Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text
Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here </p>
</div>
<div class="section col-lg-4 col-md-12 col-sm-12">
<h3 id="item3" class="title">Menu Item 3</h3>
<p>Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text
Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here Text Goes Here </p>
</div>
</div>
</body>
</html>