I have made a nav section with a couple of dropdown buttons.
I would like to set the width of the div's by the text lenght.
I tought I did a pretty good job, according to the result in Firefox. (the exact result I would like)
However, checking the site in Chrome, the whole nav section is completely reacting different.
The text is breaking up, div width isn't right anymore.
But the strangest thing is that when I hover on the buttons, the div width's start to react and changing to the right settings.
Is this a Chrome thing, or do I need to make my code on different way?
I'm using normalize.css in my parent css file.
This is the website: http://callensdecor.be/preview/
HTML:
<nav>
<ul>
<li><a class="selected" href="index.html">Home</a></li>
<li>Onze diensten
<ul>
<li>Schilderwerken</li>
<li>Totaalwerken</li>
<li>Andere werken</li>
</ul>
</li>
<li>Over ons</li>
<li>Contact</li>
</ul>
</nav>
CSS:
nav{
float:right;
padding-top:68px;
}
nav ul{
position: relative;
display: inline-table;
width:100%;
}
nav ul:after {
content: ""; clear: both; display: block;
}
nav li{
float:left;
list-style-type:none;
margin-right:2%;
}
nav ul li a{
display:block;
width:auto;
min-width:75px;
text-align:center;
background-color:#E9E9E9;
color:#555555;
padding:7px 13% 10px;
border-radius:50px;
font-family:"Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
font-size:16px;
text-decoration:none;
}
nav li a:hover, .selected{
background-color:#838383;
color:white;
text-decoration:none;
}
nav ul ul {
display: none;
border-radius: 0px;
padding: 0;
position: absolute;
top: 35px;
width:auto;
margin-left:0%;
}
nav ul li:hover > ul {
display: block;
}
nav ul ul li {
float: none;
position: relative;
}
nav ul ul li a {
color:#555555;
background-color:#E9E9E9;
margin-top:3px;
width:auto;
}
nav ul ul li a:hover {
background: #838383;
color:white;
text-decoration:none;
}
In my Google Chrome this works:
jsfiddle <-- See the jsfiddle
It look's like the padding in the nav ul li a{ is messing it up for you.
As the other answer said it's the 13% padding here:
nav ul li a{
display:block;
width:auto;
min-width:75px;
text-align:center;
background-color:#E9E9E9;
color:#555555;
padding:7px 13% 10px;
border-radius:50px;
font-family:"Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
font-size:16px;
text-decoration:none;
}
that is screwing with you change it to a px value and you should be good to go :D
Related
I made a drop down menu, which works fine for top level items.
But I dunno what CSS to add for second level menu items, to be move them to the right side of the hovered item.
Here is my HTML content:
<ul class="menu">
<li><a href="#" >item1</a></li>
<li>item2</li>
<li>item3
<ul>
<li>subitem1</li>
<li>subitem2</li>
<li>subitem3
<ul>
<li>subsubitem1</li>
<li>subsubitem2</li>
</ul>
</li>
<li>subitem4</li>
<li>subitem5</li>
</ul>
</li>
<li>item4</li>
<li>item5</li>
</ul>
and my actual CSS:
.menu {
border:none;
border:0px;
margin:0px;
padding:0px;
font: 67.5%"Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
}
.menu ul {
background:#333333;
height:35px;
list-style:none;
margin:0;
padding:0;
}
.menu li {
float:left;
padding:0px;
}
.menu li a {
background:#333333 url("seperator.gif") bottom right no-repeat;
color:#cccccc;
display:block;
font-weight:normal;
line-height:35px;
margin:0px;
padding:0px 25px;
text-align:center;
text-decoration:none;
}
.menu li a:hover, .menu ul li:hover a {
background: #2580a2 url("hover.gif") bottom center no-repeat;
color:#FFFFFF;
text-decoration:none;
}
.menu li ul {
background:#333333;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:225px;
z-index:200;
/*top:1em;
/*left:0;*/
}
.menu li:hover ul {
display:block;
}
.menu li li {
background:url('sub_sep.gif') bottom left no-repeat;
display:block;
float:none;
margin:0px;
padding:0px;
width:225px;
}
.menu li:hover li a {
background:none;
}
.menu li ul a {
display:block;
height:35px;
font-size:12px;
font-style:normal;
margin:0px;
padding:0px 10px 0px 15px;
text-align:left;
}
.menu li ul a:hover, .menu li ul li:hover a {
background:#2580a2 url('hover_sub.gif') center left no-repeat;
border:0px;
color:#ffffff;
text-decoration:none;
}
jsfiddle
I'm trying to do a submenu of a submenu of a list menu and told that this may work but i dont know how to add it to css. and weather or not the styles would apply to it if its put into css.
[SOLVED]
Okay, so i managed to solve this ( and now I just have to style widths and hovers ). What I Did was chuck in the css from the answer below, added in this css aswell
.tabs .widget ul, .tabs .widget ul {
margin: 0;
padding: 0;
overflow: visible;
list-style: none;
}
For some reason it was set to { overflow:hidden ; } (wtf!) so i changed that and it seemed to overflow correctly now.
In the menu html, I changed
<ul>
<li><a href="#" >item1</a></li>
....
</ul>
to
<ul class="menu_top">
<li><a href="#" >item1</a></li>
....
</ul>
on line one of the given html.
Now all that I need to do is style {width:225px; } and change the :hover element, thanks for everyones help!
You can use the following CSS:
ul.menu_top {
float:left;
width:70%;
margin: 8px 100px 0 0;
border-radius:4px;
background-color: #c4092a;
list-style-type: none;
z-index:+1;
}
ul.menu_top li {
float: left;
position: relative;
margin: 4px 2em 4px 4px;
padding: 0;
}
ul.menu_top li ul {
visibility: hidden;
position: absolute;
top:100%;
left:0px;
padding:0.5em;
list-style-type: none;
white-space:nowrap;
background-color: #c4092a;
border: 1px solid white;
border-radius:4px;
z-index:+1;
}
ul.menu_top li:hover > ul {
visibility: visible;
z-index: +2;
}
ul.menu_top li ul li {
padding: 0;
margin: 12px 4px;
float:none;
border:0;
min-width:3em;
}
ul.menu_top li ul li ul {
top:0;
left:99%;
}
ul.menu_top a {
background-color:#c4092a;
color:white;
text-decoration:none;
padding:4px;
font-size:18px
}
ul.menu_top a:hover, ul.menu_top a.haschildren.childselected, ul.menu_top a.selected {
background-color:white;
color:blue;
text-decoration:none;
}
ul.menu_top li a.haschildren:after {
content:"\00A0\00A0\25BC";
}
a {
color:#0000aa;
background-color:inherit;
}
body, ul, li { /* normalize for old browsers*/
margin:0;
padding:0;
}
It's taken from my old question. The .menu_top class is used only for distinguishing between the navigation menu and another unordered lists.
JSFiddle code & result page
Roll over the text and the blue block below moves along the blue line. If I do it via position relative and set the blue block to top 20px, it also moves the text down.
Is there a way I can do this purely in CSS, or should I use a background image with the top half set as a transparent gif and the bottom blue?
The code I've tried so far is:
#menu ul {
list-style:none;
margin:0;
padding:10px;
text-align:center;
}
#menu ul li {
display:block;
float:left;
list-style:none;
margin-right: 40px;
font-family: Arial, Helvetica, sans-serif;
color: #FFF;
font-size: 14px;
padding-top: 5px;
padding-bottom: 5px;
height: 39px;
}
#menu ul li a {
display:block;
margin:0px;
padding:0px;
color:#FFF;
text-decoration:none;
font-family: Arial, Helvetica, sans-serif;
margin-right: 5px;
margin-left: 5px;
padding-left: 10px;
padding-right: 10px;
}
#menu ul li a:hover {
color:#fff;
margin-bottom:5px;
padding-bottom:5px;
}
#menu ul li a.active,
#menu ul li a.active:hover {
color:#fff;
background-color: #0488C5;
font-weight:bold;
}
I am still learning so excuse any mistakes!
Click here for a demo.
<ul>
<li>Home</li>
<li>About</li>
<li>Products</li>
</ul>
ul {
width: 100%;
border-bottom: 3px solid blue;
overflow: hidden;
}
li {
float: left;
margin: 0 20px 0 20px;
}
li a {
border-bottom: 20px solid #fff;
display: block;
}
li a:hover, .active {
border-bottom: 20px solid blue;
}
You can then use the hover state for another class called something like "active" that you can apply when on that page.
You should be able to tweak this example to suit your needs.
You don't need any images. CSS is more than capable of doing this for you.
....................................
Live demo
Hi now this is possible used to after in css
as a simple example is this
HTML
<ul>
<li>Home</li>
<li>Home</li>
<li>Home</li>
<li>Home</li>
<li>Home</li>
<li>Home</li>
</ul>
Css
ul{
list-style:none;
border-bottom:solid 10px blue;
}
li{
display:inline-block;
vertical-align:top;
background:red;
}
li a{
text-decoration:none;
display:inline-block;
vertical-align:top;
position:relative;
padding-left:10px;
padding-right:10px;
padding-bottom:10px;
}
li:hover a:after{
content:'';
position:absolute;
left:0;
right:0;
bottom:0;
height:10px;
background:blue;
}
LIve demo
Place three anchors in an unordered list and have them displayed in-line by setting the list display to none an floating the list items. Further add an empty span to each anchor which you can style with the :hover pseudo selector.
Learn CSS, its fun!
I am trying to make a horizontal menu look pretty.
Here's an example of what my HTML looks like.
<div id="menu">
<ul>
<li><a class="selected" href="index.html">Home</a></li>
<li>Bio</li>
<li>Labs</li>
<li>Assignments</li>
</ul>
</div>
This is a snippet from my CSS. It does the job in Firefox but not IE.
#menu {
margin:auto;
padding-top: 4px;
width: 800px;
}
#menu ul
{
float:left;
list-style-type:none;
margin:0;
padding:0;
padding-top:7px;
padding-left:20px;
}
#menu li
{
font: 87.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
display:inline-block;
}
#menu a, #menu a.selected
{
text-decoration:none;
color:#000;
background-color:#fff;
background-image:url('../images/menu-unselected.jpg');
background-repeat:repeat-x;
padding-top:4px;
padding-bottom:0px;
padding-left:12px;
padding-right:12px;
border:solid;
border-width: 1px 1px 1px 1px;
border-color:#000;
}
#menu a.selected
{
padding-top:7px;
padding-bottom:1px;
border-width: 1px 1px 0px 1px;
}
#menu a:hover, #menu a.selected
{
background-image:url('');
}
I can make changes to the css to get it working right in IE, but then it doesn't work in FireFox! Here's screenshots of the code above rendered in each browser:
Firefox: here
Internet Explorer: here
This worked for me.
On #menu li instead of display:inline; replace it with float:left;
Then on #menu a.selected use padding and margin to reposition it taller than the others. I added:
padding-bottom:4px;
padding-top:7px;
margin-top:5px;
display:block; on #menu a seems optional. I'm on a Mac in FF 7.0.1 and it looks correct. Can't see it in IE. Hope that helps.
i tend to use display:inline-block; instead of float:left; when it's possible, and never had problems cross-browsers. So what i suggest to you is to use #menu li{ display:inline-block;}.
Obviously all changes are relative to your default layout ... wrappers,pages,body,html etc etc ..
Change display: inline-block; to display: inline; in your li.
Then add display: block; float: left; to your a.
You would then change the style of the tabs through the a tag (things such as text-align, width, etc).
I have a vertical ul as a nav menu. When a:hover is triggered, a border-left shows up at the edge of the screen and padding is adjusted so the text isn't displaced. Pretty common menu effect. Works well, except when user resizes their screen to the point where the nav menu items break into two lines- then there is no padding on the second line, pulling it to the left. I need to find a way to apply the padding equally to the whole li even if the line is broken, while keeping my border-left effect!
I have looked at some answers to similar problems on stackoverflow but they all seem to involve removing the padding from the li and applying it to the ul or containing element instead. If I do this, then I lose the positioning on my left border highlight- the border shows up right next to the text, and I can't figure out how to manipulate the padding on the border separate from the li to bump it back out!
Here's the css:
#middle_left ul {
list-style: none;
padding-top:5%;
font-family: 'Gill Sans', Verdana, Arial, 'Liberation Sans', FreeSans, sans-serif;
font-size:1.5em;
}
#middle_left ul a {
padding-left:15px;
text-decoration: none;
color: #2e2f2a;
}
#middle_left ul a:hover {
padding-left:12px;
color: #81827f;
border-left: solid 3px #81827f;
}
And the HTML:
<div id="middle_left">
<ul>
<li>The Novel</li>
<li>Bio</li>
<li>Translation</li>
<li>Other Works</li>
</ul>
</div>
Thanks for any suggestions for how to tackle this!
Wrap the a in divs:
<div id="middle_left">
<ul>
<li><div>The Novel</div></li>
<li><div>Bio</div></li>
<li><div>Translation</div></li>
<li><div>Other Works</div></li>
</ul>
</div>
#middle_left ul {
list-style: none;
padding-top:5%;
padding-left: 15px;
font-family: 'Gill Sans', Verdana, Arial, 'Liberation Sans', FreeSans, sans-serif;
font-size:1.5em;
}
#middle_left ul div{
padding-left:15px;
text-indent: -15px;
}
#middle_left ul div:hover{
padding-left:15px;
text-indent: -15px;
border-left: solid 3px #81827f;
}
#middle_left ul a {
padding-left:15px;
text-decoration: none;
color: #2e2f2a;
}
#middle_left ul a:hover {
padding-left:12px;
color: #81827f;
}
See here for example:
http://jsfiddle.net/6nz9F/2/
How about this?
CSS
#middle_left ul {
list-style: none;
padding-top: 5%;
padding-left:12px;
font-family: 'Gill Sans', Verdana, Arial, 'Liberation Sans', FreeSans, sans-serif;
font-size: 1.5em;
}
#middle_left ul a {
display: block;
text-decoration: none;
color: #2e2f2a;
border-left: 3px solid transparent;
}
#middle_left ul a:hover {
color: #81827f;
border-left-color: #81827f;
}
I am working on a dropdown meenu, which is disappearing in IE 8. Works fine in firefox and chrome, but not in IE8. i googled for two days and made many changes but still not working in IE. Here is the code for CSS.
.dropdownmenu li, .dropdownmenu li ul
{
display: block;display:inline;float:none;
}
dropdownmenu ul:hover , .dropdownmenu ul li:hover
{
display: block;display:inline; float:none;
}
.dropdownmenu{
border:none;
border:0px;
margin:0px;
padding:0px;
font: 37.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
color:#ffffff;
}
.dropdownmenu ul{
background:#333333;
height:35px;
list-style:none;
margin:0;
padding:0;
}
.dropdownmenu li a.top_link span {color:#ffffff;font-size:11px;}
.dropdownmenu li{
color: #FFFFFF;
font-size:11px;
float:left;
padding:0px;
}
.dropdownmenu li a{
background:#333333 url("dropdown/seperator.gif") bottom right no-repeat;
color:#ffffff;
display:block;
font-weight:normal;
line-height:35px;
margin:0px;
padding:0px 11px;
text-align:center;
text-decoration:none;
}
.dropdownmenu li a:hover{
background: #2580a2 url("dropdown/hover.gif") bottom center no-repeat;
color:#FFFFFF;
text-decoration:none;
}
.dropdownmenu li ul{
color:#ffffff;
font-size:10px;
background:#333333;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:auto;
z-index:200;
/*top:1em;
left:0;*/
}
.dropdownmenu li:hover ul{
display:block;
float:left;
}
.dropdownmenu li li {
background:url('dropdown/sub_sep.gif') bottom left no-repeat;
display:block;
float:none;
margin:0px;
padding:0px;
width:auto;
}
.dropdownmenu li ul a{
display:block;
height:35px;
font-size:12px;
color:#ffffff;
font-style:normal;
margin:0px;
padding:0px 10px 0px 17px;
text-align:left;
}
.dropdownmenu li ulli a:hover{
display:block;
background:#2580a2;
color:#ffffff;
text-decoration:none;
}
Here is the php code, I have used <?include ('dropdown.php')?> on my site to include this in the CMS built website.
<link rel="stylesheet" href="dropdown/dropdown3.css" type="text/css" />
<ul class="dropdownmenu">
<li ><span>Home & Garden <img src="dropdown/down.gif"></span>
<ul class="sub">
<li>ArtWork</li>
<li>Bedding & Bath</li>
<li>Kitchen & Dining</li>
<li>Patio, Lawn & Garden</li>
<li>Pet Supplies</li>
<li>Sewing, Craft & Hobbies</li>
<li>Vacuum, Cleaning & Storage </li>
</ul>
</li>
</ul>
What else can i do to fix it in IE?
Also, when the dropdown menu is hovered, it shows a background color of #2580a2, which can be seen at .dropdownmenu li a:hover This particular thing is not being shown in chrome. What could be the reason?
Using Internet Explorer Compatibility View on that website may help it display properly. Try it.
I'm using jQuery Dropdown for this with no errors at any browser.
If your menu will work well Explorer Compatibility View as "Sagotharan" suggested you can override IE rendering engine by setting it to render as IE7 always, like so
<meta http-equiv="X-UA-Compatible" content="IE=7" />