So I've been trying to get my custom image to appear in a vertical toolbar, but I'm having trouble. I'm referencing http://codepen.io/nikhil/pen/sicrK which has all of the source code; I want pretty much the same toolbar, but with custom images. Here's a snippet, from the part I've been trying to adjust to get it to work:
From the HTML:
<ul class="menu">
<li title="home">menu</li>
<li title="search">search</li>
<li title="pencil">pencil</li>
<ul>
From the CSS - before (works, as in the link):
.menu li a.search:before {
content: "\f002";
}
From the CSS - with my attempted modification (doesn't work; no image appears)
.menu li a.search:before {
list-style-image: "\newImage.png";
}
So, I was trying to use list-style-image, but no image would appear. The image I'm referencing in the folder is 100x100px. I tried background-image and just using <img src="newImage.png"> inside the HTML markup, but no dice - no image appears and there are no errors logged in the console. How can I resolve this issue? The toolbar re-sizes according to the CSS based on the screen size, so I assume that means the size of my image doesn't really matter. Or, do I need to be using an SVG instead? Thanks for any help - I'm new to working with CSS.
You are misunderstanding the concept of Icon Fonts.
If you want to display an image in a pseudo-element, then you should use background property, just as with any other element. See fro more Using :before CSS pseudo element to add image to modal
Please have a look at my snippet:
$(document).ready(function() {
$(".menu-button").click(function() {
$(".menu-bar").toggleClass("open");
})
})
.menu,
.menu-bar {
position: fixed;
top: 0;
left: 0;
height: 100%;
list-style-type: none;
margin: 0;
padding: 0;
background: #f7f7f7;
z-index: 10;
overflow: hidden;
box-shadow: 2px 0 18px rgba(0, 0, 0, 0.26);
}
.menu li a {
display: block;
text-indent: -500em;
height: 5em;
width: 5em;
line-height: 5em;
text-align: center;
color: #72739f;
position: relative;
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
transition: background 0.1s ease-in-out;
}
.menu li a:before {
font-family: FontAwesome;
speak: none;
text-indent: 0em;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
font-size: 1.4em;
}
.menu li a.search:before {
content: '';
background: url("http://piq.codeus.net/static/media/userpics/piq_162172_400x400.png");
background-size: contain;
background-repeat: no-repeat;
background-position: 50% 50%;
/* content: "\f002"; */
}
.menu li a.archive:before {
content: '';
background: url("http://i.imgur.com/HsZNOfb.png");
background-size: contain;
background-repeat: no-repeat;
background-position: 50% 50%;
/* content: "\f187"; */
}
.menu li a.pencil:before {
content: '';
background: url("http://thepunkeffect.com/wp-content/uploads/2013/11/01-03.jpeg");
background-size: contain;
background-repeat: no-repeat;
background-position: 50% 50%;
/* content: "\f040"; */
}
.menu li a.contact:before {
content: "\f003";
}
.menu li a.about:before {
content: "\f007";
}
.menu li a.home:before {
content: "\f039";
}
.menu-bar li a:hover,
.menu li a:hover,
.menu li:first-child a {
background: #267fdd;
color: #fff;
}
.menu-bar {
overflow: hidden;
left: 5em;
z-index: 5;
width: 0;
height: 0;
transition: all 0.1s ease-in-out;
}
.menu-bar li a {
display: block;
height: 4em;
line-height: 4em;
text-align: center;
color: #72739f;
text-decoration: none;
position: relative;
font-family: verdana;
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
transition: background 0.1s ease-in-out;
}
.menu-bar li:first-child a {
height: 5em;
background: #267fdd;
color: #fff;
line-height: 5
}
.para {
color: #033f72;
padding-left: 100px;
font-size: 3em;
margin-bottom: 20px;
}
.open {
width: 10em;
height: 100%;
}
#media all and (max-width: 500px) {
.container {
margin-top: 100px;
}
.menu {
height: 5em;
width: 100%;
}
.menu li {
display: inline-block;
float: left;
}
.menu-bar li a {
width: 100%;
}
.menu-bar {
width: 100%;
left: 0;
height: 0;
}
.open {
width: 100%;
height: auto;
}
.para {
padding-left: 5px;
}
}
#media screen and (max-height: 34em) {
.menu li,
.menu-bar {
font-size: 70%;
}
}
#media screen and (max-height: 34em) and (max-width: 500px) {
.menu {
height: 3.5em;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" />
<ul class="menu">
<li title="home">menu
</li>
<li title="search">search
</li>
<li title="pencil">pencil
</li>
<li title="about">about
</li>
<li title="archive">archive
</li>
<li title="contact">contact
</li>
</ul>
<ul class="menu-bar">
<li>Menu
</li>
<li>Home
</li>
<li>Profile
</li>
<li>Editorial
</li>
<li>About
</li>
</ul>
Related
I'm having trouble with the dropdown menu of my blog. When I hover over "Plamo Reviews", it doesn't drop down the sub-menus. I read some articles related to this but still cannot find any solution. I think I did something wrong with the CSS.
Could anyone help me?
I'd appreciate any help. Thank you in advance!
nav.fixnavbar {
position: relative;
display: block;
width: 100%;
background: #778595;
z-index: 99;
padding: 0;
margin-bottom: 0;
font-size: 0;
opacity: 1;
}
.fixednav {
position: relative;
margin: 0 auto;
padding: 0;
max-width: 1010px;
}
.fixednav li {
display: inline-block;
position: relative;
}
.fixednav li a {
display: inline-block;
padding: 20px;
color: #fff;
font-size: 14px;
font-weight: 700;
text-transform: uppercase;
}
.fixednav li a:hover {
background: #6c7a89;
color: #fff;
}
.nav-icon {
display: none;
}
nav.fixnavbar.main-nav-scrolled {
position: fixed;
top: 0;
left: 0;
opacity: 0.97;
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
.sub-menu li {
display: none;
}
.fixednav li {
position: relative;
}
.sub-menu {
display: none;
position: absolute;
}
.fixednav li:hover .sub-menu {
display: block;
}
<nav class='fixnavbar'>
<ul class='fixednav' id='togglemenu'>
<li><a href='/'>Home</a></li>
<li><a href='/search/label/list'>List bài viết</a></li>
<li><a href='/search/label/kinh-nghiem'>Kinh nghiệm</a></li>
<li><a href='/search/label/review'>Plamo Reviews</a>
<ul class="sub-menu">
<li>No1</li>
<li>No2</li>
</ul>
</li>
<li class='indzign-box' onclick='document.getElementById('indzignbox').style.top='60px';document.getElementById('count-box').style.display='none';'><i class='fa fa-bars' /></li>
</ul>
</nav>
To achieve the behaviour you want, there are two things you should probably change:
You can get rid of the CSS rule that gives your sub-menus li elements a value of display: none as it's unnecessary. If the parent .sub-menu is set to display: none then the children will inherit that automatically.
You've set your .sub-menu to be position: absolute, but you haven't specified any additional CSS rules to indicate where it should go relative to its parent. So, for example, you can try making your .sub-menu rules look like the following:
.sub-menu {
display: none;
position: absolute;
top: 75px;
background: #ccc;
}
This way, you're saying that your menu should be positioned 75 pixels beneath its parent. The background is just so that your sub-menu is visible against the rest of your app (you can modify this to whatever you like, of course).
I don't think Stackoverflow is a place to get your homework done. Yet, here's a working sample with the minimal fixes to make it work.
You were missing the position (top) for the sub-menu and it was right beneath the fixed-nav.
There was no background-color for the sub-menu items, so the text which is white was not visible.
nav.fixnavbar {
position: relative;
display: block;
width: 100%;
background: #778595;
z-index: 99;
padding: 0;
margin-bottom: 0;
font-size: 0;
opacity: 1;
}
.fixednav {
position: relative;
margin: 0 auto;
padding: 0;
max-width: 1010px;
}
.fixednav li {
display: inline-block;
position: relative;
background-color: #6b7684;
}
.fixednav li a {
display: inline-block;
padding: 20px;
color: #fff;
font-size: 14px;
font-weight: 700;
text-transform: uppercase;
}
.fixednav li a:hover {
background: #6c7a89;
color: #fff;
}
.nav-icon {
display: none;
}
nav.fixnavbar.main-nav-scrolled {
position: fixed;
top: 0;
left: 0;
opacity: 0.97;
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
.fixednav li {
position: relative;
}
.sub-menu {
display: none;
position: absolute;
top: 54px;
left: 0;
}
.fixednav li:hover .sub-menu {
display: block;
}
<nav class='fixnavbar'>
<ul class='fixednav' id='togglemenu'>
<li><a href='/'>Home</a></li>
<li><a href='/search/label/list'>List bài viết</a></li>
<li><a href='/search/label/kinh-nghiem'>Kinh nghiệm</a></li>
<li><a href='/search/label/review'>Plamo Reviews</a>
<ul class="sub-menu">
<li>No1</li>
<li>No2</li>
</ul>
</li>
<li class='indzign-box' onclick='document.getElementById('indzignbox').style.top='60px';document.getElementById('count-box').style.display='none';'><i class='fa fa-bars' /></li>
</ul>
</nav>
I am trying to do an icon navbar where on hover the icon also hovers the same colour, I have the icon sort of positioned but at the same time I can't push it to the right or it disappears.
The main goal is pretty much put the icon to the left of the a href with about 3px of padding of the right so it's not touched the text and on the nav menu hover the icon hovers the same colour as the text for each nav item.
HTML
<nav class="fixed-nav-bar">
<div id="menu" class="menu">
<a class="show" href="#menu">Menu</a><a class="hide" href="#hidemenu">Menu</a>
<ul class="menu-items">
<li><div class="fa-icon-home"></div>HOME</li>
<li>ABOUT</li>
<li>DESIGNS</li>
<li>CONTACT</li>
</ul>
</div>
</nav>
CSS:
.fa-icon-home {
background-image: url('../img/home.png');
background-repeat: no-repeat;
height: 22px;
position: relative;
top: 15px;
right: 10px;
}
.fixed-nav-bar {
position: fixed;
width: 100%;
background-color: #3f3f3f;
}
.fixed-nav-bar li, .fixed-nav-bar a {
line-height: 70px;
width: 100px;
max-width: 120px;
}
.menu {
width: 90%;
max-width: 960px;
margin: 0 auto;
text-align: center;
}
.menu a, .menu a:visited {
color: #ffffff;
overflow: hidden;
font-size: 20px;
}
.menu a:hover, .menu a:target {
display: block;
color: #72BCD4;
}
.menu-items {
display: inline-block;
}
.menu-items li {
display: inline-block;
border-top: 2px solid transparent;
}
.menu-items a {
text-decoration: none;
display: block; /* New Line */
}
.menu-items li:hover {
border-top: 2px solid #72BCD4;
}
.show, .hide {
display: none;
padding-left: 15px;
background-color: transparent;
background-repeat: no-repeat;
background-position: center left;
color: #dde1e2;
}
.show {
background-image: url(../assets/down-arrow-icon.png);
}
.hide {
background-image: url(../assets/up-arrow-icon.png);
}
I changed the way the icon is applied, using a:before now.
.menu-items li {
position: relative;
}
.menu-items li:nth-child(1) a:before {
font-family: FontAwesome;
color: white;
content: "\f015";
position: absolute;
top: 0;
left: -.5em;
}
.fixed-nav-bar {
position: fixed;
width: 100%;
background-color: #3f3f3f;
}
.fixed-nav-bar li,
.fixed-nav-bar a {
line-height: 70px;
width: 100px;
max-width: 120px;
}
.menu {
width: 90%;
max-width: 960 px;
margin: 0 auto;
text-align: center;
}
.menu a,
.menu a:visited {
color: #ffffff;
overflow: hidden;
font-size: 20px;
}
.menu a:hover,
.menu a:target {
display: block;
color: #72BCD4;
}
.menu-items li {
display: inline-block;
border-top: 2px solid transparent;
}
.menu-items a {
text-decoration: none;
display: block;
}
.menu-items li:hover {
border-top: 2px solid #72BCD4;
}
.menu-items li:hover a:before {
color: #72BCD4;
}
.show,
.hide {
display: none;
padding-left: 15px;
background-color: transparent;
background-repeat: no-repeat;
background-position: center left;
color: #dde1e2;
}
.show {
background-image: url(../assets/down-arrow-icon.png);
}
.hide {
background-image: url(../assets/up-arrow-icon.png);
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<nav class="fixed-nav-bar">
<div id="menu" class="menu">
<a class="show" href="#menu">Menu</a><a class="hide" href="#hidemenu">Menu</a>
<ul class="menu-items">
<li>HOME</li>
<li>ABOUT</li>
<li>DESIGNS</li>
<li>CONTACT</li>
</ul>
</div>
</nav>
Here, changed a few CSS rules and here you go:
.fixed-nav-bar {
position: fixed;
width: 100%;
background-color: #3f3f3f;
}
.fixed-nav-bar li, .fixed-nav-bar a {
line-height: 70px;
width: 100px;
max-width: 120px;
}
.menu {
width: 90%;
max-width: 960px;
margin: 0 auto;
text-align: center;
}
.menu a, .menu a:visited {
color: #ffffff;
overflow: hidden;
font-size: 20px;
}
.menu a:hover, .menu a:target {
display: block;
color: #72BCD4;
}
.fixed-nav-bar .fa-home:hover {
color: #72BCD4;
}
.menu-items {
display: inline-block;
}
.menu-items li {
display: inline-block;
border-top: 2px solid transparent;
}
.menu-items a {
text-decoration: none;
display: block; /* New Line */
}
.menu-items li:hover {
border-top: 2px solid #72BCD4;
}
.show, .hide {
display: none;
padding-left: 15px;
background-color: transparent;
background-repeat: no-repeat;
background-position: center left;
color: #dde1e2;
}
.show {
background-image: url(../assets/down-arrow-icon.png);
}
.hide {
background-image: url(../assets/up-arrow-icon.png);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<nav class="fixed-nav-bar">
<div id="menu" class="menu">
<a class="show" href="#menu">Menu</a><a class="hide" href="#hidemenu">Menu</a>
<ul class="menu-items">
<li><i class="fa fa-home" aria-hidden="true"></i> HOME</li>
<li>ABOUT</li>
<li>DESIGNS</li>
<li>CONTACT</li>
</ul>
</div>
</nav>
I am trying to add a border-top with 2px on my fixed navbar however on the a href hover it pushes all of the nav items down by 2px, I am trying to make it so it's static, any help is appreciated.
.fixed-nav-bar {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 9999;
width: 100%;
height: 70px;
background-color: #3f3f3f;
}
.fixed-nav-bar li, .fixed-nav-bar a {
height: 0 auto;
line-height: 50px;
width: 100px;
overflow: hidden;
}
.menu {
width: 90%;
max-width: 960px;
margin: 0 auto;
text-align: center;
}
.menu a, .menu a:visited {
color: #ffffff;
overflow: hidden;
}
.menu a:hover, .menu a:target {
display: block;
border-top: 2px solid #72BCD4;
color: #72BCD4;
}
.menu-items { display: inline-block; }
.menu-items li {
display: inline-block;
margin-right: 10px;
margin-left: 10px;
}
.menu-items a {
text-decoration: none;
}
.show, .hide {
display: none;
padding-left: 15px;
background-color: transparent;
background-repeat: no-repeat;
background-position: center left;
color: #dde1e2;
}
.show {
background-image: url(../assets/down-arrow-icon.png);
}
.hide {
background-image: url(../assets/up-arrow-icon.png);
}
<nav class="fixed-nav-bar">
<div id="menu" class="menu">
<!-- Example responsive navigation menu -->
<a class="show" href="#menu">Menu</a><a class="hide" href="#hidemenu">Menu</a>
<ul class="menu-items">
<li>HOME</li>
<li>ABOUT</li>
<li>DESIGNS</li>
<li>CONTACT</li>
</ul>
</div>
</nav>
It's because of no border. Either give a transparent border with the same width or use the colour of the border. But in your case, it's screwed up. So I changed the overflow: hidden and used margin-top: -2px:
.fixed-nav-bar {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 9999;
width: 100%;
height: 70px;
background-color: #3f3f3f;
}
.fixed-nav-bar li, .fixed-nav-bar a {
height: 0 auto;
line-height: 50px;
width: 100px;
}
.menu {
width: 90%;
max-width: 960px;
margin: 0 auto;
text-align: center;
}
.menu a, .menu a:visited {
color: #ffffff;
}
.menu a:hover, .menu a:target {
display: block;
border-top: 2px solid #72BCD4;
color: #72BCD4;
margin-top: -2px;
}
.menu-items {
display: inline-block;
}
.menu-items li {
display: inline-block;
margin-right: 10px;
margin-left: 10px;
}
.menu-items a {
text-decoration: none;
}
.show, .hide {
display: none;
padding-left: 15px;
background-color: transparent;
background-repeat: no-repeat;
background-position: center left;
color: #dde1e2;
}
.show {
background-image: url(../assets/down-arrow-icon.png);
}
.hide {
background-image: url(../assets/up-arrow-icon.png);
}
<nav class="fixed-nav-bar">
<div id="menu" class="menu">
<!-- Example responsive navigation menu -->
<a class="show" href="#menu">Menu</a><a class="hide" href="#hidemenu">Menu</a>
<ul class="menu-items">
<li>HOME</li>
<li>ABOUT</li>
<li>DESIGNS</li>
<li>CONTACT</li>
</ul>
</div>
</nav>
That's all because of box-sizing property. by default it adds value of paddings/margins/borders outside of content area, so element becomes bigger. Just define globally * {box-sizing: border-box;} it will make elements to fixed sizes. That means if element had no border, and then it adds, the element's area for content will be smaller, but the whole size will be the same. However, I strongly recommend you to use border at the beginning, otherwise, it will jump inside the element. You can set the color 'transparent' and it won't be visible. Then just by changing border-color it will be nicer.
I have created a little fiddler:
https://jsfiddle.net/marco_rensch/0hva2241/
this could be a possible solution
checkout CSS Code Changes between row 31 and 51
the key is to add a default border 2px transparent to the li's and change it by hover:
.menu-items li:hover{border-top: 2px solid #72BCD4;}
Here is the deal. I'm trying to create a mobile first navigation bar using css3, html5 and transition properties. I've been successful so far but I am unable to control the transition for when I resize the window (using media queries min-width) from desktop view to mobile view. I've add a Toggle button in the mobile view to create a burger menu that disappears at 600px and vice versa. when the button is unchecked (menu not visible) and I resize the view from desktop to mobile there is a very fast transition that I don't want. I've tried so far so many variants and nothing seems to work. Any suggestion would be greatly appreciated!
* {
margin: 0;
padding: 0;
outline: none;
box-sizing: border-box;
}
body {
background: #eee;
color: #444;
-webkit-font-smoothing: antialiased;
font-family: Arial, sans-serif;
font-weight: 400;
height: auto !important;
height: 100%;
min-height: 100%;
text-rendering: optimizeLegibility;
}
header {
display: block;
background-color: #FFF;
height: inherit;
}
nav {
text-align: center;
line-height: 3.5em;
}
nav ul {
background-color: rgba(255, 255, 255, 0.15);
float: none;
line-height: inherit;
margin: 0;
}
nav ul li {
display: block;
list-style-type: none;
}
nav ul li:hover {
background-color: #ededed;
}
nav ul li a {
text-decoration: none;
color: #313131;
}
nav ul li a:hover {
color: #b9b5b5;
}
#menuToggle {
display: none;
}
.menu {
width: 100%;
position: absolute;
top: 66px;
transition: all 300ms ease-in-out;
}
.menu-icon {
float: right;
color: #2f2f2f;
cursor: pointer;
padding-top: 0.46em;
padding-right: 1em;
padding-left: 1em;
padding-bottom: 0.46em;
text-decoration: none;
font-size: 30px;
}
.menu {
max-height: 0;
transition-property: max-height 0s ease-in-out;
overflow: hidden;
}
#menuToggle:checked ~ header .menu {
max-height: 300px;
transition-property: all 0.6s ease-in-out;
}
#logo {
float: none;
text-align: left;
padding-top: 7px;
padding-left: 2em;
height: inherit;
}
/*------------ MEDIUM BIG SCREEN -----------------------*/
#media screen and (min-width:600px) {
#logo {
float: left;
}
.menu {
position: relative;
top: -70px;
height: 100%;
max-height: 100%;
transition-property: none;
}
.menu-icon {
display: none;
}
header {
height: 70px;
background-color: #FFF;
margin: auto;
width: 100%;
}
nav {
width: 100%;
}
nav ul {
background-color: #FFF;
display: block;
float: right;
padding: 0.55em 2em 0 0;
height: inherit;
}
nav ul li {
display: inline-flex;
}
nav ul li:hover {
background-color: #FFF;
}
nav ul li a {
padding: 0 2em;
}
<!-- === MENUTOGGLE === -->
<input type="checkbox" name="checkbox" id="menuToggle" value="value">
<label for="menuToggle" class="menu-icon">☰</label>
<!-- ==== HEADER ==== -->
<header class="header">
<div id="logo">
<h1><img src="images/logo.png" alt="Hello"></h1>
</div>
<nav class="menu">
<ul>
<li>Work</li>
<li>About</li>
<li>Blog </li>
<li>Contact</li>
</ul>
</nav>
</header>
Put everything you only want to happen on the small screen inside:
#media screen and (max-width:599px) {
}
And everything you only want to happen on the large screen inside your:
#media screen and (min-width:600px) {
}
Is there a particular way to make a <ul> a height? I have this structure:
<ul class="dropdown">
<li></li>
<li></li>
<li></li>
<li>
<ul id="sub_menu1"> // I have 4 of these
<li></li>
<li></li>
</ul>
</li>
</ul>
CSS:
ul.dropdown {
font-family: 'CapsuulaRegular', Arial, sans-serif;
position: relative;
padding: 0;
margin: 0;
z-index: 1;
}
ul.dropdown li a {
color: #b38201;
font-size: 18px;
}
ul.dropdown li {
display: block;
float: left;
color: #b38201;
font-weight: normal;
text-transform: uppercase;
padding: 38px 10px 12px 7px;
margin-left: 2px;
}
ul.dropdown a:hover {
color: #002565;
background-image: url(../images/menu-hover.png);
background-position: 50% 100%;
background-repeat: no-repeat;
}
.navSelected {
color: #002565;
background-image: url(../images/menu-hover.png);
background-position: 50% 100%;
padding:0;
margin:0;
background-repeat: no-repeat;
}
ul.dropdown a:active {
color: #ffa500;
}
ul.dropdown li a {
padding: 38px 7px 12px 7px;
}
ul.dropdown li:last-child a {
border-right: none;
}
/* Doesn't work in IE */
ul.dropdown li.hover, ul.dropdown li:hover {
color: black;
position: relative;
}
ul.dropdown li.hover a {
color: black;
}
/* LEVEL TWO */
#sub_menu1 {
width: 175px;
position: absolute;
left: -175px;
}
#sub_menu2 {
width: 175px;
position: absolute;
left: 0px;
}
#sub_menu3 {
width: 175px;
position: absolute;
left: 175px;
}
#sub_menu4 {
width: 175px;
position: absolute;
left: 200px;
}
ul.dropdown ul {
visibility: hidden;
position: relative;
top: 100%;
left: 0px;
font-size: 10px !important;
padding: 0;
margin: 0;
display: block;
}
ul.dropdown ul li {
background: #ccc;
}
ul.dropdown ul li {
font-weight: normal;
background: #f1f3f7;
color: #000;
/*border-bottom: 1px solid #ccc;*/
float: none;
padding: 10px;
margin: 0;
text-transform: none;
}
I having trouble making the <ul> that are hovered the same height. The go depending on what content is in them.
I want all the menus to be the same height, or within a wrapper of fixed height/width..
does this solve your question?
ul { height: 150px; }
if you apply this, all of your ul's will have the height of 150 pixels.
Edit
Well, you're using floating. Floating elements are ignored in the flow of the document. To overcome this problem you should add a overflow: hidden; to your ul.dropdown