Hi, I’m really in trouble with divs.
smaller divs won’t line up properly.their parent div is 1200px width.Each of them are 390px width and 5px margined.I want 3 of them for each line but they do 2-dived lines.If we do the math, 3390 + 45=1190. so they should fit.
when i use float:left they line up properly but this time the container div doensn’t wrap them.
Please help me get out of this mess…
here’s my code:
html,body{height:100%;margin:0;padding:0;
}
.container{margin:auto;
width:1200px;
min-height:100%;
background-color:red;}
.menu{z-index:2;
position:sticky;
top:0;
width:1200px;
height:100px;}
.menu ul{
margin:0px;
padding:0px;}
.menu ul li{
float:left;
width:400px;
line-height:50px;
list-style-type:none;}
.menu ul li a{
background-color:pink;
text-decoration:none;
text-align:center;
display:block;
}
.menu ul li ul{display:none;}
.menu ul li:hover ul {
display:block;}
.content{z-index:1;
position:absolute;
width:1200px;
padding:0;}
.div1{
display:inline-block;
width:390px;
height:350px;
margin:5px;
position:relative;
background-color:blue;}
.footer{
width:1200px;
height:150px;
margin:auto;
background-color:orange;
}
<head>
<title>divs</title>
<link rel="stylesheet" type="text/css" href="divs.css">
</head>
<body>
<div class="container">
<div class="menu">
<ul>
<li><a href="">z</a></li>
<li><a>x</a>
<ul> <li><a href="" >x1</a></li>
<li><a href="" >x2</a></li>
<li><a href="" >x3</a></li>
</ul>
</li>
<li><a href="" >y</a></li>
</ul>
</div>
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam tincidunt leo non
mauris rutrum, eget pretium nunc scelerisque. Aenean tincidunt id magna sit amet
laoreet. Donec vehicula libero at elementum auctor. Morbi pretium placerat risus,
sed semper nibh porttitor eu. Donec ante metus, convallis eu turpis vitae, sagittis
blandit ex. Maecenas eu mauris sed magna tempus rhoncus. Nulla tristique tempus
condimentum. Nunc ultrices iaculis tellus at eleifend. Vivamus mollis magna ut
tellus hendrerit volutpat vitae eu lacus. Duis quis malesuada dui, at gravida nisl.
Curabitur vestibulum nec arcu nec tempus. Nam molestie quam in molestie varius.
Duis dapibus dolor et libero consectetur, sed dignissim augue viverra. Etiam tempus
dignissim ipsum ac elementum.
<br><br><br><br>
Curabitur ac dolor rutrum, mollis lacus eu, interdum magna. Pellentesque efficitur
dui enim, sed elementum quam egestas a. Pellentesque vel condimentum ante.
Suspendisse magna felis, eleifend a mollis et, bibendum vel mauris. Integer vel quam
scelerisque ipsum bibendum lacinia. Donec pulvinar eros quis fermentum interdum. Cras
eleifend, nisi ut sollicitudin blandit, justo justo consequat magna, ac sagittis tortor
nunc in felis. Donec vestibulum pulvinar leo, sed euismod risus mattis in. Nullam
interdum vitae risus id luctus. Vivamus rhoncus maximus nunc.
</div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
</div>
<div class="footer"></div>
</body>
</html>