Here is the fiddle, this is a vertical menu, floated to right. I have to use percent values (to have responsive design) but then the last menu goes underline. If I set it with "px" it works.
http://jsfiddle.net/aDRnn/
#topmenu
{
margin-top: 20px;
min-height: 47px;
background-color: red;
border-radius: 25px;
float: right;
}
#topmenu ul
{
list-style-type: none;
margin: 0 0 0 0;
padding: 13px 0 0 0;
color: #fff;
font-size: 1.6em;
}
#topmenu ul li
{
display: inline;
padding: 15px 2.5% 17px 2.5%; /* when its set with percents, it screwes */
margin: 0 0 0 0;
}
#topmenu ul li:last-child
{
border: none;
box-shadow: none;
}
#topmenu ul li:first-child
{
border-top-left-radius: 15px;
}
#topmenu ul li img
{
vertical-align: middle;
}
#topmenu a
{
color: #fff;
text-decoration: none;
height: 54px;
}
<div id="topmenu"><ul>
<li class="">
<a href="tanar">
Nyitólap</a>
</li>
<li class="">
<a href="diak">
Rólunk</a>
</li>
<li class="">
<a href="szulo">
Szállodák</a>
</li>
<li class="">
<a href="nyelviskola">
Apartmanok</a>
</li>
<li class="">
<a href="boltok">
Gourmentteszt</a>
</li>
</ul>
<div style="clear:both;"></div></div>
You have a float:right on the #topmenu, but you need a float:left to his children "ul". Also, if you want to have "li" paddings and margins, you need to also float them left.
Related
I'm new in HTML and CSS.
Want to create menu with image and also want to show menu separator, menu should be horizontally aligned.
when we hover mouse on menu item, image and text color should change.
It should be look like as per image.
sry I forgot to upload the code, uploading here.
but now I want to show some menu items on left side( left align) and others on right side( right align)
.mainmenu{
background-color: black;
}
.mainmenu {
margin-top: 20px;
display: inline-block;
position: relative;
width: 100%;
}
.mainmenu li a {
display: block;
position: relative;
text-decoration: none;
text-align: center;
font-size: 10px;
color: gray;
line-height: 32px;
font-weight: bold;
text-shadow: black 0 1px 0;
font-family: sans-serif;
border-right: 1px solid #030304;
border-left: 1px solid #36393C;
white-space: nowrap;
}
.mainmenu ul.menu {
margin: 0;
width: 100%;
}
.mainmenu ul.menu li {
float: left;
list-style: none;
width: 16.666666666666668%;
}
.mainmenu ul.menu li a:hover {
color: #76b900;
}
img {
border: 0;
vertical-align: middle;
max-width: 100%;
}
<div>
<div class="mainmenu ">
<ul class="menu">
<li>
<a href="#">
<img src="images/nav-icons/home.png">HOME</a>
</li>
<li>
<a href="#">
<img src="images/nav-icons/users.png">
USERS
</a>
</li>
<li>
<a href="#">
<img src="images/nav-icons/gallary.png">
GALLARY
<a/>
</li>
<li>
<a href="#">
<img src="images/nav-icons/community.png">
COMMUNITY
</a>
</li>
</ul>
</div>
Thanks
ul.menu {
list-style-type: none;
}
ul.menu li {
padding: 5px;
font-size: 16px;
font-family: "Trebuchet MS", Arial, sans-serif;
}
ul.menu li a {
height: 50px;
line-height: 50px;
display: inline-block;
padding-left: 60px;
/* To sift text off the background-image */
color: #3E789F;
background: url("../images/mySprite.png") no-repeat;
/* As all link share the same background-image */
}
ul.menu li.firefox a {
background-position: 0 0;
}
ul.menu li.chrome a {
background-position: 0 -100px;
}
ul.menu li.ie a {
background-position: 0 -200px;
}
ul.menu li.safari a {
background-position: 0 -300px;
}
ul.menu li.opera a {
background-position: 0 -400px;
}
<ul class="menu">
<li class="firefox">Firefox
</li>
<li class="chrome">Chrome
</li>
<li class="ie">Explorer
</li>
<li class="opera">Opera
</li>
<li class="safari">Safari
</li>
</ul>
I have on main Menu that works totally fine without child menu items.
But now i have to add additional items and wanted to do a drop down Menu.
The Menu item "Services" is parent of "test" there should be a clean line, but when opening "Services" the border of the whole menu expands with "test" there should only be a small border the same length as "Services" surrounding "test".
For this to work i have to edit "current active deeper parent" or "nav-child unstyled small" if i'm correctly.
If possible you should even only need to hover over "Services" to trigger the dropdown menu.
.flowmenu {
background: none repeat scroll 0 0 #333333;
padding-left: 0px;
position: relative;
}
.flowmenu li {
display: inline-block;
list-style: none outside none;
padding: 0;
}
.flowmenu ul li {
position: relative;
}
.flowmenu li > a {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border-color: #000000;
border-style: solid;
border-width: 0 1px 0 0;
box-shadow: 1px 0 0 0 #555555;
margin-bottom: 0;
padding: 5px 15px;
text-transform: uppercase;
color: #FFFFFF;
cursor: pointer;
display: block;
font-family: 'Corbel', sans-serif;
font-size: 12px;
font-weight: normal;
line-height: 30px;
text-decoration: none;
}
.flowmenu li.active {
background: #222222;
}
<div class="navfix">
<ul class="nav menu flowmenu li">
<li class="item-435">Home
</li>
<li class="item-485">Communication
</li>
<li class="item-486 current active deeper parent">Services
<ul class="nav-child unstyled small">
<li class="item-579">Test
</li>
</ul>
</li>
<li class="item-487">Languages
</li>
<li class="item-488">Network
</li>
</ul>
</div>
The parent list item of the <ul> has to be position relative if you want a dropdown menu
the <ul> it self can be position absolute so it appears nicely under the parent. I made a jsFIDDLE
Most important changes:
.flowmenu > li {
position:relative;
display: inline-block;
list-style: none outside none;
padding: 0;
}
.flowmenu ul {
position: absolute;
display:block; /* or none */
width:100%;
background: #222222;
list-style:none;
margin:0;
padding:0;
}
Hope this helps! I didn't completly styled the dropdown maybe it's better to do that yourself
.flowmenu {
background: none repeat scroll 0 0 #333333;
padding-left: 0px;
position: relative;
}
.flowmenu > li {
position: relative;
display: inline-block;
list-style: none outside none;
padding: 0;
}
.flowmenu ul {
position: absolute;
display: none;
width: 100%;
background: #222222;
list-style: none;
margin: 0;
padding: 0;
}
.flowmenu ul > li {
display: block;
}
.flowmenu li > a {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border-color: #000000;
border-style: solid;
border-width: 0 1px 0 0;
box-shadow: 1px 0 0 0 #555555;
margin-bottom: 0;
padding: 5px 15px;
text-transform: uppercase;
color: #FFFFFF;
cursor: pointer;
display: block;
font-family: 'Corbel', sans-serif;
font-size: 12px;
font-weight: normal;
line-height: 30px;
text-decoration: none;
}
.flowmenu > li.active {
background: #222222;
}
.flowmenu > li:hover ul {
display: block;
}
<div class="navfix">
<ul class="nav menu flowmenu li">
<li class="item-435">Home
</li>
<li class="item-485">Communication
</li>
<li class="item-486 current active deeper parent">Services
<ul class="nav-child unstyled small">
<li class="item-579">Test
</li>
</ul>
</li>
<li class="item-487">Languages
</li>
<li class="item-488">Network
</li>
</ul>
</div>
so basically I've got this code: HTML and CSS below, using bootstrap as well, and for some reason, it's not centred. It used to be, but at some point it wasn't anymore, now it pulls to the left. See image below. Any ideas?
<div class="row" id="nav-bar">
<div class="col-md-9">
<ul>
<li class="col-md-3 nav-btn" id="home">Home</li>
<li class="col-md-3 nav-btn" id="about">About</li>
<li class="col-md-3 nav-btn dropdown-toggle" id="games">
Games & Apps ▼
<div class="dropdown">
<ul>
<li>Games & Apps ▼</li>
<li id="first">Space Rodeo</li>
<li id="spaced">Boodya's Carpet Ride</li>
<li id="spaced">Ultimate Points Counter</li>
</ul>
</div>
</li>
<li class="col-md-3 nav-btn" id="blog">Blog</li>
</ul>
</div>
</div>
#nav-bar {
margin: 0px 0px 10px 0px;
height: 60px;
}
#nav-bar ul {
margin-top: 20px;
}
.col-md-3 a {
padding: 15px 40px 15px 40px;
font-size: 20px;
text-decoration: none;
text-align: center;
color: #B6B6B6;
}
#nav-bar a:hover {
color: #428bca;
}
.col-md-3 {
display: inline;
}
.col-md-9 {
float: none;
margin: auto;
left: 0;
right: 0;
}
.dropdown {
padding: 0;
margin-top: -48px;
position: absolute;
z-index: 10;
background-color: #ffffff;
box-shadow: -5px -5px 20px;
border-radius: 5px;
height: 210px;
width: 275px;
}
.dropdown ul {
padding: 0;
margin-top: 0;
}
.dropdown li {
list-style: none;
padding: 0;
width: 310px;
}
#games2 {
color: #428bca;
}
#spaced {
margin-top: 10px;
}
#first {
padding-top: 20px;
border-top: 1px solid black;
margin-top: 22px;
}
Showing result of code, the navbar is off centre
http://i.stack.imgur.com/smtTP.png
Your list items are display: inline which means they'll follow the alignment rules of text. Since you set no text-align, it defaults to the left. You can fix that by adding text-align: center to your ul so the contents will be centered.
Now the insides of the dropdown will also inherit that, you can reset that by setting text-align: left back on the dropdown ul again.
Also reset the left padding that ul has by default.
#nav-bar ul {
padding-left: 0;
text-align: center;
}
#nav-bar .dropdown ul {
text-align: left;
}
Works in this jsFiddle
I'm trying to get the dropdown menu to not expand the first-level ul on hover and display the items below but without setting a fixed width. Any ideas? Currently, the only nav item that has a menu is the 'Configure' tab.
nav ul {
padding: 0px;
margin: 0px;
list-style: none;
position: relative;
display: block;
font-family: 'Trebuchet MS', Helvetica, sans-serif;
font-size: 14px;
height: 25px;
}
nav ul:after {
content: "";
clear: both;
display: block;
}
nav ul ul {
display: none;
position: absolute;
}
nav ul li {
float: left;
cursor: pointer;
border-left: solid 1px #AAD6EA;
height: 25px;
position: relative;
}
nav ul li div {
margin-top: 5px;
margin-left: 10px;
margin-right: 10px;
height: 100%;
padding: 0px;
float: left;
}
nav ul li:hover {
background-color: #AAD6EA;
color: #FFFFFF;
}
nav ul li:hover>ul {
display: block;
position: relative;
z-index: 1;
list-style-type: none;
padding: 0;
margin: 0;
}
nav ul ul li {
background-color: #AAD6EA;
border-bottom: solid 1px #0085C3;
width: 100%;
/* float: none; */
}
nav ul ul li:hover {
color: #0085c3;
}
<div style="height: 100%; float: right; margin: 0; padding: 0; ">
<nav>
<ul>
<li>
<img src="img/help.png" id="vulcanUIHelp" style="margin-top: 5px; margin-right: 10px; margin-left: 10px;" alt="" width="16" height="16" title="Get UI help" />
</li>
<li>
<div id="configure">Configure</div>
<ul>
<li>
<div id="confmbpolicy">Middlebox Policy</div>
</li>
<li>
<div>Middlebox</div>
</li>
</ul>
</li>
<li>
<div id="settingsButton" title="Change system settings">Change Settings</div>
</li>
<li>
<div id="optionsLink" title="Open or close options window">Options</div>
</li>
<li>
<div id="help" title="Interactvely build a query">Build Query</div>
</li>
<li style="border-right: 0;">
<div id="logoutButton" title="Logout and close this window">Logout</div>
</li>
</ul>
</nav>
</div>
I've put the code I'm working on in a fiddle here: http://jsfiddle.net/aPbV4/
Thank you! All your help is appreciated!
how about ( as parent <li> is relative )
nav ul li:hover > ul {
display: block;
position: absolute;
top:25px;
left:0;
}
http://jsfiddle.net/aPbV4/3/
I am trying to implement a:hover effect as in attached image.But i have missed something it is not working .can you please correct me.
HTML code:
<ul class="short-by-list">
<li class="right-mrgn">Make</li>
<li>
<a onclick="ajaxSearchLoad(5,49)" href="javascript:void(0)">
<img class="SortPosition" alt="ascending" src="../images/nav-arrow.png">
</a>
<div class="tooltip-text" style="display: none;">
<img class="tooltip-arrow" alt="Arrow" src="../images/tooltip-arrow.png">
Sort by Ascending
</div>
</li>
<li class="last">
</ul>
CSS:
.short-by-list {
background: url("../images/short-bg.png") no-repeat scroll 0 0 transparent;
float: left;
height: 21px;
margin: 0 6px 15px 0;
padding: 0 6px 0 10px;
width: 79px;
}
.short-by-list li {
color: #FFFFFF;
display: block;
float: left;
line-height: 21px;
position: relative;
}
.short-by-list li .tooltip-text {
left: -38px;
}
.short-by-list li.last .tooltip-text {
left: -40px;
}
.short-by-list li.right-mrgn {
margin-right: 9px;
min-width: 29px;
}
.short-by-list li a {
display: block;
float: left;
padding: 0 6px;
text-decoration: none;
}
.short-by-list li:hover a, .short-by-list li.select a {
background: url("../images/bg-hover.png") repeat-x scroll 0 0 transparent;
}
.short-by-list li.select .tooltip-text {
display: block !important;
}
In .short-by-list li, try adding height:21px;
I am suspecting that it is because the inner <img> element has been floated, therefore the height of the <a> element collapses. Try setting overflow: hidden for <a>.
If it all fails, set an explicit height for <a>.