I don't understand why I am able to see through my navigation bar like this. I can even highlight the text through it. Any help guys?
Here's the HTML and CSS, when I test this on an online editor, it works properly. But on my local code, it doesn't.
nav{
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #fff;
box-shadow: 0 3px 10px -2px rgba(0,0,0,.1);
border: 1px solid rgba(0,0,0,.1);
}
nav ul{
list-style: none;
position: relative;
float: right;
margin-right: 100px;
display: inline-table;
}
nav ul li{
float: left;
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}
nav ul li:hover{background: rgba(0,0,0,.15);}
nav ul li:hover > ul{display: block;}
nav ul li{
float: left;
-webkit-transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}
nav ul li a{
display: block;
padding: 30px 20px;
color: #222;
font-size: .9em;
letter-spacing: 1px;
text-decoration: none;
text-transform: uppercase;
}
<nav role="navigation">
<ul>
<li>Home</li>
<li>About Us</li>
<li>Services</li>
<li>Contact Us</li>
</ul>
</nav>
I cant comment, so this appears as an answer but its more a suggestion as I cant see all your code (like where is the Lorem Ipsum coming from?)
You've set the nav to position:fixed, this removes itself from the structure of the DOM. I dont see a z-index property there so that might fix the situation. The text will be hidden behind the navigation if you set the z-index to anything greater than 0.
nav {
position:fixed;
z-index: 1;
...
}
To make sure the text sits underneath the navigation, you may want to set a margin-top to your body tag equating to the height of the navigation bar.
Related
What I'm trying to achieve ---> http://jsfiddle.net/46a8u/
I applied those styles to my css. Problem is my links bounce to the left when hovered. I don't want them to move at all. The only transition I want is for the underline to go from left to right in a hover state. I have a codepen link below showing my issue. Again: I do not want my links(Contact, Behance, LinkedIn) to move, just want the underline to appear from left to right when hovered like how it in jsfiddle link I posted above.
Thanks!
My Codepen
http://codepen.io/Chris-Brennan/pen/Gpgvqy
<nav>
<ul id="nav">
<li>Contact</li>
<li>Behance</li>
<li>LinkedIn</li>
</ul>
</nav>
nav{
position:absolute;
right: 0px;
right:350px;
top: 50px;
}
#nav{
list-style-type:none;
}
nav li{
float:left;
margin:0px 10px;
padding-right: 11px;
font-family: 'Lato', sans-serif;
color:#888;
}
nav a{
text-decoration: none;
display: inline-block;
border-bottom: 3px solid blue;
margin-right: 39px;
width: 0px;
-webkit-transition: 0.5s ease;
transition: 0.5s ease;
}
nav a:hover{
-webkit-transition: 0.5s ease;
transition: 0.5s ease;
border-bottom: 3px solid blue;
width: 55px;
margin-right: 9px;
}
Use pseudoclases instead of animating border. Take a look codepen.io/anon/pen/MaYQEp
this is happening because "nav a" margin-right is not good enough and when you are chaning on hover at "nav a:hover" it pushes the content. as per my knowledge you can achieve this by
using following css in "nav a"
nav a{
text-decoration: none;
display: inline-block;
border-bottom: 3px solid blue;
margin-right: 65px;
width: 0px;
-webkit-transition: 0.5s ease;
transition: 0.5s ease;
}
and some the css for "nav a :hover "
nav a:hover{
-webkit-transition: 0.5s ease;
transition: 0.5s ease;
border-bottom: 3px solid blue;
width: 55px;
margin-right: 9px;
}
I want to reduce the size of the drop down menus to the same as the buttons. Adjusting either the padding or margin would move the items out of place and close themselves when I try to hover over it. I'd like to know what is causing this. Here's the Fiddle
Any help would be great.
CSS:
.sort ul {
text-align: left;
display: inline;
margin: 0;
list-style: none;
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.15);
float:right;
}
.sort ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #FF5C00 url(http://i1350.photobucket.com/albums/p769/Stonecold_Stone/Games/SoManySales/Joint%20Supplement/alert-overlay_zpsf561d19b.png) repeat-x;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
color:#fff;
}
.sort ul li:hover {
background: #555;
color: #fff;
}
.sort ul li ul {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width: 150px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
.sort ul li ul li {
background: #FFDFDF;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
z-index:9999;
}
.sort ul li ul li:hover { background: #666; }
.sort ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
.button, ul{ padding-left: 15px;}
.button {
list-style: none; cursor: pointer;
float: left; margin: 10px 10px;
background-color: #039fd3; color: #fff;
padding: 5px 10px;
font-size: 13px;
border-radius: 3px;
-webkit-transition:background-color 0.3s ease-in;
-moz-transition:background-color 0.3s ease-in;
-o-transition:background-color 0.3s ease-in;
transition:background-color 0.3s ease-in;
}
HTML:
<div class="sort"><ul>
<li>
Sort AXXX
<ul>
<li><a href='#'>SXXXX</a></li>
<li><a href='%#%'>AXXXx</a></li>
</ul>
</li>
<li>Sort BXXX
<ul>
<li><a href='%#%'>CXXXX</a></li>
</ul>
</li>
<li>Sort C
<ul>
<li><a href='%#%'>WSXXXX</a></li>
<li><a href='%#%'>SXXXX</a></li>
</ul>
</li>
</ul></div>
Following the op coding style, in order to adjust the width of the dropdown it is required to set a width value for the list items under .sort div. Also added paddings similar to the ones set to the blue buttons on the left.
.sort ul li{
width:70px;
padding-top:5px;
padding-bottom:5px;
padding-left:5px;
padding-right:5px;
}
Also it is necesary to adjust the top relative position of the sub menu to always be below the the main menu,
.sort ul li ul{
top:100%;
}
To adjust the distance from the top of the menu to be the same as with the buttons, it is possible to tweak the top relative distance of the menu to achieve it.
The ul element containing the buttons is a block element and the list items within it are floated with a margin-top of 10px and padding-top of 5px so a total of 15px from the top. The ul element within div.sort is floated to the right and has a padding-top of 5px so with margin-top 10px (i.e. 15-5) should be aligned with the buttons.
.sort > ul{
margin-top:10px;
}
http://jsfiddle.net/fLSyE/
First is, if you want your buttons and drop down menu to have the same size, just set the width to be the same. Here is an example(from your code):
.sort ul li ul {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width: 100px; /* set width of drop down menu to 100px */
-webkit-box-shadow: none;
/* SOME OTHER CODES FOLLOW */
}
.sort ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
width: 100px; /* also set the width of the menus to 100px */
position: relative;
padding: 15px 20px;
}
Hope it helps!
I have a problem where images are appearing over my navigation menu. I have a fixed nav menu that stays at the top of the window, and 8 images that are set to 0.7 opacity lower on the page. The image change to 1.0 opacity when you hover, If you scroll down the images above the nav menu, unless i hover over them, then they appear under the nav like they should.
I will show you my code for the nav, and one of the 8 images, maybe someone can help. this is my first time posting, I hope everything is posted correctly.
Nav:
<div id="nav-container">
<div id="nav">
<ul>
<li>Home</li>
<li>Folio</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
</div>
Images:
<div id="bg2">
<div class="content-title">
<h2>Folio</h2>
<p> This is what I do </p>
<div class="content-area">
<div class="folio-item">
<img src="images/folio/folio1.png" alt="some_text">
</div>
</div> <!-- content-area close-->
</div> <!-- content-title close-->
Relvent Style:
#nav-container {
width:100%;
height:50px;
box-shadow: 0px 1px 50px #464646;
position:fixed;
top:0px;
background-image: url(images/bggrey.png);
}
#nav {
font-size: 14px;
text-align: center;
line-height: 50px;
}
#nav li{
text-decoration: none;
text-align: center;
display: inline;
padding: 10px;
margin-left: 40px;
margin-right: 40px;
}
#nav a{
text-decoration: none;
color: rgb(250,250,250);
opacity: 1;
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
}
#nav a:visited{
text-decoration: none;
color: rgb(250,250,250);
}
#nav a:hover{
text-decoration: none;
color: rgb(250,250,250);
opacity: 0.7;
}
#nav a:active{
text-decoration: none;
color: rgb(250,250,250);
}
#bg1 {
background-image: url(images/bubble.png);
background-repeat:no-repeat;
background-position: center;
height: 800px;
margin: -1;
}
.content-title {
width: 960px;
margin: auto;
font-size: 20px;
color: white;
text-align: center;
padding-top: 70px;
}
.content-title p{
font-size: 14px;
}
.content-area {
border: 1px dashed black;
height: 500px;
width: 960px;
margin: auto;
margin-top: 50px;
font-size: 0px;
}
.folio-item {
float: left;
opacity: 0.7;
}
.folio-item:hover {
opacity: 1.0;
transition: opacity .3s ease-out;
-moz-transition: opacity .3s ease-out;
-webkit-transition: opacity .3s ease-out;
-o-transition: opacity .3s ease-out;
}
If I understand in the right way you want your #nav-container always overlapping the images; then you need the property z-index to manage the level of the elements, try adding this on the CSS:
#nav-container {
z-index:1;
}
I'm working on getting my site up and running, and I've run into a problem with my drop-down navigation menu in Firefox.
I have been using the site in Chrome and it works fine, it is a simple setup of nested lists for the selections. The options appear, but they are floating to the left instead of directly below their appropriate section.
CSS:
/*sub-menu navigation*/
nav.primary ul ul
{
opacity: 0;
filter: alpha(opacity=0);
position: absolute;
z-index: 999;
background: #111111;
height: 0px;
overflow: hidden;
min-width: 100%;
-webkit-transition: opacity 0.4s ease-out;
-moz-transition: opacity 0.4s ease-out;
-o-transition: opacity 0.4s ease-out;
-ms-transition: opacity 0.4s ease-out;
transition: opacity 0.4s ease-out;
-webkit-box-shadow: 0px 2px 2px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 2px 2px rgba(0,0,0,0.3);
box-shadow: 0px 2px 2px rgba(0,0,0,0.3);
}
nav.primary ul li:hover ul
{
opacity: 10;
filter: alpha(opacity=100);
height: auto;
overflow: auto;
}
nav.primary ul ul li
{
float: none;
display: list-item;
border-bottom: 1px solid #747474;
}
nav.primary ul ul li a
{
display: block;
margin-left: 10px;
line-height: 40px;
font-size: 0.8em;
/*text-transform: none;*/
font-family: 'LibbyRegular', Helvetica, Arial, sans-serif;
}
Menu HTML
<ul>
<li>independent work
<ul>
<li>>> big and ugly</li>
<li>>> iceworld</li>
<li>>> gordon's got game</li>
</ul>
</li>
<li>team projects
<ul>
<li>>> blastrobots</li>
<li>>> ruined</li>
</ul>
</li>
<li>scripting
<ul>
<li>>> hero man (C#)</li>
<li>>> CloneOut (lua)</li>
<li>>> shotgun (unrealscript)</li>
</ul>
</li>
<li>resume</li>
</ul>
The site is http://lvsherman.com if you would like to test it.
Try adding to your inner UL elements.
left: 0;
top: WHATEVER;
I created a horizontal navigation (menu) bar for my site. When I re-size my window to a size smaller than that of the bar, the menu items get wrapped. I want the menu to remain intact (that is, it should remain horizontal) irrespective of the size of window as it usually can be seen in sites such as Google. I tried various ways posted on various forums including this one but nothing worked for me. Below I have pasted my CSS code for the menu.
CSS CODE:
#cssmenu ul { margin: 0; padding: 0;}
#cssmenu li { margin: 0; padding: 0;}
#cssmenu a { margin: 0; padding: 0;}
#cssmenu ul {list-style: none;}
#cssmenu a {text-decoration: none;}
#cssmenu {height: 70px; background-color: #6699CC; box-shadow: 0px 2px 3px rgba(0,0,0,.4); }
#cssmenu > ul > li {
float: left;
margin-left: 30px;
position: relative;
}
#cssmenu > ul > li > a {
color: #FFFFFF;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 18px;
line-height: 70px;
padding: 15px 20px;
-webkit-transition: color .15s;
-moz-transition: color .15s;
-o-transition: color .15s;
transition: color .15s;
}
#cssmenu > ul > li > a:hover {color: #00FF00; }
body.home li.home, body.tech li.tech {font-weight:bold; }
#cssmenu > ul > li > ul {
opacity: 0;
visibility: hidden;
padding: 16px 0 20px 0;
background-color: #FFFFFF;
text-align: left;
position: absolute;
top: 55px;
left: 50%;
margin-left: -90px;
width: 180px;
-webkit-transition: all .3s .1s;
-moz-transition: all .3s .1s;
-o-transition: all .3s .1s;
transition: all .3s .1s;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0px 1px 3px rgba(0,0,0,.4);
-moz-box-shadow: 0px 1px 3px rgba(0,0,0,.4);
box-shadow: 0px 1px 3px rgba(0,0,0,.4);
}
#cssmenu > ul > li:hover > ul {
opacity: 1;
top: 65px;
visibility: visible;
}
#cssmenu > ul > li > ul:before{
content: '';
display: block;
border-color: transparent transparent rgb(250,250,250) transparent;
border-style: solid;
border-width: 10px;
position: absolute;
top: -20px;
left: 50%;
margin-left: -10px;
}
#cssmenu > ul ul > li { position: relative;}
#cssmenu ul ul a{
color: rgb(50,50,50);
font-family: Verdana, 'Lucida Grande';
font-size: 13px;
background-color: rgb(250,250,250);
padding: 5px 8px 7px 16px;
display: block;
-webkit-transition: background-color .1s;
-moz-transition: background-color .1s;
-o-transition: background-color .1s;
transition: background-color .1s;
}
#cssmenu ul ul a:hover {background-color: rgb(240,240,240);}
#cssmenu ul ul ul {
visibility: hidden;
opacity: 0;
position: absolute;
top: -16px;
left: 206px;
padding: 16px 0 20px 0;
background-color: rgb(250,250,250);
text-align: left;
width: 160px;
-webkit-transition: all .3s;
-moz-transition: all .3s;
-o-transition: all .3s;
transition: all .3s;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0px 1px 3px rgba(0,0,0,.4);
-moz-box-shadow: 0px 1px 3px rgba(0,0,0,.4);
box-shadow: 0px 1px 3px rgba(0,0,0,.4);
}
#cssmenu ul ul > li:hover > ul { opacity: 1; left: 196px; visibility: visible;}
#cssmenu ul ul a:hover{
background-color: rgb(205,44,36);
color: rgb(240,240,240);
}
HTML Code:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="styles.css" rel="stylesheet" type="text/css">
<title>Home</title>
</head>
<body class="home" background="teenscorner1.jpg" text="#FFFFFF" style="background-attachment: fixed">
<div id='cssmenu'>
<ul>
<li class="home"><a href='home.jsp'><span>Home</span></a></li>
<li class="tech"><a href='tech.jsp'><span>Tech Specs</span></a></li>
<li><a href='#'><span>Fun</span></a></li>
<li><span>Deals</span></li>
<li><span>Wheelz</span></li>
<li><a href='#'><span>About</span></a></li>
</ul>
</div>
</body>
When you don't know the width because the links can differ in width you could use display: inline-block on the list item <li> and white-space:nowrap on the list itself <ul>
http://jsfiddle.net/Frd8J/
You should set a min-width for #cssmenu > ul, one that allows all your menu items to fit.
The accepted answer did not work in my case but #Ana original answer did. I tried to add this as a comment to her answer but it would not fit. Putting a min-width on the UL as suggested, brought all of the LI items back to one line as desired, but that line extended to the right of the containing div. I added the same min-width to the parent div and I got what I wanted, all of the LI on one line within the container. As a final step, I removed the min-width from the UL (so this is a different, more general answer than Ana's) and everything still worked. In a nut shell if you make the UL nowrap in css as documented in the accepted answer and it wraps anyway, then make sure you give the list enough width so that it does not need to wrap. Another way to increase the width that also works (without using min-width) is to increase the width of the content area below the UL in the containing div. My case was a tabbed DIV, the LIs were the tabs on top. Each tab had content below it. When the content below was wide enough already the LIs stayed in one row. I could have put a min width on every tab content, but for me it worked better to put it once on the outside container. HTH.
im assuming these are you nav bar items
<li class="home"><a href='home.jsp'><span>Home</span></a></li>
<li class="tech"><a href='tech.jsp'><span>Tech Specs</span></a></li>
<li><a href='#'><span>Fun</span></a></li>
<li><span>Deals</span></li>
<li><span>Wheelz</span></li>
<li><a href='#'><span>About</span></a></li>
if you just put them like this
<li class="home"><a href='tech.jsp'><span>Tech Specs</span></li> <li><span>Deals</span></li> <li><span>Wheelz</span></li> <li><a href='#'><span>About</span></a></li>
thats all you have to do is join them all together with no spaces between the li end and start tags, now that would display them all in line with no spaces visually between your nav items on your loaded page, so you might not want them all to be visually joined like its one bar, so iv also put a code for a space in between the li end and start tags, this will give you a single space between all nav tags visually on your loaded screen but they will still stay tied together so that wont go staking up if you make screen narrow.
I am having the same problem with my menu items wrapping to the next line. It took a few changes. First, I had to set the <ul> to have a max-height and overflow set to hidden. Then I just had to set a width to the parent container.
In my case, since the design is responsive and the area available changes (since the menu is flanked on both sides by elements with preset hard widths) I had to expand the area given as it grows.
#primary-menu {
display: none;
}
#media screen and (min-width: 59em) {
#primary-menu {
display: inline-block;
width: 74%;
}
}
#media screen and (min-width: 64em) {
#primary-menu {
width: 78%;
}
}
#media screen and (min-width: 78.75em) {
#primary-menu {
width: 83%;
}
}
ul {
max-height: 53px;
overflow: hidden;
}
<div id="primary-menu" class="menu">
<ul class="menu menu__navigation--primary">
<li class="first leaf active-trail">
Equipment
</li>
<li class="leaf">
Solutions
</li>
<li class="leaf">
Services
</li>
<li class="leaf">
Locations
</li>
<li class="leaf">
Our Company
</li>
<li class="last leaf">
Contact Us
</li>
</ul>
</div>
You should give "display:flex" to "ul" tag