So I added an animation to my navigation bar at repo.itechy21.com and its made the drop down text push to the right side of the drop down when I want it centred. The relevant CSS it attached below (along with HTML)
CSS:
/* Start nav bar*/
#header {
height: 100px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
#content {
margin-left: auto;
margin-right: auto;
padding: 20px;
text-align: center
}
#menu, #menu nav {
margin:0 auto;
padding:0;
position: center;
text-align: center
}
#menu {
display: inline-block;
list-style:none;
background-color: #98bf21;
border-radius: 10px;
text-align: center
}
#menu li {
float: left;
position: relative;
list-style: none;
text-align: center
}
#menu > li:hover > ul {
display:block;
background-color: #98bf21;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
visibility:visible;
opacity:1;
filter:alpha(opacity=100);
}
#menu > li > ul {
/*animation control*/
visibility: hidden;
opacity: 0;
filter:alpha(opacity=0);
-webkit-transition:.5s ease;
-moz-transition:.5s ease;
-o-transition:.5s ease;
transition:.5s ease;
position: relative;
}
#menu li a {
display: inline-block;
width: 120px;
font-weight: bold;
color: #FFFFFF;
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
/*animation control*/
-o-transition:color .2s ease-out;
-ms-transition:color .2s ease-out;
-moz-transition:color .2s ease-out;
-webkit-transition:color .2s ease-out;
}
#menu li a:hover {
color: black;
-o-transition:color .5s ease-in;
-ms-transition:color .5s ease-in;
-moz-transition:color .5s ease-in;
-webkit-transition:color .5s ease-in;
}
/*End of nav bar css*/
HTML navbar layout (minus links):
<ul id="menu">
<li>Home</li>
<li>Modules
<ul>
<li>Remove Retina</li>
<li>Device Information</li>
<li>Syslogd Fixer</li>
</ul>
</li>
<li>Toolkit</li>
<li>Donate</li>
<li>Blog</li>
</ul>
Any suggestions on how to fix this and get the align back to what it used to be?
I hope this will help.
/* Start nav bar*/
#header {
height: 100px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
#content {
margin-left: auto;
margin-right: auto;
padding: 20px;
text-align: center
}
#menu, #menu nav {
margin:0 auto;
padding:0;
position: center;
text-align: center
}
#menu {
display: inline-block;
list-style:none;
height: auto;
width: auto;
background-color: #98bf21;
border-radius: 10px;
text-align: center;
-webkit-transition:.5s ease;
-moz-transition:.5s ease;
-o-transition:.5s ease;
transition:.5s ease;
}
#menu > li {
float: left;
position: relative;
display: inline-block;
width: 120px;
list-style: none;
text-align: center;
}
#menu ul > li {
display: block;
width: 100%;
list-style: none;
text-align: center;
}
#menu > li:hover > ul {
display:block;
background-color: #98bf21;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
visibility:visible;
opacity:1;
filter:alpha(opacity=100);
}
#menu > li > ul {
/*animation control*/
display:none;
width: 120px;
height: auto;
margin: 10px 0 0 0;
opacity: 0;
z-index: 10;
filter:alpha(opacity=0);
-webkit-transition:.5s ease;
-moz-transition:.5s ease;
-o-transition:.5s ease;
transition:.5s ease;
}
#menu li a {
font-weight: bold;
color: #FFFFFF;
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
/*animation control*/
-o-transition:color .2s ease-out;
-ms-transition:color .2s ease-out;
-moz-transition:color .2s ease-out;
-webkit-transition:color .2s ease-out;
}
#menu li a:hover {
color: black;
-o-transition:color .5s ease-in;
-ms-transition:color .5s ease-in;
-moz-transition:color .5s ease-in;
-webkit-transition:color .5s ease-in;
}
/*End of nav bar css*/
Related
I am having a ton of trouble. I am trying to create a drop down menu from 'about' and have not been able to center the menu correctly. It is always right of the menu. I believe it to have to do with the size of 'about'.
How can I fix this?
.nav-main {
position: absolute;
top: 0;
height: 65px;
width: 100%;
text-align: center;
}
.nav-main ul {
position: relative;
margin: 0 auto;
padding: 0;
list-style: none;
font-size: 22px;
line-height: 100%;
font-family: 'Futura W01 Bold', sans-serif;
text-align: center;
text-transform: uppercase;
display: inline-block;
width: 90%;
height: inherit;
}
.nav-top {
position: relative;
margin: 0;
padding: 0 66px 0 50px;
float: none;
display: inline-block;
list-style: none;
height: inherit;
background: transparent url(../images/nav-divide.png) no-repeat right center;
}
.nav-top:first-child {
padding-left: 0;
}
.nav-top:last-child {
background-image: none;
padding-right: 0;
}
.nav-top > a {
position: relative;
display: block;
margin: 0;
color: #6f6f6f;
text-decoration: none;
padding-top: 20px;
padding-bottom: 5px;
-moz-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
transition: all 0.3s ease;
}
.nav-top a:hover,
.nav-top.active a {
color: #454545;
border-bottom: 4px solid #00e9d9;
text-decoration: none;
}
.nav-top ul {
display: none;
position: absolute;
}
.nav-top:hover ul {
display: inline;
}
.nav-top li {
float: center;
background-color: #e9e9e9;
}
.nav-top li > a {
position: relative;
display: inline;
margin: 0;
color: #6f6f6f;
text-decoration: none;
padding-top: 20px;
padding-bottom: 5px;
-moz-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
transition: all 0.3s ease;
}
<nav class="nav-main" role="navigation">
<ul>
<li class="nav-top">Welcome</li>
<li class="nav-top">About
<ul>
<li>Services</li>
<li>Clients</li>
<li>Press</li>
<li>Leadership</li>
<li>Twitter</li>
</ul>
</li>
<li class="nav-top">Contact</li>
</ul>
<span class="nav-arrow"></span>
</nav>
Andrews:
To solve you problem, you need to indicate the position of your nested list because you are setting it up as "position: absolute" without coordinates.
Add a "left value" to your UL CSS class in order to solve this issue:
.nav-top ul {
display: none;
position: absolute;
left: 0;
}
I'm trying to make a navigation bar for a hobby website to display my photography and other interest's of mine, I'm having slight issues with the position of a drop-down bar I have.
I wanted to know how I would be able to position the drop down menu so when I hover over the music item it would show directly under it. I tried position: relevant, it did work but it shifted all the items to the left of it down to align with the drop down menu.
http://jsfiddle.net/daCrosby/Ly8wuws1/
body{
background-color: #333;
}
nav ul {
list-style: none;
margin: 10px;
padding: 0;
font-family: 'Roboto', sans-serif;
font-weight: bold;
}
nav li {
display: inline-block;
margin: 0 5px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
nav a {
color: black;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
nav a:hover {
color: #12242d;
}
nav span {
display: block;
color: rgba(255,255,255,0.6);
}
.Inav ul {
list-style: none;
margin-top: 20%;
padding: 0;
text-align: left;
top: 0;
left: 0;
position: fixed;
right: 0;
text-align: center;
font-family: 'Roboto', sans-serif;
font-weight: bold;
}
.Inav nav ul li {
display: inline-block;
margin: 0 5px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.Inav nav a {
color: black;
position: block
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
text-decoration: none;
}
.Inav nav a:hover {
color: #12242d;
}
.Inav nav span {
color: rgba(255,255,255,0.6);
}
.Inav ul li:hover ul{
display: block;
margin: 0px;
padding: 0px;
}
.Inav ul li ul{
display: none;
position: absolute;
}
.Inav ul li ul li{
display: block;
}
.Inav ul ul a{
color: white;
}
<div class="Inav">
<nav>
<ul>
<li><span>Home</span></li>
<li><span>FAQ</span></li>
<li><span>Honesty</span></li>
<li><span>Rand2</span></li>
<li><span>Rand3</span></li>
<li><span>Music</span>
<ul>
<li>Kanye</li>
<li>Drake</li>
</ul>
</li>
</ul>
</nav>
</div>
You need to add position: relevant to the parent list items, then add positioning top and left on the sub menu.
nav li {
position: relative;
}
.Inav ul li ul{
position: absolute;
top: 100%; /* modify as necessary */
left: 0px; /* modify as necessary */
}
http://jsfiddle.net/daCrosby/Ly8wuws1/1/
I'm creating a website, and currently I am having issues with my navigation bar. The issue I am having is with the active link. The background won't fit to the size of the initial button like I want it to. The background is just highlighting the text basically.
<div class="nav">
<ul>
<li>Home</li>
<li><a class="active" href="cage-habitat.html">Cage & Habitat</a>
<ul>
<li>Litter Training</li>
</ul>
</li>
<li>Food & Treats</li>
<li>Dust Bath & Care</li>
<li>Safe Toys</li>
<li>Chinquiry</li>
</ul>
</div>
.nav {
background-color: #526655;
}
.nav a {
color: #fff;
text-decoration: none;
}
.nav ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
}
.nav ul li {
color: #fff;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #526655;
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;
}
.nav ul li:hover {
background: #94b399;
color: #fff;
}
/* drop down styles */
.nav ul li ul {
padding: 0;
position: absolute;
top: 42px;
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;
}
.nav ul li ul li {
background: #94b399;
display: block;
color: #fff;
}
.nav ul li ul li:hover {
background: #94b399;
}
.nav ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
/* end dropdown styles */
.active {
background: #94b399;
}
Any help would be appreciated. https://jsfiddle.net/cweav3r/7j25e8jh/
<ul><li><a href="litter-train-chinchilla.html">Litter
Training</a></li></ul> is taking extra space .
DEMO : http://jsfiddle.net/b89kds70/10/
<div class="nav">
<ul>
<li>Home</li>
<li><a class="active" href="cage-habitat.html">Cage & Habitat</a>
</li>
<li>Food & Treats</li>
<li>Dust Bath & Care</li>
<li>Safe Toys</li>
<li>Chinquiry</li>
</ul>
</div>
.nav {
background-color: #526655;
}
.nav a {
color: #fff;
text-decoration: none;
}
.nav ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
position:relative;
}
.nav ul li {
color: #fff;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #526655;
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;
}
.nav ul li:hover {
background: #94b399;
color: #fff;
}
/* drop down styles */
.nav ul li ul {
padding: 0;
position: relative;
top: 42px;
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;
}
.nav ul li ul li {
background: #94b399;
display: inline;
color: #fff;
}
.nav ul li ul li:hover {
background: #94b399;
}
.nav ul li:hover ul {
position:absolute;
display: block;
opacity: 1;
visibility: visible;
}
/* end dropdown styles */
I'm trying to create a navbar (already done) with a dropdown, but the dropdown keeps spazzing out when I hover over it :(
I made a JS Fiddle of what I've accomplished so far, and I was hoping for some help!
http://jsfiddle.net/kkpp6/
I think it might be due to the display: none; I used in one of the ul's or possibly due to a stupid typo but I can't figure out where!
As well as this, I can't figure out how to make a sub-menu for my sub-menus that already exist.. (so the desc tab has a submenu of swim squad which will also have a sub-menu of other things).. How would I do that? I can't figure out where I would start!
Cheers for all the help in advance!
Try like this: LINK
CSS:
.nav-wrap {
background-color: #125CC1;
text-align: center;
}
ul.navigation-bar li a {
color: #FFFFFF;
background-color: #125CC1;
text-align: center;
padding: 6px;
font-size: 12px;
text-decoration: none;
text-transform: uppercase;
}
ul.navigation-bar li a:hover {
background-color: #06398F;
}
ul.navigation-bar {
text-align: left;
display: inline;
margin: 0;
list-style: none;
}
ul.navigation-bar li {
line-height:28px;
margin-right: -4px;
position: relative;
display: inline-block;
width: 120px;
font-weight: bold;
color: #FFFFFF;
background-color: #125CC1;
text-align: center;
}
ul.navigation-bar li ul {
padding: 0;
position: absolute;
top: 28px;
left: 0;
width: 120px;
-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;
}
ul.navigation-bar li ul li {
background: #125CC1;
display: block;
color: #fff;
}
ul.navigation-bar li ul li:hover {
background: #06398F;
color: #fff;
}
ul.navigation-bar li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
Updated fiddle LINK
Multi-level dropdown menu LINK
On line 38, you set a list to display when the user hovers over a list item. This makes it visible, but also causes the entire menu to shift over so that you're no longer hovering over the list item that triggered that. If you use position:absolute on the list, it won't affect the other elements on the page:
ul.navigation-bar li > ul {
position:absolute;
}
JSFiddle: http://jsfiddle.net/P9SUg/
I also think its because of display:none;, instead of display:none; you should use visibility:hidden;.
and also add
ul.navigation-bar li > ul {
position:absolute;
}
You need to do lot of changes in CSS for making dropdown menu.
.nav-wrap {
background-color: #125CC1;
text-align: center;
}
ul.navigation-bar {
list-style-type: none;
margin: 0;
padding: 0;
}
ul.navigation-bar > li {
display: inline;
position:relative;
}
ul.navigation-bar > li > a {
display: inline-block;
width: 120px;
font-weight: bold;
color: #FFFFFF;
background-color: #125CC1;
text-align: center;
padding: 4px;
font-size: 12px;
text-decoration: none;
text-transform: uppercase;
-webkit-transition: all 0.15s linear;
-moz-transition: all 0.15s linear;
-o-transition: all 0.15s linear;
transition: all 0.15s linear;
}
ul.navigation-bar > li > a:hover {
background-color: #06398F;
}
ul.navigation-bar ul {
display: none;
}
ul.navigation-bar li:hover > ul {
display: block;
position:absolute;
top:23px;
background-color:#ff00ff;
z-index:10;
width:100%;
list-style-type: none;
margin: 0;
padding: 0;
}
ul.navigation-bar li ul li a
{
list-type:none;
text-align: left;
font-weight:normal;
padding: 4px;
font-size: 10px;
text-decoration: none;
text-transform: uppercase;
-webkit-transition: all 0.15s linear;
-moz-transition: all 0.15s linear;
-o-transition: all 0.15s linear;
transition: all 0.15s linear;
}
ul.navigation-bar li ul li:hover
{
background-color:#000;
}
ul.navigation-bar li ul li:hover a
{
color:#fff;
}
FIDDLE DEMO
to see if anyone can tell me why my css button has a radius of action as big around, is there any way to reduce it?
When I put the mouse over the hand that goes in idle state goes far beyond the text of the button, I would like to reduce this area of action, but not as in css
Thank you.
CSS:
/*BOTONES SUPERIOR*/
#botonera-blogsuperior {
width: 900px;
height: 35px;
}
.texto-botones-blogsuperior {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
font-style: normal;
line-height: 10px;
color: #FFF;
padding-top: 0px;
padding-bottom: 0px;
margin-left: 10px;
}
.menu-blogsuperior,
.menu-blogsuperior ul,
.menu-blogsuperior li,
.menu-blogsuperior a {
margin: 0;
padding: 0;
border: none;
outline: none;
}
.menu-blogsuperior {
height: 31px;
width: 900px;
}
.menu-blogsuperior li {
position: relative;
list-style: none;
float: right;
display: block;
height: 21px;
}
.menu-blogsuperior li a {
display: block;
padding: 0 0px;
padding-right: 15px;
margin: 25px -59px;
margin-right: 12px;
line-height: 22px;
text-decoration: none;
background-image: url (boton-fondo-probar.png);
background-repeat:no-repeat;
background-position:center;
height:27px;
width:105px;
background-position:46px -1px;
background-size:69px 24px;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 14px;
color: #000000;
-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;
text-align: right;
text-align: right;
text-align: right;
text-align: right;
}
.menu-blogsuperior li:first-child a { border-left: none; }
.menu-blogsuperior li:last-child a{ border-right: none; }
.menu-blogsuperior li:hover > a {
color: #FF6C6C;
}
.menu-blogsuperior ul {
position: absolute;
top: -109px;
left: 0;
opacity: 0;
background: #1f2024;
-webkit-border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
-webkit-transition: opacity .10s ease .1s;
-moz-transition: opacity .10s ease .1s;
-o-transition: opacity .10s ease .1s;
-ms-transition: opacity .10s ease .1s;
transition: opacity .10s ease .1s;
}
.menu-blogsuperior li:hover > ul { opacity: 1; }
.menu-blogsuperior ul li {
height: 0;
overflow: hidden;
padding: 0;
}
.menu-blogsuperior li:hover > ul li {
height: 36px;
overflow: visible;
padding: 0;
}
.menu-blogsuperior ul li a {
width: 36px;
padding: 10px 0 1px 10px;
margin: 0;
border: none;
border-bottom: 0px solid #353539;
}
.menu ul-blogsuperior li:last-child a { border: none; }
HTML
<div class="botonera-blogsuperior"><ul class="menu-blogsuperior">
<li>INDICE</li>
<li>DINO</li>
<li>LEONES</li>
</ul>
</div>
EXAMPLE:
http://jsfiddle.net/#&togetherjs=vSgITe2BmT
Thanks !!
I just moved all definitions that give shape to the link from the a Tag to the li Tag and replaced the padding with margin.
Add this to your CSS:
.menu-blogsuperior li {
height:27px;
width:105px;
padding: 0 0px;
margin: 25px -59px;
margin-right: 27px;
background-image: url (boton-fondo-probar.png);
background-repeat:no-repeat;
background-position:center;
background-position:46px -1px;
background-size:69px 24px;
text-align: right;
text-align: right;
text-align: right;
text-align: right;
}
And adjust this definition in your CSS so it is exactly like mine:
.menu-blogsuperior li a {
text-decoration: none;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 14px;
color: #000000;
-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;
}
Worked for me in the fiddle.