0
I’ve been using the float: léft;
lately, but there are times when it doesn’t work as I hope. Example:
(image 1) Note that a margin appears that should not be here. (image 2) A margin some, but since there is no float the other div is on the bottom line.
The purpose of the code is to make a top menu similar to this:
Shouldn’t he just play the Divs next to each other? How do I fix this? Why does he do this?
@import url(https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700);
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,700,600);
*{margin: 0; padding: 0;}
body{
background: #ecf0f1;
color: #2c3e50;
font-family: 'Open Sans', sans-serif;
}
.top-menu{
width: 100%;
height: 50px;
background: #c0392b;
border-bottom: 4px solid #96271C;
color: #f2f2f2;
position: fixed;
}
.top-menu .content{
width: 900px;
margin: 0 auto;
}
.burger-menu{
background: #96271C;
height: 100%;
width: 100px;
float: left;
position: relative
}
.burger > div{
width: 21px;
height: 4px;
border-radius: 2px;
display: block;
background: #fff;
margin-bottom: 4px;
}
.burger{
float: left;
margin: 15px 10px;
}
.burger-menu{
font-size: 18px;
text-transform: uppercase;
line-height: 50px;
}
.title-section{
width: 300px;
margin: 0 auto;
float: left;
display: block;
position: relative;
}
.title-section .title{
text-align: center;
text-transform: uppercase;
font-size: 32px;
line-height: 50px;
font-weight: 300;
}
.search-section{
width: 160px;
height: 30px;
margin-top: 10px;
}
.search-section input, input:focus{
width: 160px;
height: 30px;
background: #96271C;
border-radius: 3px;
border: 1px #ecf0f1 solid;
padding:5px;
color: #f2f2f2;
outline: none;
}
::-webkit-input-placeholder {color: #f2f2f2;}
:-moz-placeholder {color: #f2f2f2;}
::-moz-placeholder {color: #f2f2f2;}
:-ms-input-placeholder {color: #f2f2f2;}
<!DOCTYPE HTML5>
<html>
<head>
<meta charset="utf-8">
<title>Menu G1</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
</head>
<body>
<div class="top-menu">
<div class="content">
<div class="burger-content">
<div class="burger-menu">
<div class="burger">
<div></div>
<div></div>
<div></div>
</div>menu
</div>
</div>
<div class="title-section">
<div class="title">Política
</div>
</div>
<div class="search-section">
<input type="text" placeholder="Pesquisar" name="pesquisa-menu">
</div>
</div>
</div>
</body>
</html>
I think it would be important you [Dit] the post and make it clear the result you want to get instead of wanting to use the
float:left
at any time. It may happen in your case thefloat:left
not fit for it. Or if you just want to learn about thefloat
, Then the question is already different, and the images up are no longer relevant. Remember that the more objective the question, the greater the chance of a good answer, because good answers depend on the community understanding the problem in fact, and not only the developments that the problem causes.– Bacco