'How do i get the two blocks to get horizontally inline?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lost and Found</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Anton&display=swap" rel="stylesheet">
</head>
<body>
<div class="nav" >
<img src="img.png" alt="logo" srcset="">
<div class="b"><span>Electronincs</span></div>
<div class="b"><span>Plastics</span></div>
<div class="b"><span>Wearables</span></div>
<div class="b"><span>Others</span></div>
<input id="srch" type="search" value="Search">
</div>
<div class="main">
<div style="display: inline;">
<div class="head">
<p>Help The Needy</p>
</div>
<div class="head">
<p>Help The Needy</p>
</div>
</div>
</div>
</div>
</body>
</html>
*{
margin: 0px;
padding: 0px;
}
.nav{
background-color:bisque;
width: 100%;
height: 60px;
display: flex;
align-items: center;
position:absolute;
}
.b{
height: 60px;
width: 10%;
background-color: antiquewhite;
margin: 2px;
justify-content: center;
font-family: 'Anton', sans-serif;
border-radius: 20px;
align-items: center;
display: flex;
}
img{
width: 80px;
height: 60px;
}
#srch{
width: 10%;
height:60px;
right: 0%;
position:fixed;
font-size: larger;
}
.main{
height: 1700px;
width: 100%;
border-color: blue;
border-style: double;
background-color:lightgoldenrodyellow;
}
.head{
margin-top: 60px;
display:flexbox;
width: 45%;
height: 554px;
border-color:red;
border-style: groove;
border-width: 5;
font-family: cursive;
font-size: larger;
}
How do i get the two blocks to get horizontally inline The 2nd block is getting placed vertically below the 1st box. Also when i set display (which is inline) to inline-block, the blocks suddenly become very thin and still not inlined.
I am beginner web developer trying to learn html and css. Please help me solve this problem.
Solution 1:[1]
Wrap your elements within a container then use display flex for the container ... Hope this simple example make it clear
.container{
display:flex;
justify-content:space-between;
}
<div class="container">
<div class="div1">Some Dummy Text 1</div>
<div class="div2">Some Dummy Text 2</div>
</div>
strong text
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Salwa A. Soliman |
