Hi all I have simple menu but I don't know how to make link in whole square. Now only working on link click.
<ul><li>Menu 1</li>
<li>Menu 2</li>
<li>
Menu 3
<ul>
<li>Menu 4</li>
<li>Menu 5</li>
<li>Menu 6</li>
</ul>
</li>
</ul>
CSS:
ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #fff;
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;
}
ul li:hover {
background: #555;
color: #fff;
}
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;
}
ul li ul li {
background: #555;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
ul li ul li:hover { background: #666; }
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
JSFiddle Demo
Remove the padding from li and add it to the a instead. Also set your a to display:block.
Move your padding from the <li> to the <a> and set your anchor to display: block;
/* add this selector */
li > a {
padding: 15px 20px;
display: block;
}
Your updated jsFiddle: https://jsfiddle.net/q5y1sg9v/1/
It will open the link when the element gets clicked. You want it to open the link when the grey box is clicked.
Therefore you have to make the size of the same size as the grey box. And as the others pointed out you will have to remove the padding from li and give it to a instead (or specify its height and width).
Related
I have this navigation, It's working fine. But when I'm apply tags in the li, the text hover, text color effect is just getting messy. I want to apply anchor styling in the css so the text styling remain same after after apply ahrefs.
HTML
<ul class="rexademenu"><li class="rexademenu">Home</li>
<li>About</li>
<li>
Portfolio
<ul class="rexadesubmenu">
<li>Web Design</li>
<li>Web Development</li>
<li>Illustrations</li>
</ul>
</li>
<li>Blog</li>
<li>Contact</li>
</ul>
CSS
.rexademenu {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
.rexademenu li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #fff;
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;
}
.rexademenu > li:hover {
background: #555;
color: #fff;
}
.rexadesubmenu {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width: 150px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
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;
}
.rexadesubmenu > li {
background: #555;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
.rexadesubmenu > li:hover { background: #666; }
.rexademenu > li:hover .rexadesubmenu {
display: block;
opacity: 1;
visibility: visible;
http://jsfiddle.net/oyp6qkyz/2/
Update your css like this:
Css
.rexademenu li a{
color:#666666;
text-decoration:none;
}
.rexademenu li a:hover, .rexademenu li:hover a{
color:#ffffff;
}
Updated Fiddle
(answer derived from comments)
If you don't want underlining and blue color on the menu, you could add this to the css:
.rexademenu li a, .rexademenu li a:hover {
text-decoration: none;
color: #AAA;
}
.rexademenu li a:hover {
text-decoration: none;
color: white;
}
You override the code in your global css-file with this.
My drop down menu is hidden behind my "mainsection" tag and I'm not sure what I can do to expose it. It needs to lay on top of the "mainsection" tag area and not behind it.
Here is the jsfiddle : http://jsfiddle.net/nSmZ9/
and here is the html code
<header>
<ul class="right-nav-after-login">
<li>Home</li>
<li>About</li>
<li>
Menu
<ul>
<li>Account</li>
<li>My Gifts</li>
<li>Log off</li>
</ul>
</li>
<li>Contact</li>
</ul>
</header>
<article>
<section class="mainsection"></section>
</article>
here is my css
header {
height: 66px;
margin-left: 75px;
margin-right: 75px;
border: 2px solid black;
}
.mainsection {
background-color: #a6dbed;
height: 500px;
position: relative;
}
.right-nav-after-login {
float: right;
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
.right-nav-after-login li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #fff;
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;
}
.right-nav-after-login li:hover {
background: #555;
color: #fff;
}
.right-nav-after-login 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;
}
.right-nav-after-login li ul li {
background: #555;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
.right-nav-after-login li ul li:hover { background: #666; }
.right-nav-after-login li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
.mainsection is defined later in your HTML than the menu, and since both are taken out of the regular flow, .mainsection will cover the menu . I'd recommend a more natural layout but lacking that, you can try this:
.right-nav-after-login, .right-nav-after-login * {
z-index: 1;
}
This will guarantee the menu and everything within to be above everything else, as long as the elements have position set to anything except static.
You can use z-index to specify the vertical stack order of elements. (Note that in order for z-index to work, an element must have absolute or relative positioning.)
There are different ways to do this. You just need to ensure that the element you want on top has a higher z-index. Here is one solution:
.mainsection {
....
z-index:1;
}
.right-nav-after-login li ul li {
....
position:relative;
z-index:2;
}
See demo
Take this off of .mainsection.
position: relative;
//inset this code
.right-nav-after-login li ul{z-index:100;}
I have a problem with this simple made list. Only the text is clickable, I'm tying to make the whole block of the text to be clickable but I have failed. I've tried almost everything I could find but seems nothing is working for my code.
My HTML5
<ul>
<li>Αρχική</li>
<li>Συμπληρώματα
<ul>
<li>Πρωτεΐνες</li>
<li>Αμινοξέα</li>
<li>Κρεατίνες</li>
<li>Νιτρικά</li>
<li>Λιποδιαλυτικά</li>
<li>Μπάρες Πρωτεΐνης</li>
<li>Ροφήματα</li>
<li>Ειδικά</li>
</ul>
</li>
<li>Μάρκες
<ul>
<li>Maximuscle</li>
<li>IronMaxx</li>
<li>Leofit</li>
</ul>
</li>
<li>Υπηρεσίες
<ul>
<li>Λιπομέτρηση</li>
<li>Διατροφή</li>
<li>Πρόγραμμα Προπόνησης</li>
</ul>
</li>
<li>Κατάστημα</li>
</ul>
And my CSS3
ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
position: relative;
top: 50px;
}
ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #2B2B2B;
color:#CCC;
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;
}
ul li:hover {
background: #555;
color: #fff;
}
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;
}
ul li ul li {
background: #555;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
ul li ul li:hover { background: #666; }
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
Excuse my ignorance but I am new to the whole thing.
Instead of targetting the ul li elements as clickable, you need to target the 'a' (Anchor) as it is this that is clicked.
For example, if you add padding to the 'a' then you will notice the cursor change before you hover over the text.
If you are looking at doing a navigation menu whet you want all your links to of the same width you need to make the 'a' a block level element so that it takes up all the wish of its patent li.
follow a simple tutorial such as: http://www.cssterm.com/css-menus/vertical-css-menu/simple-vertical-menu
I see you are also trying to do nested menus (menu in a menu item). You can find many tutorials that can help with nested menus also.
I'm having trouble creating the third level fligh out for a horizontal css menu. I've tried many different changes to the css to no avail. I have included the menu html and the css. What changes do I need to make to the css to have it work?
When 'ADD SCORES' is hovered over the 2 menus should show to the right
#menu {
background-color: #66A366;
padding: 6px 0 6px 20px;
}
#menu ul li a {
color: #fff;
text-decoration: none;
font-family:"Arial Narrow", "Myriad Pro";
}
#menu li {
color: #fff;
text-decoration: none;
font-family:"Arial Narrow", "Myriad Pro";
}
ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
ul li {
font: bold 14px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #66A366;
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;
}
ul li:hover {
background: #555;
color: #fff;
}
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;
z-index:1000;
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 li ul li {
background: #555;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
ul li ul li:hover {
background: #666;
}
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
ul li ul li:hover li{
display: block;
opacity: 1;
visibility: visible;
}
ul li ul li ul li{
padding: 15px 20px;
font: bold 14px/18px sans-serif;
display: none;
position: relative;
top: -48px;
left: 154px;
width: 120px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
opacity: 0;
z-index:1000;
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;
}
<div id="menu">
<ul>
<li>SCORES
<ul>
<li>ADD SCORES
<ul>
<li>Level 3-A-1</li>
<li>Level 3-A-2</li>
</ul>
</li>
<li>EDIT SCORES</li>
</ul>
</li>
<li>PLAYERS
<ul>
<li>ADD PLAYER</li>
<li>EDIT PLAYERS</li>
</ul>
</li>
<li>COURSES
<ul>
<li>ADD COURSE</li>
<li>EDIT COURSES</li>
</ul>
</li>
<li>ADMIN</li>
</ul>
</div>
Demo FIDDLE
I'm not sure how you want your menu to look like, but I noticed that you forgot to wrap the tabs inside a <ul></ul> tag.
If you do that, the menu will look and behave like what most users would expect.
<div id="menu">
<ul> <-- here
<li>SCORES
// some code
<li>ADMIN</li>
</ul> <-- and here
</div>
You can save your time using Swimbi - Swift Menu Builder
- http://f-source.com/swimbi/
have a look at menu demo
So basically I have a simple menu that is not displaying correctly in IE at all.
Have visited another few posts that has this same problem, although they didn't seem to work.
Here is my HTML:
<div id="topnav">
<ul>
<li>Car Sales</li>
<li>Boat Sales</li>
<li>Caravan Sales</li>
<a href="#" title="Truck Sales"><li>Truck Sales</li><a>
<li>Equipment Sales</li>
<li>Bike Sales</li>
</ul>
</div>
Here is my CSS:
#topnav
{
text-align:center;
width:100%;
background-color:#ffffff;
}
#topnav ul a li
{
display:inline-block;
font: 12px/18px sans-serif;
color:#000000;
}
#topnav ul {
width:100%;
text-align: left;
display: inline;
margin: 0;
padding: 0px;
list-style: none;
}
#topnav ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 5px 20px;
background: #fff;
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;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
#topnav ul li:hover {
background: #555;
color: #fff;
}
#topnav ul li a:hover{ color:#ffffff; }
#topnav 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;
}
#topnav ul li ul li {
background: #555;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
#topnav ul li ul li:hover { background: #666; }
#topnav ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
JSfiddle:
http://jsfiddle.net/menEk/1/
All help and suggestions would be greatly appreciated.
Your HTML code is wrong!
try it:
<ul>
<li>Car Sales</li>
<li>Boat Sales</li>
<li>Caravan Sales</li>
<li><a href="#" title="Truck Sales">Truck Sales<a></li>
<li>Equipment Sales</li>
<li>Bike Sales</li>
</ul>
and
#topnav ul li a
{
display:inline-block;
font: 12px/18px sans-serif;
color:#000000;
}
Tha a tag should be in li tag!
If you gave #topnav an exact width such as 100px and gave each li in it a width of 100% they would be forced to align vertically.
I have made a JS Fiddle to show it.
Changed css widths have:
/* CHANGED */
above them.
http://jsfiddle.net/menEk/2/