background image height cut - css

I´m trying to figure out why the background image on my a:selected class is being cut both bottom and top. I´ve tried assigning height:!important; and min-height; to .main_menu ul li and .main_menu ul li a.selected, but seems like something else is limiting the background image size (17x21px)
I wanted to provide an image, but since I´m new they won´t let me do so :(
The image is a circle and it´s being sliced bottom and top, just as it was to fit into a smaller container
Here´s the code, thanks for any suggestion!
.menu_container{
position: absolute;
float: left;
width: 270px;
margin-top: 220px;
}
.main_menu ul {
padding: 0px;
margin:0px;
list-style-type: none;
}
.main_menu ul li {
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
letter-spacing:4px;
text-align:right;
line-height:35px;
list-style-type:none;
}
.main_menu ul li a {
padding-right: 25px;
text-decoration:none;
color:#999;
}
.main_menu ul li a.selected {
color: #bc4c9b;
font-weight:bold;
background: url(images/circle.gif) right center no-repeat;
height: 35px!important;
}
.main_menu ul li:hover {
text-decoration:none;
color:#999;
font-weight:bold;
background:url(images/circle_grey.gif) right center no-repeat;
}

try and rewrite the following rule:
.main_menu ul li a {
padding-right: 25px;
text-decoration:none;
color:#999;
display:block;
}

Hey i think you can give to
anchor tag display: inline-block; or give to line-height
as like this
.main_menu ul li a{
display:inline-block;
line-height:35px;
}

Your background is attached to a anchor tag (.main_menu ul li a) and is therefor sized after font-size. To see the whole background file, you need to make anchor element to block or you can use padding.
Use:
display: inline-block;
or
display: block;
or use padding for .main_menu ul li a

You just need to define display:inline-block; in your li a see your updated css :-
.menu_container{
position: absolute;
float: left;
width: 270px;
margin-top: 220px;
}
.main_menu ul {
padding: 0px;
margin:0px;
list-style-type: none;
}
.main_menu ul li {
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
letter-spacing:4px;
text-align:right;
line-height:35px;
list-style-type:none;
}
.main_menu ul li a {
padding-right: 25px;
text-decoration:none;
font-weight:bold;
color:#999;
display:inline-block;
}
.main_menu ul li a.selected {
color: #bc4c9b;
font-weight:bold;
background: url(http://i.imgur.com/TXNfW.gif) right center no-repeat;
}
.main_menu ul li a:hover {
text-decoration:none;
color: #595959;
font-weight:bold;
background:url(http://i.imgur.com/5Ic6o.gif) right center no-repeat;
}
see the demo:- http://jsbin.com/agavid/13/edit

Related

Navigation bar visited selector not changing color

I am having problems with my navigation bar. I want it to show a different color after the link has been visited. I read an answer from code academy, Stack O/F and other sites saying that "The pseudo-class_selector must follow the following order for it to work.
:link
:visited
:hover" (codeacademy-Submitted by Samrudhi Sharma). I tried this, but nothing happened. I've really gotten myself confused now. Thanks for your help.
My code:
#nav {
width:100%;
float: left;
margin: 20px;
padding: 0;
border-top: 5.5px solid red;
border-bottom: 5.5px solid red;
line-height: 1.8em;
display:inline-block;
clear:both;
}
#nav ul {
float: left;
margin: auto;
width: 1024px;
margin:0px;
list-style: none;
}
#nav ul li {
color: orange;
font-size:1.5em;
float: left;
width: 150px;
padding: 0px;
margin:0px;
list-style:none;
}
#nav ul li a {
border-left:1px solid #fff;
text-align:center;
display: block;
width: auto;
height: 25px;
text-decoration: none;
}
#nav ul li:visited a{
background:yellow;
color:#FFFFFF;
text-decoration:none;
}
#nav ul li:hover a{
background:#C60;
color:#FFFFFF;
text-decoration:none;
}
Place a:visited on the <a>.
Have a fiddle - Fiddle link! (Click "Run" in the jsfiddle header if the yellow does not render.)
CSS
#nav li a:visited {
background:yellow;
color:#F00;
text-decoration:none;
}
you should use the pseudo-classes on your anchor, not on the list element. So a:visited instead of li:visited, because you visit the anchor's link, not the list element's ;)

Navigation Menu Alighment CSS

I'd like to have my navigation menu on my site span the width evenly. Here is an example of what I'm trying to accomplish, notice how the links are spaced evenly and stretch the entire width of the navigation bar.
I'm not exactly sure what code to use to accomplish this. I tried margin:auto but that didn't seem to work.
Here is the CSS that I have:
.mainNav{
height:30px;
padding-bottom:0px;
margin:0 !important;
position: relative;
border-top: 1px #d5d5d5 solid;
border-bottom: 1px #d5d5d5 solid;
}
.mainNav a {
font-size:16px;
-webkit-transition:none;
-moz-transition:none;
-o-transition:none;
transition:none;
position: relative;
}
.mainNav ul {
list-style-type: none;
list-style-image: none;
}
.mainNav li {
float:left;
margin: 0 auto;
position: relative;
list-style-type: none;
list-style-image: none;
}
.mainNav li a {
text-transform:uppercase;
padding:0 0 0 36px;
display:block;
padding-bottom:13px;
}
.mainNav li ul {
display: none;
margin:0 !important;
}
.mainNav li:hover > ul, .mainNav li.hover > ul {
display: block;
position: absolute;
top: 35px;
left: 0;
z-index: 1000;
width: 180px;
}
.mainNav li > ul {
height:auto;
width: auto;
background: #fff;
border:1px solid #efefef;
padding:0;
}
.mainNav li > ul li {
width:180px;
padding: 0;
position: relative;
height:35px;
border-bottom:1px solid #efefef;
}
.mainNav li > ul li:last-child{
border-bottom:none;
}
.mainNav li > ul li a {
text-transform:none;
height:22px;
padding: 5px 10px 0px 15px;
text-align: left;
font-size: 13px;
line-height:25px;
color:#333;
}
.mainNav li > ul li a:hover {
border:none;
}
.mainNav li ul li:hover > ul, .mainNav li ul li.hover > ul {
display: block;
position: absolute;
top:0;
left: 180px;
z-index: 0;
width: 180px;
}
If you turn off javascript and reload that wordpress theme that you want to replicate, you'll notice that the styling breaks.
That is because the margin's set on the list items to space them out evenly, is calculated using javascript and then applied.
You could write a javascript solution to style your list items or a quick fix would be to hard code the widths of the list items, e.g:
Change your current block of CSS:
.mainNav li a {
text-transform:uppercase;
padding:0 0 0 36px;
display:block;
padding-bottom:13px;
}
To the following:
.mainNav li a {
text-transform:uppercase;
text-align: center; /*added*/
width: 117px; /*added*/
padding:0; /*edited*/
display:block;
/*padding-bottom:13px;*/ /*removed*/
}
It looks fixed to me. Screenshot of your site in firefox, with applied styles seen in firebug:

a:hover not working on menu li items

I´m building a vertical menu in CSS, but I can´t get the a:hover to work, it´s just doing nothing. I´ve been searching and reviewing the code (I´m new to CSS), but can´t figure it out...if anyone has any suggestions, much appreciated :)
Here´s CSS:
.menu_container{
position: absolute;
float: left;
width: 270px;
margin-top: 220px;
}
.main_menu ul {
padding: 0px;
margin:0px;
list-style-type: none;
}
.main_menu ul li {
padding-right: 25px;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
letter-spacing:4px;
text-align:right;
line-height:35px;
list-style-type:none;
}
.main_menu ul li a {
text-decoration:none;
color:#999;
}
.main_menu ul li a:hover {
text-decoration:none;
color:#999;
font-weight:bold;
background:url(images/circle_grey.gif) right center no-repeat;
padding-right: 25px;
float:right;
}
.main_menu ul li a.selected {
background: url(images/circle.gif) right center no-repeat;
padding-right: 25px;
float:right;
color: #bc4c9b;
font-weight:bold;
}
HTML:
<div class="menu_container">
<div class="main_menu">
<ul>
<li>HOME</li>
<li><a href="quienes_somos.html" class="selected" >QUIÉNES SOMOS</a></li>
<li>Consultoría</li>
<li>Capacitación</li>
<li>Académico / ARTÍCULOS</li>
<li>Alianzas</li>
<li>Proyectos</li>
<li>Contacto</li>
</ul>
</div>
</div>
The menu was being floated to the left on hover and also on the .selected class and that was what was causing the problem. Here are the fixed classes with the float properties removed:
.main_menu ul li a:hover {
text-decoration:none;
color:#999;
font-weight:bold;
background:url(images/circle_grey.gif) right center no-repeat;
padding-right: 25px;
}
.main_menu ul li a.selected {
background: url(images/circle.gif) right center no-repeat;
padding-right: 25px;
color: #bc4c9b;
font-weight:bold;
}

How can I fix my drop down?

if you open the following link
http://dev.scopedesign.com/client/nyfarmersmarket_02/
you find an navigation bar if you go on "ABOUT US" you will see a drop down..
then you se the problem in drop down
now i want to give you a little idea from how i make this..
I am working on joomla CMS, & i do some changes in navigation module to get my style now the follwing CSS i used for this.. the problem is it is displaying the .parent.active a
background in drop downs i dont want that for this purpose i made .parent.active a ul
but it doesnt work..
you can check this how it works by inspect element in the browser.
.parent.active a{
background-image:url(../images/selected.png);
background-repeat:repeat-x;
padding-top:13px;
padding-bottom:13px;
}
.parent.active a ul{
background-image:none !important;
background-repeat:none;
padding-top:0px !important;
padding-bottom:0px !important;!
}
.menusan
{
/* Use these parameters to positions your menu. */
position: absolute;
// left: 10px;
}
.menusan, .menusan li, .menusan li ul { /* all lists */
padding: 0;
margin: 0;
// list-style: none;
display:block;
float:left;
}
.menusan li a{
padding-left:20px;
padding-right:18px;
}
.menusan li a:hover{
background-image:url(../images/selected.png);
background-repeat:repeat-x;
padding-top:13px;
padding-bottom:13px;
}
.menusan li{ /* all list items */
padding-top:11px;
padding-bottom:11px;
// padding-left:20px;
// padding-right:18px;
-moz-border-right:#537d28 groove 2px;
border-right:#7cb43f groove 2px;
[border-right:#537d28 groove 2px;
border-right:#7cb43f groove 2px;/
border-right:#7cb43f groove 2px;]
}
.menusan li ul { /* second-level lists */
//top:35px;
margin-top:13px;
float:left;
position: absolute;
border: none;
left: -98%; /* Use left instead of display to hide menus; display: none isn’t read by screen readers. */
}
.menusan li ul li{
display:list-item;
float:none;
border: none;
background-color:#537d28;
color:#fff;
//padding:10px 10px 24px 10px;
}
.menusan li ul li:hover{
display:list-item;
float:none;
background-color:#96c73d;
}
.menusan li ul li a{
display:block;
float:left;
}
.menusan li ul li a:hover{
display:block;
float:left;
background-color:#96c73d;
}
.menusan li:hover ul, .menusan li.sfhover ul { /* lists nested under hovered list items */
left: auto; /* change is to 10px, 20px, etc for indenting the sub menu */
border: none;
display:block;
float:left;
}
/* **************** Dropdown Menu styling end here ***************/
One thing i specialy want to let you know guys that it is difficult to make div in it or cheange style name because it is a dynamic module.
Cleaned up and fixed your CSS, try this:
.navigation {
background-color:#537D28;
color:#fff;
float:left;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
height:40px;
margin-bottom:0.6em;
width:100%;
}
.menusan {
margin: 0;
list-style-type: none;
font-weight:700;
float: left;
color:#fff;
}
.menusan > li {
margin:0;
float: left;
border-right:1px groove #7cb43f;
position:relative;
}
.menusan li a {
display:block;
height:40px;
line-height:40px;
padding:0 25px;
text-decoration:none;
color:#fff;
}
.menusan .active {
background: url("http://dev.scopedesign.com/client/nyfarmersmarket_02/templates/nyfm/images/selected.png") repeat-x center center;
}
.menusan li a:hover {
background: url("http://dev.scopedesign.com/client/nyfarmersmarket_02/templates/nyfm/images/selected.png") repeat-x center center;
}
.menusan li.parent ul {
position:absolute;
z-index:9999;
top:40px;
left:0;
display:none;
background-color:#537D28;
}
.menusan li.parent:hover ul {
display:block;
}
.menusan li.parent ul a {
float:left;
}
.menusan li.parent ul a:hover {
background-color:#70A835;
}
.menusan li.parent ul a {
width:55px;
}

IE 6 and 7 bug making third tier navigation float to away

I'm having problems trying to figure out why my drop down navigation is settling under where they are suppose to in IE 6 and IE 7. Any help you could give me would be life saving for me.
the css file for the drop down nav
#nav-bar { /*Container Div*/
width: 950px;
height: 45px;
background-image:url(images/nav-bar-background.jpg);
background-repeat: no-repeat;
margin: 7px 0 2px 0;
z-index:999;
position:relative;
padding:0;
}
/*First Level*/
#nav-bar ul {
padding: 10px;
text-align:center;
margin-top: 6px;
}
#nav-bar ul li {
font-family: Arial, Helvetica, sans-serif;
color: #585858;
font-size: 14px;
display: inline;
padding:0 9px 40px 9px;
text-align:center;
}
#nav-bar ul li a {
text-decoration: none;
color: #585858;
}
/*First Level HOVER*/
#nav-bar ul li a:hover {
background-image: url(nav.png);
background-repeat: repeat-x;
}
* html ul#nav-bar li a {
height:37px;
margin-top:-10px;
}
ul#nav-bar>li a:hover, ul#nav-bar>li:hover {
background-position:0px -20px;
height:37px;
text-decoration:none;
}
* html ul#nav-bar li a:hover, * html ul#nav-bar li:hover, * html ul#nav-bar li.hover {
background-position:0px -20px;
height:27px;
}
#nav-bar ul ul {
background-image:url(images/secondtierbg.gif);
display:none;
}
#nav-bar ul ul li {
width:100px;
}
#nav-bar ul ul li a {
line-height:26px;
}
#nav-bar ul li {
font-family: Arial, Helvetica, sans-serif;
color: #585858;
font-size: 14px;
display: inline;
padding: 10px 9px 20px 9px;
text-align:center;
}
#nav-bar ul li a {
text-decoration: none;
color: #585858;
}
#nav-bar li:hover ul, #nav-bar li.hover ul {
display:inline;
position:absolute;
left:0;
top:44px;
width:950px;
height:26px;
margin:0 auto;
padding: 0;
z-index:200;
}
* html #nav-bar li.hover ul {
height:37px;
}
/*
#nav-bar li:hover li {
list-style:none;
display:inline;
color:#fff;
margin:5px 0px 0 20px;
padding:0;
}
*/
#nav-bar li:hover li a, #nav-bar li.hover li a {
color:#fff;
font-size:12px;
font-family:Arial, Helvetica, sans-serif;
text-align:center;
margin-top: 10px;
padding: 5px;
text-decoration:none;
}
#nav-bar li:hover li a:hover {
background:none!important;
}
/* THIS IS FOR DROP DOWNS */
#nav-bar ul ul ul {
visibility: hidden;
background-image: none;
display: block;
margin: 0px;
padding: 0px;
list-style: none;
}
#nav-bar ul ul ul li {
display: block;
width:100px;
height: auto;
font-family: Arial, Helvetica, sans-serif;
color:#FFF;
font-size: 11px;
background-color:maroon;
border-style: solid;
border-color: white;
border-width: 1px 1px 0 1px;
padding: 5px 0;
float: none;
clear: both;
}
#nav-bar ul ul #firstrange li {
width:100px;
}
#nav-bar ul ul ul li:last-child {
border-bottom: 1px solid white;
/*background:transparent;*/
}
#nav-bar ul ul ul li a{
cursor:pointer;
line-height:14px;
}
#nav-bar ul ul li:hover ul {
visibility: visible;
left:0;
position:absolute;
margin-top:0;
top:31px;
z-index:220;
}
#nav-bar ul ul li:hover {
position:relative;
}
the link is:
http://www.paysonsecure.com/colonialwarsct/
notes/advice/question:
Think about how you can make this work in two levels.
I had difficulties trying to get the second level to show in IE(Something you might wanna work on too).
Consider having a vertical sub-menu. It's easier for the user to navigate.
Question. How much content is going to go in each year? If not much, maybe you can group years content.
I re-worked the css for the navigation I think its a good start - if you wish.
http://jsfiddle.net/EvRem/1/
Hope this made sense

Resources