How to make navbar tab fill up upon hover in IE? - html

So I have successfully done this in Chrome, as well as for Firefox. Today I realized why not try it in IE! Well, looks like IE doesn't exactly want to work the same...
Does anyone know how I can do this a different way to make it also work for IE?
HTML:
<div id="navbar">
<div id="navlinks">
<nav>
<ul id="navlist">
<li>HOME</li>
<li>ASSIGNMENTS</li>
<li>DREAM CARS</li>
<li>PROJECTS</li>
<li>CONTACT</li>
</ul>
</nav>
</div>
</div>
CSS:
body{
margin:0 auto;
}
#logo{
margin:auto;
width:430px;
}
#navbar{
width:100%;
height:50px;
display:table;
margin:auto;
}
#navlinks ul {
display:table;
border-collapse:collapse;
width:100%;
margin:0 0 20px;
padding:0;
list-style:none;
}
#navlinks li {
display: table-cell;
vertical-align: middle;
text-align:center;
width:20%;
background: linear-gradient(to right, #111 50%, #444 50%);
background-size: 200% 100%;
background-position:left top;
transition:all 1s ease;
}
#navlinks li:hover{
background-position:right top;
}
#navlinks a {
text-decoration:none;
color: #999;
text-transform: uppercase;
display:block;
padding-top:10px;
padding-bottom:10px;
font: bold 12px/25px Arial, Helvetica;
transition:color 1s ease-in-out;
}
#navlinks li:hover a{
color:black;
}
Demo in JSFiddle

Related

List hover not activating

I'm trying to get a menu to appear when hovering over the image, but for some reason it's not appearing. (I'm making it mobile adaptive so the navigation links appear in a hover menu when the browser window is smaller)
Can someone help me figure out why the css rule 'ul.nav-menu:hover' hover isn't working?
#header-nav-menu{
display:hidden;
width:44px;
height:31px;
background:url(https://animalcorner.co.uk/wp-content/uploads/2015/02/elephant-1-720x422.jpg) no-repeat;
margin-left:50px;
}
#header-nav-menu a:hover{
border-radius:4px 4px 0 0;
}
ul.nav-menu{
list-style-type:none;
margin-left: 50px;
font-size:20px;
font-family: Montserrat, Helvetica, Arial, sans-serif;
font-weight:100;
color:#373436;
padding:0;
margin:0 0 0 0;
text-decoration:none;
}
ul.nav-menu li{
display:inline-block;
margin-left:50px;
}
ul.nav-menu a:link{
color:#373436;
text-decoration:none;
}
ul.nav-menu a:visited{
color:#373436;
text-decoration:none;
}
ul.nav-menu a:hover{
color:#2778BA;
}
/* BELOW ADAPTS WITH SMALLER BROWSER WINDOW */
#media (max-width: 960px) {
ul.nav-menu, ul.nav-menu:active{
display:none;
z-index:999999999999999999999999999999999999;
position:absolute;
border:1px solid #f0f;
border-radius: 2px 0 2px 2px;
}
#header-nav-menu{
display:inline-block;
}
/* BELOW NOT WORKING */
ul.nav-menu:hover{
display:block;
}
}
<nav>
<ul class="nav-menu">
<li>Services</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
When you hover #header-nav-menu, you want the .nav-menu that comes after it to display. This will do it.
#header-nav-menu{
display:hidden;
width:44px;
height:31px;
background:url(https://animalcorner.co.uk/wp-content/uploads/2015/02/elephant-1-720x422.jpg) no-repeat;
margin-left:50px;
}
#header-nav-menu a:hover{
border-radius:4px 4px 0 0;
}
ul.nav-menu{
list-style-type:none;
margin-left: 50px;
font-size:20px;
font-family: Montserrat, Helvetica, Arial, sans-serif;
font-weight:100;
color:#373436;
padding:0;
margin:0 0 0 0;
text-decoration:none;
}
ul.nav-menu li{
display:inline-block;
margin-left:50px;
}
ul.nav-menu a:link{
color:#373436;
text-decoration:none;
}
ul.nav-menu a:visited{
color:#373436;
text-decoration:none;
}
ul.nav-menu a:hover{
color:#2778BA;
}
/* BELOW ADAPTS WITH SMALLER BROWSER WINDOW */
#media (max-width: 960px) {
ul.nav-menu, ul.nav-menu:active{
display:none;
z-index:999999999999999999999999999999999999;
position:absolute;
border:1px solid #f0f;
border-radius: 2px 0 2px 2px;
}
#header-nav-menu{
display:inline-block;
}
/* BELOW NOT WORKING */
ul.nav-menu:hover{
display:block;
}
}
.wrap {
display: inline-block;
}
.wrap:hover .nav-menu {
display: block;
}
<nav>
<div class="wrap">
<ul class="nav-menu">
<li>Services</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
</nav>
I would say you want to nav:hover ul { display: block; } so if your mouse is over the <nav> then the menu is visible. Then it's is better possible to click on a menu item.
#header-nav-menu{
display:hidden;
width:44px;
height:31px;
background:url(https://animalcorner.co.uk/wp-content/uploads/2015/02/elephant-1-720x422.jpg) no-repeat;
margin-left:50px;
}
#header-nav-menu a:hover{
border-radius:4px 4px 0 0;
}
ul.nav-menu{
list-style-type:none;
margin-left: 50px;
font-size:20px;
font-family: Montserrat, Helvetica, Arial, sans-serif;
font-weight:100;
color:#373436;
padding:0;
margin:0 0 0 0;
text-decoration:none;
}
ul.nav-menu li{
display:inline-block;
margin-left:50px;
}
ul.nav-menu a:link{
color:#373436;
text-decoration:none;
}
ul.nav-menu a:visited{
color:#373436;
text-decoration:none;
}
ul.nav-menu a:hover{
color:#2778BA;
}
/* BELOW ADAPTS WITH SMALLER BROWSER WINDOW */
#media (max-width: 960px) {
ul.nav-menu, ul.nav-menu:active{
display:none;
z-index:999999999999999999999999999999999999;
position:absolute;
border:1px solid #f0f;
border-radius: 2px 0 2px 2px;
}
#header-nav-menu{
display:inline-block;
}
/* BELOW NOW WORKING */
nav:hover ul{
display:block;
}
<nav>
<ul class="nav-menu">
<li>Services</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>

Dropdown menu working differently in Firefox

I have a dropdown menu which works exactly as expected in Chrome.
The dropdown list is with position absolute, and the parent with position relative. However, it seems to render differently in Firefox. The dropped menu appears to be relative to the ul element rather than the li element
This dropdown is activated using javascript, adding a display:block on click
Any ideas why?
I did not use a table.
Fiddle
http://jsfiddle.net/eyJ8e/1/
HTML
<div id="menubar">
<div class="container">
<ul class="menu-container title" style="float:left;">
<li>NEW
</li>
<li class="dropdown"> <a class="click-dropdown" href="#">MEN</a><span class="caret"></span>
<ul class="dropdown-menu" style="display:block"> <li>Jeans</li>
<li>Pants</li>
<li>Shirts</li>
<li>Shorts</li>
<li>Tees</li>
</ul>
</li>
</ul>
</div>
</div>
CSS
body
{
width: 100%;
margin: 0px;
padding: 0px;
font-family: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif;
font-size: 10pt;
/* background-color: #f0f0f0; */
}
.title{
/*font-family: Impact, Charcoal, sans-serif;*/
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
text-transform: uppercase;
font-family: SourceSans Pro Bold;
}
.container{
width:1024px;
margin:0 auto;
}
a, a:active, a:visited
{
color: #000000;
text-decoration: none;
outline: none;
}
a:hover
{
text-decoration: none;
}
#menubar {
width:100%;
min-width:1000px;
height:75px;
background-color:#000;
line-height: 75px;
color:white;
}
#menubar .brand{
display: block;
height:75px;
width: 120px;
margin-right:30px;
margin-top:3px;
float:left;
color:white!important;
}
#menubar .menu-container{
list-style:none;
margin:0px;
}
#menubar .menu-container li:first{
border-left: 1px solid grey;
}
#menubar .menu-container li{
position:relative;
display:inline;
padding:0px 15px;
font-size: 14px;
text-transform: uppercase;
border-right: 1px solid grey;
height:75px;
}
#menubar .menu-container > li.shopping-bag-wrapper:hover{
text-decoration: none;
}
#menubar .menu-container li.shopping-bag-wrapper{
border-right:none;
padding-right:0px;
}
#menubar .authentication-fb-form{
display:inline;
}
#menubar .menu-container li a{
color: white!important;
}
#menubar .menu-container li:last-child{
border:none;
}
#menubar .menu-container .dropdown ul.dropdown-menu > li:hover{
background-color:#555555;
}
#menubar .menu-container ul.dropdown-menu{
border:none;
position:absolute;
z-index:1000;
background-color:black;
display:none;
margin-top:-20px;
}
#menubar .menu-container .dropdown-menu li{
display:block;
min-width:150px;
max-width: 250px;
height:auto;
}
#menubar .menu-container .dropdown-menu a{
display:block;
line-height:25px;
padding: 5px 0px;
height:auto;
border: 2px solid white;
border-bottom:0px;
}
#menubar .menu-container .dropdown-menu a:last-child{
border: 2px solid white;
}
ul{
list-style: none;
margin:0px;
padding:0px;
}
.inline-block{
display: inline-block;
}
.pull-right{
float:right!important;
}
.caret{
display: inline-block;
width: 0;
height: 0;
margin-left: 2px;
vertical-align: middle;
border-top: 4px solid;
border-right: 4px solid transparent;
border-left: 4px solid transparent;
}
There are a couple of issues here. Firstly, you are nesting <li>'s within <a>'s which is invalid. You need to fix this:
<ul class="dropdown-menu">
<li>Jeans</li>
<li>Pants</li>
<li>Shirts</li>
<li>Shorts</li>
<li>Tees</li>
</ul>
secondly, you arent actually giving your nested <ul> a left position which FF seems to need:
#menubar .menu-container ul.dropdown-menu{
left: 0;
}
You will then also need to move your border from the <a> to the <li> to keep the styling that you had before making these changes.
DEMO
just put left:0 in #menubar
.menu-container ul.dropdown-menu{left:0}
refer http://jsfiddle.net/aashi/eyJ8e/8/
For a drop down menu you may check this demo link :
The html part:
<ul class="menubar">
<li>NEW</li>
<li>MENU
<ul class="dropmenu">
<li>JEANS</li>
<li>PANTS</li>
<li>SHIRTS</li>
<li>SHORTS</li>
<li>TEES</li>
</ul>
</li>
</ul>
the CSS part:
*{ margin:0; padding:0;}
ul.menubar{
margin:0 auto;
width:100%;
background:#000;
height:40px;
display:block;
}
ul.menubar li{
list-style-type:none;
display:inline-block;
float:left;
position:relative;
}
ul.menubar li a{
display:block;
text-decoration:none;
color:#fff;
padding:10px;
}
ul.menubar li ul.dropmenu{
position:absolute;
width:120px;
padding:10px 10px 10px 0;
display:none;
}
ul.menubar li:hover ul.dropmenu{
display:block;
top:30px;
}
ul.menubar li:hover ul.dropmenu li{
background:#222;
width:100%;
}
ul.menubar li:hover ul.dropmenu li a:hover{
background:#333;
}
Here is the JS fiddle:
http://jsfiddle.net/ameysawant/LPdqV/1/

Border radius on rounded images? (Links)

Am having a struggle finding a working solution to solve the invisible padding on image tabs that are rounded.
I have tried using border radius on the a tags, including the div but nothing works.
JSFiddle
Also, if anyone can help me figure out how to vertical align the images... That'd be highly appreciated.
HTML:
<div class="linksbar">
<div class="logo"><img src="images/logo2.png"></div>
<div class="logo2"><img src="images/logo.png"></div>
<div class="tabs">
<nav><ul style="min-width:90%;">
<li><img src="images/b_home.png"></li>
<li><img src="images/g_portfolio.png"></li>
<li><img src="images/g_grades.png"></li>
<li><img src="images/g_school.png"></li>
</ul></nav>
</div>
</div>
CSS:
body{
margin:0 !important;
overflow-y: scroll;
}
h2, h3, h4{
margin: 0;
}
.okbar{
width:100%;
background-color:black;
color:black;
height:25px;
min-width:90%;
}
.okbarlinks li{
list-style-type:none;
display:inline;
padding:0px 10px 0px 10px;
float:right;
}
.okbarul {
padding:3px;
}
.okbarlinks a{
font-weight:bold;
font-family:Arial, Helvetica, sans-serif;
font-size:15px;
text-decoration:none;
color:#8a8a8a;
padding:0px;
transition:all 1s ease;
-webkit-transition-delay:all .5s ease;
-moz-transition-delay:all .5s ease;
-ms-transition-delay:all .5s ease;
-o-transition-delay:all .5s ease;
position:static;
}
.okbarlinks a:hover{
color:#454545;
}
.whitestrip{
width:100%;
height:1px;
background-color:white;
color:white;
text-align:center;
}
.linksbar{
background: url('images/blacktabbar.jpg');
background-color:black;
width:100%;
height:102px;
}
.logo{
height:102px;
margin-left:5%;
width:68px;
background-repeat:no-repeat;
vertical-align:middle;
background-position: center center;
float:left;
display:block;
border-radius:15px;
}
.logo2{
height:102px;
width:200px;
padding-left:30px;
background-repeat:no-repeat;
vertical-align:middle;
background-position: center;
float:left;
display:block;
border-radius:15px;
}
.bluebody{
background: url('images/bluebar.jpg');
width:100%;
height:200px;
margin-top:1px;
padding:0;
}
.tabs ul{
margin:0;
}
.tabs li{
list-style-type:none;
display:inline;
min-width:90%;
}
.tabs a{
margin-left:10px;
text-decoration:none;
}
.tabs{
position:absolute;
text-align:center;
width:100%;
}
.bluebodyheaderfont{
font-size:22px;
font-family:'Helvetica Neue', Helvetica, Arial, 'lucida grande',tahoma,verdana,arial,sans-serif;
}

issue with centering nav horizontally in UL

It seems the list items are stuck on the left side of the UL no matter what size I make it. It looks centered on some screens but not on larger ones. Float:right has been the only thing that works for my screen size, but it doesn't stay centered if you resize the window.
Site: http://www.lotusroomofboca.com/
HTML:
<div id="header">
<img id="logo" src="images/logo.png" alt="Lotus Room logo">
<ul id="nav">
<li>Home</li>
<li>Our Tea</li>
<li>Menu</li>
<li>Learn More</li>
<li>Contact</li>
</ul>
</div>
CSS:
#header {position:fixed;
width:100%;
background-color:rgba(244,243,243,1);
z-index:100;
-webkit-box-shadow: 0px 10px 60px 0px rgba(219,219,216,0.94);
-moz-box-shadow: 0px 10px 60px 0px rgba(219,219,216,0.94);
box-shadow: 0px 10px 60px 0px rgba(219,219,216,0.94);
}
#nav {list-style:none;
margin:auto;
text-align:center;
width:960px;
padding-top:30px;
padding-bottom:20px;
float:right;}
#nav a {text-decoration:none;
text-align:center;
display:block;
color:#5c5c5c;
font-family:'Avenir';
font-size:12px;
border-right:thin grey solid;
float:left;
width:10%;
}
#nav li:last-child a {border-right:none;}
#nav a:hover {color:#7b8c6f;
transition:ease 0.5s;}
Here's a FIDDLE
Use this config for <ul>
<ul id="nav">
<li>Home
</li><li>Our Tea
</li><li>Menu
</li><li>Learn More
</li><li>Contact
</li>
</ul>
and this css
#nav li {
text-align:center;
display:inline-block;
color:#5c5c5c;
font-family:'Avenir';
font-size:12px;
border-right:thin grey solid;
width:10%;
}
#nav li:last-child {
border-right: none;
}
#nav li a {
text-decoration: none;
color: #000;
transition: color 0.5s ease;
-moz-transition: color 0.5s ease;
-webkit-transition: color 0.5s ease;
}
#nav li a:hover {
color:#7b8c6f;
}
first try adding
#nav a {
margin: 0 auto;
}
#nav a {
display: inline-block; //instead of block
float: left; //remove this too
}

How to center the following menu?

I've got the following inside a div. I'd like to center the menu elements. Currently they appear like so...
| Home | Blog | About | Contact |
I'd like it to center so something like...
| Home | Blog | About | Contact |
Here's my CSS, what would I need to change?
ul#menu
{
margin:0;
padding:0;
list-style-type:none;
width:auto;
position:relative;
display:block;
height:30px;
font-size:12px;
font-weight:bold;
background:transparent url(images/nav_bg.png) repeat-x top left;
font-family:Arial, Helvetica, sans-serif;
border-bottom:1px solid #000000;
border-top:1px solid #000000;
}
ul#menu li
{
display:block;
float:left;
margin:0;
padding:0;
}
ul#menu li a
{
display:block;
float:left;
color:#999999;
text-decoration:none;
font-weight:bold;
padding:8px 20px 0 20px;
}
ul#menu li a:hover
{
color:#FFFFFF;
height:22px;
background:transparent url(images/nav_bg.png) 0px -30px no-repeat;
}
ul#menu li a.current
{
display:inline;
height:22px;
background:transparent url(images/nav_bg.png) 0px -30px no-repeat;
float:left;
margin:0;
}
To center your menu, give your menu a width and use:
maring:0 auto;
The final result is something like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
<style>
.menu
{
width:270px;
margin:0 auto;
}
ul#menu
{
margin: 0;
padding: 0;
list-style-type: none;
width: auto;
position: relative;
display: block;
height: 30px;
font-size: 12px;
font-weight: bold;
background: transparent url(images/nav_bg.png) repeat-x top left;
font-family: Arial, Helvetica, sans-serif;
border-bottom: 1px solid #000000;
border-top: 1px solid #000000;
}
ul#menu li
{
display: block;
float: left;
margin: 0;
padding: 0;
width:60px;
text-align:center;
}
ul#menu li.divider
{
width:5px;
}
ul#menu li a
{
display: block;
float: left;
color: #999999;
text-decoration: none;
font-weight: bold;
padding: 8px 20px 0 20px;
}
ul#menu li a:hover
{
color: #FFFFFF;
height: 22px;
background: transparent url(images/nav_bg.png) 0px -30px no-repeat;
}
ul#menu li a.current
{
display: inline;
height: 22px;
background: transparent url(images/nav_bg.png) 0px -30px no-repeat;
float: left;
margin: 0;
}
</style>
</head>
<body>
<div class="menu">
<ul id="menu">
<li class="divider">|</li>
<li>Home</li>
<li class="divider">|</li>
<li>Blog </li>
<li class="divider">|</li>
<li>About </li>
<li class="divider">|</li>
<li>Contact</li>
<li class="divider">|</li>
</ul>
</div>
</body>
</html>
Update:
If you didn't want to use pipes in the divider, you could always use:
ul#menu li.divider
{
width:2px;
background-color:Black;
}
instead which will give a similar look and make screen readers not blow up at you.
I think you're looking for something like this: http://jsfiddle.net/sp45g/
div { // Container around the UL
text-align: center;
background-color: blue;
}
ul { // Inline block to shrink-wrap to contents
display: inline-block;
background-color: red;
}
li { // Inline to display in a row
display: inline;
}​
I cleaned it up a little bit...
ul#menu{
margin:0;
padding:0;
list-style-type:none;
display:block;
height:30px;
font-size:12px;
font-weight:bold;
font-family:Arial, Helvetica, sans-serif;
border-bottom:1px solid #000000;
border-top:1px solid #000000;
}
ul#menu li{
display:block;
float:left;
margin:0;
padding:0;
}
ul#menu li a{
color:#999999;
text-decoration:none;
padding:8px 20px 0 20px;
height:22px;
background:transparent url(images/nav_bg.png) repeat-x top left;
}
ul#menu li a:hover, ul#menu li a.current{
color:#FFFFFF;
background:transparent url(images/nav_bg.png) 0px -30px no-repeat;
}
add a wrapper around the ul:
<div id="wrapper">
<ul id="menu">
<li><a>link</a></li> |
<li><a>link</a></li> |
...
</ul>
</div>
and add folling:
#wrapper{
width:100%;
}
ul#menu{
margin:0 auto;
}
I didn't test it, so maybe u have to change some values...