css a:hover to a:focus - css

I am making a website for my brother and I did a dropdown CSS menu for him which worked on the :hover to display the secondary options. Then he decided he wanted people to click on the main navigation box which would then dropdown the menu to show the secondary levels...
I tried changing the :hover to :focus (also the a:active) on the a element and this worked fine in IE9, but Firefox, Safari, Chrome and Opera wouldn't recognise the new commands. I read about a Javascript alternative but I'm not familiar with it too much to really feel confident about going down that route.
Just wondering if someone could help:
Link to web: http://www.doogledesigns.co.uk/prime%20elements/website/
HTML Code:
<div class="nav1">
<div class="menu-item-home">
<h4>Home</h4>
<ul>
<li>Plumbing & Gas Work</li>
<li>Electrical Work</li>
<li>Extensions</li>
<li>Internal & External Developments</li>
</ul>
</div>
<div class="menu-item-garden">
<h4>Garden</h4>
<ul>
<li>Garden Maintenance</li>
<li>Landscaping</li>
<li>Patios & Driveways</li>
<li>Walls & Fencing</li>
<li>Ponds & Water Features</li>
<li>Lighting</li>
<li>Drainage</li>
</ul>
</div>
<div class="menu-item-construction">
<h4>Construction</h4>
<ul>
<li>Home Redevelopment</li>
<li>New Builds</li>
<li>Driveways</li>
</ul>
</div>
</div>
CSS Code:
.nav1 {
float: left;
background: #404041;
height: 500px;
line-height: 1.5;
width: 170px;
-webkit-box-shadow: 2px 2px 5px rgba(0,0,0,2);
-moz-box-shadow: 2px 2px 5px rgba(0,0,0,2);
box-shadow: 2px 2px 5px rgba(0,0,0,2);
}
.menu-item-home, .menu-item-garden, .menu-item-construction {
background: #404041;
width: 170px;
}
.menu-item-home h4, .menu-item-garden h4, .menu-item-construction h4 {
color: #fff;
font-size: 13px;
font-weight: 500;
padding: 7px 12px;
background: #10702a;
}
.menu-item-home h4 a, .menu-item-garden h4 a, .menu-item-construction h4 a {
color: #fff;
display: block;
text-decoration: none;
width: 170px;
}
/* Menu Header Styles */
.menu-item-home h4, .menu-item-garden h4, .menu-item-construction h4 {
border-bottom: 1px solid rgba(0,0,0,3);
border-top: 1px solid rgba(225,225,225,0.2);
color: #fff;
font-size: 13px;
font-weight: 500;
padding: 7px 12px;
/* Gradient */
background: #a90329; /* Old browsers */
background: -moz-linear-gradient(top, #02942a 0%, #0b872d 44%, #0f722a 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#02942a), color-stop(44%,#0b872d), color-stop(100%,#0f722a)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #a90329 0%,#80b872d 44%,#0f722a 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #02942a 0%,#0b872d 44%,#0f722a 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #02942a 0%,#0b872d 44%,#0f722a 100%); /* IE10+ */
background: linear-gradient(top, #02942a 0%,#0b872d 44%,#0f722a 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#02942a', endColorstr='#0f722a',GradientType=0 ); /* IE6-9 */
}
/* ul styles */
.menu-item-home ul, .menu-item-garden ul, .menu-item-construction ul {
background: #404041;
font-size: 12px;
line-height: 30px;
height: 0px;
list-style-type: none;
overflow: hidden;
padding: 0px
}
.menu-item-home ul a, .menu-item-garden ul a, .menu-item-construction ul a {
margin-left: 2.5px;
text-decoration: none;
color: #404041;
diplay: block;
width: 173px;
}
/* li styles */
.menu-item-home li, .menu-item-garden li, .menu-item-construction li {
border-bottom: 1px solid #eee;
}
.menu-item-home li:hover, .menu-item-garden li:hover, .menu-item-construction li:hover {
background: #eee;
}
/* ul styles */
.menu-item-home ul, .menu-item-construction ul, .menu-item-garden ul {
background: #fff;
font-size: 12px;
line-height: 30px;
min-height: 0px;
max-height: 0px /* collapses the menu */
list-style-type: none;
overflow: hidden;
padding: 0px;
/* Animation */
-webkit-transition: height 1s ease;
-moz-transition: height 1s ease;
-o-transition: height 1s ease;
-ms-transition: height 1s ease;
transition: height 1s ease;
}
.menu-item-home:hover ul {
height: 155px;
}
.menu-item-garden:hover ul {
height: 220px;
}
.menu-item-construction:hover ul {
height: 90px;
}
CSS sheet needs cleaning up a bit but you get the general jist!

You want that menu to appear on click event.
To make that possible and to also make that cross browser compatible i would recommend using a jquery library jQuery just download the library and attach the link in the <head> section of your page and simply write jquery code to attach click event handler.
jQuery Download Link
basically you need to code only this much
after you link the jquery to your page write this in
<script>
$(document).ready(function(){
$(".menu-item-home a").click(function(){
$(".menu-item-home ul").slideToggle('slow');
});
$(".menu-item-garden a").click(function(){
$(".menu-item-garden ul").slideToggle('slow');
});
$(".menu-item-construction a").click(function(){
$(".menu-item-construction ul").slideToggle('slow');
});
});
</script>
and a little change to css is also required.and thats it you wana do.
have changed your css code and witten the jquery code for you for your website
check this link and you will have both your changed code.
and on the right side is the working website with click enabled.
http://jsfiddle.net/znsZu/
Hope it helps.

Related

Error in the navigation menu (CSS) with the border of last-child

I have the following piece of code where I am constructing a navigation menu with pure CSS code but there is seeming a problem to me that I can not figure out how to remove out the extra space(padding) between the both sides of the menu means the last and first child.
Plz someone help me out there.
<!DOCTYPE html>
<html>
<head>
<title>Navigation</title>
</head>
<style>
.menu,.sub_menu li,.menu li,.menu a {
margin: 0;
padding: 0;
border: none;
outline: none;
text-decoration: none;
}
.menu {
height: 40px;
width: 535px;
background: #4c4e5a;
background: -webkit-linear-gradient(top, #4c4e5a 0%,#2c2d33 100%);
background: -moz-linear-gradient(top, #4c4e5a 0%,#2c2d33 100%);
background: -o-linear-gradient(top, #4c4e5a 0%,#2c2d33 100%);
background: -ms-linear-gradient(top, #4c4e5a 0%,#2c2d33 100%);
background: linear-gradient(top, #4c4e5a 0%,#2c2d33 100%);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.menu li {
/*position: relative;*/
list-style: none;
float: left;
/*display: block;*/
height: 40px;
}
.sub_menu li {
display: none;
}
.menu li a {
/*display: block;*/
padding: 0 14px;
line-height: 40px;
/* Border on the left side of the navigation bar */
border-left: 1px solid #393942;
border-right: 1px solid #4f5058;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 13px;
color: #f3f3f3;
text-shadow: 1px 1px 1px rgba(0,0,0,.6);
-webkit-transition: color .2s ease-in-out;
-moz-transition: color .2s ease-in-out;
-o-transition: color .2s ease-in-out;
-ms-transition: color .2s ease-in-out;
transition: color .2s ease-in-out;
}
.menu li:first-child a {
border-left: none;
}
.menu li:last-child a {
border-right: none;
}
.menu li:hover > a {
color: #8fde62;
}
</style>
<body>
<ul class="menu">
<li>My dashboard</li>
<li>Likes</li>
<li>Views
<ul class="sub_menu">
<li>Documents</li>
<li>Messages</li>
<li>Sign Out</li>
</ul>
</li>
<li>Uploads</li>
<li>Videos</li>
<li>Documents</li>
</ul>
</body>
</html>
If you want the width of the .menu element to fit the containing contents, set the display of the element to inline-block and remove the fixed width.
EXAMPLE HERE
.menu {
height: 40px;
display: inline-block;
/* Other styling.. */
}
Additionally, if you want to remove/change the padding on the last/first a elements:
EXAMPLE HERE
.menu li:first-child a {
padding-left: 0;
}
.menu li:last-child a {
padding-right: 0;
}
As a designer for two years, I've always thought it was best to use this piece of code before I try styling my page:
*{
margin: 0;
padding: 0;
overflow: auto;
font-family: inherit;
list-style-type: none;
list-style-position: inside;
}
I use this on top of all my CSS code to eradicate any annoying padding or margin that comes default with some HTML elements.

Stop text from breaking to next line

How do I stop the text in my webpage from breaking to the next line. Its a navigation bar.
I tried both: 'whitespace: nowrap;' and 'overflow: hidden;' which gives me this result:
. The text doesn't break to the next line, but the drop down menus don't work and the text 'Arc Studios' is cut off on the top and bottom.
How do I stop the text from breaking to the next line, while still keeping all of the functions (drop-down menus, and the 'Arc Studios' text)?
CSS
p {
text-align: justify;
color: #000000;
text-indent:5px;
}
body {
background: #f5f5f5;
background-image: url('brushed.png');
}
footer {
background: rgb(63,76,107); /* Old browsers */
background: -moz-linear-gradient(top, rgba(63,76,107,1) 0%, rgba(63,76,107,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(63,76,107,1)), color-stop(100%,rgba(63,76,107,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(63,76,107,1) 0%,rgba(63,76,107,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(63,76,107,1) 0%,rgba(63,76,107,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(63,76,107,1) 0%,rgba(63,76,107,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(63,76,107,1) 0%,rgba(63,76,107,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3f4c6b', endColorstr='#3f4c6b',GradientType=0 ); /* IE6-9 */
box-shadow: 0px 1px 3px #000000;
border-radius: 0px;
text-indent: 5px;
position: absolute; right: 0; left: 0;
margin-top: 100px;
}
.menu,
.menu ul,
.menu li,
.menu a {
margin: 0;
padding: 0;
border: none;
outline: none;
overflow: hidden;
white-space: nowrap;
}
.menu {
margin-top: -8px;
height: 50px;
width: 100%;
position: absolute; right: 0; left: 0;
text-align: left;
background: rgb(63,76,107); /* Old browsers */
background: -moz-linear-gradient(top, rgba(63,76,107,1) 0%, rgba(63,76,107,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(63,76,107,1)), color-stop(100%,rgba(63,76,107,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(63,76,107,1) 0%,rgba(63,76,107,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(63,76,107,1) 0%,rgba(63,76,107,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(63,76,107,1) 0%,rgba(63,76,107,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(63,76,107,1) 0%,rgba(63,76,107,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3f4c6b', endColorstr='#3f4c6b',GradientType=0 ); /* IE6-9 */
box-shadow: 0px 1px 3px #000000;
-webkit-border-radius: 1px;
-moz-border-radius: 1px;
border-radius: 1px;
}
.menu li {
position: relative;
list-style: none;
float: left;
display: block;
height: 40px;
}
.menu li a { /* Navigation Bar text */
display: block;
padding: 0 20px;
margin: 15px 0;
line-height: 15px;
text-decoration: none;
font-family: sans-serif;
font-weight: bold;
font-size: 12px;
color: red;
/* text-shadow: 1px 1px 1px rgba(255,255,255,0.3); */
-webkit-transition: color .4s ease-in-out;
-moz-transition: color .4s ease-in-out;
-o-transition: color .4s ease-in-out;
-ms-transition: color .4s ease-in-out;
transition: color .4s ease-in-out;
}
.menu li:first-child a{ border-left: none; }
.menu li:last-child a{ border-right: none; }
.menu li:hover > a { text-decoration: underline; }
.menu li#navbar-logo:hover > a { text-decoration: none; }
.menu ul {
position: absolute;
top: 35px;
left: 0;
opacity: 0;
background: rgba(63,76,107,1);
border-left: 1px solid #393942;
border-bottom: 1px solid #393942;
border-right: 1px solid #393942;
-webkit-border-radius: 0 0 2px 2px;
-moz-border-radius: 0 0 2px 2px;
border-radius: 0 0 2px 2px;
-webkit-transition: opacity .75s ease .1s;
-moz-transition: opacity .75s ease .1s;
-o-transition: opacity .75s ease .1s;
-ms-transition: opacity .75s ease .1s;
transition: opacity .75s ease .1s;
}
.menu li:hover > ul {
opacity: 1;
}
.menu ul li {
height: 0;
overflow: hidden;
padding: 0;
-webkit-transition: height .25s ease .1s;
-moz-transition: height .25s ease .1s;
-o-transition: height .25s ease .1s;
-ms-transition: height .25s ease .1s;
transition: height .25s ease .1s;
}
.menu li:hover > ul li {
height: 35px;
overflow: visible;
padding: 0;
}
.menu ul li a {
width: 100px;
padding: 10px 0 10px 10px;
margin: 0;
border: none;
border-bottom: 1px solid #353539;
}
.menu ul li:last-child a {
border: none;
}
.menu li#navbar-logo,
.menu li#navbar-about,
.menu li#navbar-shop,
.menu li#navbar-contact,
.menu li#navbar-community {
margin-top: 5px;
}
.menu li#navbar-logo {
margin-top: 3px;
}
.menu li#navbar-logo,
.menu li#navbar-about,
.menu li#navbar-shop,
.menu li#navbar-contact,
.menu li#navbar-community {
margin-left: -13px;
margin-right: 5px;
}
.menu li#navbar-about,
.menu li#navbar-shop,
.menu li#navbar-contact,
.menu li#navbar-community {
margin-left: 5px;
margin-right: 5px;
}
#navbar-logo a{
color: #FFC8C8;
text-shadow: 2px 2px 2px rgba(255, 0, 0, 1);
font-size: 50px;
font-family: Intrique Script Personal Use;
}
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Title of Webpage</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<header>
<nav class="navbar">
<ul class="menu">
<li id="navbar-logo">Arc Studios</li>
<li id="navbar-about">About Us
<ul>
<li>FAQ's</li>
<li>Our Inception</li>
<li>Locations</li>
</ul>
</li>
<li id="navbar-shop">Store
<ul>
<li>Games</li>
<li>OS's</li>
<li>Other</li>
</ul>
</li>
<li id="navbar-contact">Contact
<ul>
<li>Email</li>
<li>Help Centre</li>
</ul>
</li>
<li id="navbar-community">Community
<ul>
<li>Forums</li>
<li>Events</li>
</ul>
</li>
</ul>
</nav>
</header>
<br></br>
<footer class="footer">
<p><small>© Copyright 2013, All rights reserved</small></p>
</footer>
</body>
</html>
I'm new to HTML, excuse me.
You would need to decrease the padding in the .menu li a style as they are still block type elements, and specifying white-space: nowrap; will not make a difference, because the menu items are split between the li's.
Remove the overflow:hidden; to show the entire logo.
As for the wrapping, if you don't want any collapsing, you need to set a min-width or a fixed width on ul.menu.
Otherwise, you could use media queries to adjust the sizing of the menu links at certain breakpoints.

Cant remove space between Header and Menu Nav bar

I for whatever reason cannot get rid of the gap between my header and the nav bar menu. I've tried every adjustment of padding/margins I can think of to either push it up or move the bar, but it just does funky stuff with the menu or pushes other content up. I need some help.
and the code
#header_wrap {
width:100%;
height:144px;
text-align: center;
}
#header {
width:980px;
margin:0 auto;
}
#preloadedImages
{
width: 0px;
height: 0px;
display: none;
background-image:url(Logo/logo14hover.gif);
}
.site_logo {
float:left;
width:302px;
height:144px;
background:url(Logo/logo14.gif) no-repeat;
}
.site_logo:hover {
float:left;
width:302px;
height:144px;
background:url(Logo/logo14hover.gif) no-repeat;
}
.headerpic {
float:left;
width:678px;
height:144px;
background:url(Images/headerpic.gif) no-repeat;
}
#menu_wrap {
position:relative;
z-index:2;
text-align:center;
width:100%;
padding: 0px 0px;
}
#menu {
position:relative;
z-index:2;
width:1000px;
text-align:center;
margin:0 auto;
height:61px;
padding: 0px 0px;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
background: #bbb38f; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2JiYjM4ZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM2YjY0NDEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #bbb38f 0%, #6b6441 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bbb38f), color-stop(100%,#6b6441)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* IE10+ */
background: linear-gradient(to bottom, #bbb38f 0%,#6b6441 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bbb38f', endColorstr='#6b6441',GradientType=0 ); /* IE6-8 */
box-shadow: 0px 0px 9px rgba(0,0,0,0.5);
padding: 0px 0px;
list-style:none;
position: relative;
display:inline-table;
text-decoration:none;
font-family:Copperplate Gothic Light,Georgia, Palatino, Times New Roman, serif;
font-size:17px;
color:#FFFFFF;
font-weight:light;
outline:none;
text-shadow: 1px 1px #000000;
}
nav ul:after {
content: ""; clear: both; display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #736e57;
background: linear-gradient(top, #BBB38F 0%, #6B6441 40%);
background: -moz-linear-gradient(top, #BBB38F4 0%, #6B64415 40%);
background: -webkit-linear-gradient(top, #BBB38F 0%,#6B6441 40%);
text-decoration:none;
font-family:Copperplate Gothic Light,Georgia, Palatino, Times New Roman, serif;
font-size:17px;
color:#FFFFFF;
font-weight:light;
outline:none;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul li:hover a {
color:#FFFFFF;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul li a {
color:#FFFFFF;
display: block;
padding: 12px 42px;
text-decoration:none;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul li:hover > ul {
background: #303030;
text-decoration:none;
display: block;
}
nav ul ul {
background: #303030;
font-family: Helvetica, Copperplate Gothic Light, Arial, sans-serif;
font-size:14px;
text-decoration:none;
color:#000;
font-weight:light;
outline:none;
filter:alpha(opacity=95);
opacity: 0.95;
-moz-opacity:0.95;
}
nav ul ul li {
text-decoration:none;
float: none;
position: relative;
}
nav ul ul li a {
text-decoration:none;
padding: 0px 0px;
color:#000;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul ul li a:hover {
text-decoration:none;
background: #736e57;
text-shadow: 1px 1px #000000;
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul ul {
text-decoration:none;
padding: 0px;
position: absolute;
}
nav ul ul li {
float: none;
position: relative;
}
nav ul ul li a {
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
padding: 10px 40px 10px 15px;
color:#000;
font-family: Helvetica, Copperplate Gothic Light, Arial, sans-serif;
font-size:15px;
text-align: left;
}
nav ul ul li a:hover {
font-family: Helvetica, Copperplate Gothic Light, Arial, sans-serif;
font-size:15px;
background: #6B6441;
text-align: left;
background: #bbb38f; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2JiYjM4ZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM2YjY0NDEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #bbb38f 0%, #6b6441 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bbb38f), color-stop(100%,#6b6441)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #bbb38f 0%,#6b6441 100%); /* IE10+ */
background: linear-gradient(to bottom, #bbb38f 0%,#6b6441 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bbb38f', endColorstr='#6b6441',GradientType=0 ); /* IE6-8 */
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
}
nav ul ul ul {
position: absolute;
left: 100%; top:0;
}
and the HTML
<div align="center" id="header_wrap">
<div id="header">
<div id="preloadedImages"></div><div class="site_logo"></div>
<div class="headerpic"></div>
</div>
</div>
<!-- START MENU NAV BAR CODE -->
<div id="menu_wrap">
<div id="menu">
<nav>
<ul>
<li>Company
<ul>
<li>Mission</li>
<li>Philosophy</li>
</ul>
</li>
<li>Solutions
<ul>
<li>Q Pipe Estimator
<ul>
<li>Advantage</li>
<li>Differentiator</li>
<li>Features</li>
<li>Screen Shots</li>
</ul>
</ul>
</li>
</li>
<li>Services
<ul>
<li>Technical Support</li>
<li>Training</li>
<li>Customization</li>
<li>FAQ's</li>
</ul>
</li>
<li>Industry
<ul>
<li>Focus</li>
<li>Customers</li>
</ul>
</li>
<li>Contact
<ul>
<li>Contact Information</li>
<li>Request Information</li>
</ul>
</li>
<li>Login
</li>
</ul>
</nav>
</div>
</div>
<!-- END MENU NAV BAR CODE -->
added fiddle link in comments
Simply remove the default margin for your main ul (the direct descendant of nav)
Select it using the following CSS, or giving that specific ul a class or id (this way you target only the ul causing you trouble).
nav > ul {margin: 0}
I stuck it into the top of your fiddle, and updated it here
I realise this has now been answered because I took way too long formatting this, but I'd just like to point out that it has nothing to do with the box-shadow which has no impact on positioning.
The ul default margin is responsible for this space. Try setting margin-top:0 to nav ul. Demo: http://jsfiddle.net/xtsAx/8/
for me the error was because i used dream weaver to edit my code.
this give me a hiccup by adding default headers.
when i removed those headers and just gave<html> <head>...<?php>....?> .... </html> it worked perfect.
always remove html tags and header by dream weaver.
**Update: I had the same error again in Firefox so i applied
*{
margin:0;
padding:0;
}
And hence got rid of it completely now.
**

How to slow drop menu animation with CSS only

I have a drop menu using CSS and now I am told they would like the drop menu to display a bit slower. Everything works great, but I am so far unable to slow down the transition when a user hovers over the navigation. What is the best way of doing this with a CSS only solution?
Demo on JSFiddle
HTML
<nav>
<ul>
<li>Line 1</li>
<li>Line 2
<ul>
<li>SubCat 1</li>
<li>SubCat 2</li>
<li>SubCat 3</li>
</ul>
</li>
<li>Line 3
<ul>
<li>SubCat 4</li>
<li>SubCat 5</li>
<li>SubCat 6</li>
</ul>
</li>
<li>Line 4
<ul>
<li>SubCat 7</li>
<li>SubCat 8</li>
<li>SubCat 9</li>
</ul>
</li>
</ul>
</nav>
CSS
nav {
background: url(../images/global/Navigation_Full.png) no-repeat;
width: 540px;
height: 54px;
margin: 0 auto;
color: #000;
}
nav ul{
display: inline-table;
list-style: none;
width: 100%;
position: relative;
border-top: 1px solid #FF9F69;
}
nav ul:after {
content: ""; clear: both; display: block;
}
nav ul ul {
display: none;
position: absolute;
width: auto;
top: 100%;
}
nav ul li:hover > ul {
display: block;
}
nav li:first-child {
border-left: none;
}
nav li {
text-align: center;
margin-left: 1px;
float: left;
height: 38px;
line-height: 40px;
padding: 0 10px;
}
nav li a {
padding: 10px 17px;
font-size: 0.813em;
text-decoration: none;
text-shadow: inherit;
color: #000;
}
nav li:hover {
box-shadow: 1px 1px 20px 1px rgba(64, 23, 0, 0.4) inset;
-webkit-transition-property:color, background;
-moz-transition-property:color, background;
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
-webkit-transition-timing-function: linear, ease-in;
-moz-transition-timing-function: linear, ease-in;
}
nav ul ul {
background: rgb(125,56,16); /* Old browsers */
background: -moz-linear-gradient(top, rgba(125,56,16,1) 0%, rgba(233,103,31,1) 30px, rgba(233,103,31,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(125,56,16,1)), color-stop(30px,rgba(233,103,31,1)), color-stop(100%,rgba(233,103,31,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(125,56,16,1) 0%,rgba(233,103,31,1) 30px,rgba(233,103,31,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(125,56,16,1) 0%,rgba(233,103,31,1) 30px,rgba(233,103,31,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(125,56,16,1) 0%,rgba(233,103,31,1) 30px,rgba(233,103,31,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(125,56,16,1) 0%,rgba(233,103,31,1) 30px,rgba(233,103,31,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7d3810', endColorstr='#e9671f',GradientType=0 ); /* IE6-9 */
border-radius: 0px; padding: 0;
border-top: none;
z-index: 1;
}
nav ul ul li {
float: inherit;
position: relative;
border-left: none;
border-right: none;
text-align: left;
font-size: 1em;
font-weight: lighter;
}
nav ul ul li a {
color: #fff;
}
nav ul ul li a:hover {
color: #000;
}
nav ul ul ul {
position: absolute; left: 100%; top:0;
}
You have animated the main menu but not the dropdown.
I have changed the transition in the dropdown from setting display:block to setting opacity to 1,
nav ul li:hover > ul {
display: block;
opacity: 1;
}
and to the base element, added display block, set opacity to 0, and animated that.
nav ul ul {
background: rgb(125,56,16); /* Old browsers */
display: block;
opacity: 0;
-webkit-transition: opacity 3s;
}
The result is:
http://jsfiddle.net/vals/SmNq3/1/
CSS3 Transitions have a duration property that you can set.
#example
{
transition-property: top;
transition-duration: 2s;
}
Note: Support may require the use of vendor prefixes (-webkit, -o, -ms, -moz).
Try this code in your css
div {
overflow:hidden;
background:#000;
color:#fff;
height:0;
padding: 0 18px;
width:100px;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
transition: all .5s ease;
}
.animated {
height:auto;
padding: 24px 18px;
}
Check this http://jsfiddle.net/catharsis/n5XfG/17/

When I integrate one CSS with another, why is the font styling of one CSS changing to that of the other?

I have an image slider (CSS based) customised to my specifications (font styles, size etc). Then I have another CSS having 6 download buttons. But when I try to combine and integrate both of them into my HTML page, why are the CAPTION'S font sizes, their styling, caption positioning etc changing?
ALSO note that in the individual DOWNLOAD BUTTON page, when I hover oved the DOWNLOAD BUTTON, the text "DOWNLOAD" still shows in WHITE colour. But after integrating both the CSSpages, when I hover over DOWNLOAD button, its colour changes from white to BLACK! Why is it happening?
Please have a look at these pages:
THE INDIVIDUAL SLIDER page: www.aamaodisha.org/nivoslider.html
THE INDIVIDUAL DOWNLOAD BUTTONS page: www.aamaodisha.org/button.html
When I integrate them both into a single page, they look like this:
www.aamaodisha.org/both.html
I am sorry, this might be a very silly doubt of mine but I am very new to CSS properties, I just decided to try design my own website.
I tried looking on Google on CSS chapters but couldn't help myself out. But as far as I have grasped things about CSS, I guess it has something to do with "IDs" and "Class" for the texts. I guess if I somehow change the CAPTION class in the nivoslider to an ID, it mayn't interfere with other settings. or may be change class of DOWNLOAD page CSS to some ID. But I am unable to find a way.
Please help me out.
This is the CSS for the SLIDER:
a, a:visited {
color:blue;
text-decoration:none;
}
a:hover, a:active {
color:#000;
text-decoration:none;
}
a.nivo-nextNav {
background-position:-30px 0;
right:15px;
}
a.nivo-prevNav {
left:15px;
}
#slider_wrapper {
height: 390px;
}
#slider {
margin:0px;
position:absolute;
left:0px;
top:102px;
width: 359px;
height: 390px;
background: url(images/loading.gif) no-repeat 50% 50%;
}
#slider img {
position: absolute;
top: 0;
left: 0;
display: none;
}
#slider a {
border: 0;
display: block;
}
.nivoSlider {
position:relative;
background:#ffffff url(loading.gif) no-repeat 50% 50%;
margin-bottom:50px;
-webkit-box-shadow: 0px 0px 0px 0px #4a4a4a;
-moz-box-shadow: 0px 0px 0px 0px #4a4a4a;
box-shadow: 0px 0px 0px 0px #4a4a4a;
}
.nivoSlider img {
position:absolute;
top:0px;
left:0px;
display:none;
}
.nivoSlider a {
border:0;
display:block;
}
/* If an image is wrapped in a link */
.nivoSlider a.nivo-imageLink {
position:absolute;
top:0px;
left:0px;
width:100%;
height:100%;
border:0;
padding:0;
margin:0;
z-index:6;
display:none;
}
/* The slices and boxes in the Slider */
.nivo-slice {
display:block;
position:absolute;
z-index:5;
height:100%;
}
.nivo-box {
display:block;
position:absolute;
z-index:5;
}
/* Caption styles */
.nivo-caption {
position:absolute;
left:0px;
bottom:0px;
background:#091023;
color:#fff;
opacity:0.7; /* Overridden by captionOpacity setting */
width:100%;
z-index:8;
}
.nivo-caption p {
font:11px/1.5 Verdana;
padding: 7px 50px;
}
.nivo-caption a {
display:inline !important;
color:#fff;
border-bottom:1px dotted #fff;
}
.nivo-caption a:hover {
color:#fff;
}
.nivo-html-caption {
display:none;
}
/* Direction nav styles (e.g. Next & Prev) */
.nivo-directionNav a {
position:absolute;
top:45%;
z-index:9;
cursor:pointer;
display:block;
width:30px;
height:30px;
background:url(arrows.png) no-repeat;
text-indent:-9999px;
border:0;
}
.nivo-prevNav {
left:0px;
}
.nivo-nextNav {
right:0px;
}
.nivo-controlNav {
position:absolute;
left:73%;
top:7px;
margin-right:-4px; /* Tweak this to center bullets */
}
/* Control nav styles (e.g. 1,2,3...) */
.nivo-controlNav a {
display:block;
width:22px;
height:22px;
background:url(bullets.png) no-repeat;
text-indent:-9999px;
border:0;
margin-right:3px;
float:left;
position:relative;
z-index:9;
cursor:pointer;
}
.nivo-controlNav a.active {
background-position:0 -22px;
font-weight:bold;
}
This is the CSS for the DOWNLOAD BUTTONS:
.button {
width: 115px;
}
.button1 {
position:absolute;
left:430px;
top:410px;
}
.button2 {
position:absolute;
left:632px;
top:410px;
}
.button3 {
position:absolute;
left:833px;
top:410px;
}
.button4 {
position:absolute;
left:430px;
top:636px;
}
.button5 {
position:absolute;
left:632px;
top:636px;
}
.button6 {
position:absolute;
left:833px;
top:636px;
}
.button a {
display: block;
height: 28px;
width: 115px;
/*TYPE*/
color: white;
font: bold 11px/28px Helvetica, Verdana, sans-serif;
text-decoration: none;
text-align: center;
text-transform: uppercase;
/*GRADIENT*/
background: #00b7ea; /* Old browsers */
background: -moz-linear-gradient(top, #00b7ea 0%, #009ec3 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#00b7ea), color-stop(100%,#009ec3)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #00b7ea 0%,#009ec3 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #00b7ea 0%,#009ec3 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #00b7ea 0%,#009ec3 100%); /* IE10+ */
background: linear-gradient(top, #00b7ea 0%,#009ec3 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00b7ea', endColorstr='#009ec3',GradientType=0 ); /* IE6-9 */
}
.button a, p {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
-moz-box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
}
p {
background: #222;
display: block;
height: 25px;
width: 105px;
margin: -27px 0 0 5px;
/*TYPE*/
text-align: center;
font: bold 10px/28px Helvetica, Verdana, sans-serif;
color: #ffffff;
/*POSITION*/
position: absolute;
z-index: -1;
/*TRANSITION*/
-webkit-transition: margin 0.4s ease;
-moz-transition: margin 0.4s ease;
-o-transition: margin 0.4s ease;
-ms-transition: margin 0.4s ease;
transition: margin 0.4s ease;
}
/*HOVER*/
.button:hover .bottom {
margin: -4px 0 0 5px;
}
.button:hover .top {
margin: -50px 0 0 5px;
line-height: 22px;
}
/*ACTIVE*/
.button a:active {
background: #00b7ea; /* Old browsers */
background: -moz-linear-gradient(top, #00b7ea 36%, #009ec3 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(36%,#00b7ea), color-stop(100%,#009ec3)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #00b7ea 36%,#009ec3 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #00b7ea 36%,#009ec3 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #00b7ea 36%,#009ec3 100%); /* IE10+ */
background: linear-gradient(top, #00b7ea 36%,#009ec3 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00b7ea', endColorstr='#009ec3',GradientType=0 ); /* IE6-9 */
}
.button:active .bottom {
margin: -14px 0 0 5px;
}
.button:active .top {
margin: -30px 0 0 5px;
}
In button.css line no 74 change the selector fro p to .button p
so instead of
p {
-moz-transition: margin 0.4s ease 0s;
background: none repeat scroll 0 0 #222222;
color: #FFFFFF;
display: block;
font: bold 10px/28px Helvetica,Verdana,sans-serif;
height: 25px;
margin: -27px 0 0 5px;
position: absolute;
text-align: center;
width: 105px;
z-index: -1;
}
it should be
.button p {
-moz-transition: margin 0.4s ease 0s;
background: none repeat scroll 0 0 #222222;
color: #FFFFFF;
display: block;
font: bold 10px/28px Helvetica,Verdana,sans-serif;
height: 25px;
margin: -27px 0 0 5px;
position: absolute;
text-align: center;
width: 105px;
z-index: -1;
}
In your CSS for the download buttons, you have this rule:
.button a, p {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
-moz-box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
}
That applies all of those declarations to every anchor element inside an element with the class button, but also to every paragraph element regardless of its parent. The caption in your slider box is placed in a paragraph tag. That's why those additional styles are applied. A quick way to solve this is to add some specificity to the caption with a class, and apply the declarations to that class instead of all paragraph elements.
The best way to understand where style declarations are coming from is to use the inspector in a modern browser like Chrome or Firefox. In Chrome, try secondary-clicking on an element like the caption. Select Inspect Element from the contextual menu. Under Computed Style, you will see every declaration the browser has interpreted, and where it came from.
<link href="button.css" type="text/css" rel="stylesheet" />
...................................................................
<link href="nivo-slider.css" type="text/css" rel="stylesheet" />
here is some source for your page. As you see, the link to the slider css is after the one for the buttons. Every time you put in a css link, whatever was defined before is overwritten if the element styling is declared again. SO you have
a:hover, a:active {
color:#000;
text-decoration:none;
} in your slider css, which is called second. This will overwrite your styling in button, as it is a general declaration for all a elements. And the color is #000 (black)

Resources