I have a dropdown menu and it's not working with Internet Explorer 10 (and compatibility mode) and Chrome. It does however work with Firefox (latest).
CSS:
#menu_items
{ float: left;
width: 600px;
}
#menu
{ margin:0;
float: left;
}
#menu li
{
padding: 0 0 0 0px;
list-style: none;
margin: 2px 0 0 0;
display: inline;
background: transparent;
}
#menu li a{
float: left;
font: bold 120% Arial, Helvetica, sans-serif;
text-align: center;
color: #FFF;
text-decoration: none;
height: 24px;
text-shadow: 0px 1px 0px #000;
padding: 16px 0px 10px 40px;
background: transparent;
}
#menu li ul li a {
float: left;
font: bold 90% Arial, Helvetica, sans-serif;
text-align: center;
color: #FFF;
text-decoration: none;
height: 24px;
text-shadow: 0px 1px 0px #000;
padding: 16px 0px 10px 40px;
background: transparent;
}
#menu li:hover ul {
display: flex;
float:inherit;
text-shadow: 0px 1px 0px #000;
padding: 1px 40px 0px 0px;
background: #669CD8;
background: -moz-linear-gradient(#90B9E2, #4B75AF);
background: -o-linear-gradient(#90B9E2, #4B75AF);
background: -webkit-linear-gradient(#90B9E2, #4B75AF);
margin: 50px 0px 0px 0px;
border-style:solid;
border-width:1px;
z-index: 2;
}
#menu li ul {
display: none;
position: absolute;
}
#menu li.current a, ul#menu li:hover a
{
color: #FFF;
text-decoration: underline;
}
HTML:
<div id="menu_items">
<ul id="menu">
<li class="current">Home</li>
<li>Werkwijze</li>
<li>Producten
<ul>
<li>Klimaat</li>
<li>Voerbakken</li>
<li>Voerinstallatie</li>
<li>Kraamhokken</li>
<li>Boxen</li>
<li>Biggen hokken</li>
<li>Roosters</li>
<li>Silo's</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div>
In the rules for #menu li:hover ul, use display: block; instead of display: flex;. (See demo at http://jsfiddle.net/8LaLa/1/.)
display: flex isn't supported by all browsers - see https://developer.mozilla.org/en-US/docs/Web/CSS/display#Browser_compatibility.
Your menu may not be clearing properly. You have a lot of floated elements and that can cause errors with your rendering. When you float an element you are taking that element "out of flow". Basically the element will disregard its position in the DOM and try to slide to the side you set in your float. If all child elements inside of a wrapper are floated the parent no longer knows how tall it should be (since all the elements are out of flow) and it sets itself to 0px height or to the height of the tallest in-flow element. To fix this you need a clearfix. This will tell the browser to make the container clear its children. Hopefully this fixes your issue!
Related
When hovering over a list item, see Fiddle (https://jsfiddle.net/22upj1yc/), I want the black highlight to cover not the entire area of the list item, not leaving any white space on top or bottom. Right now it only covers the center area of the list item.
I have tried removing the padding from ul and adding a height to li like this, but it does not work. How do I do this?
ul {
display: inline-block;
list-style: none;
margin: 0 auto;
background: #fff;
border-bottom: 2px solid #d8d8d8;
}
ul li {
display: inline-block;
border-right: 1px solid #d8d8d8;
height: 50px;
}
Add the hover to the <li> instead of the <a> tag, see fiddle https://jsfiddle.net/22upj1yc/1/
ul li:hover {
background-color: black;
}
I basically have updated your item, look in this jsfiddle.
Instead of just ul { }, I have made it ul li { }.
CODE
body {
font: 15px/1.625em "Helvetica Neue", Helvetica, sans-serif;
background: #f5f5f5;
}
ul li {
display: inline-block;
list-style: none;
padding: 10px;
margin: auto;
background: #fff;
border-bottom: 2px solid #d8d8d8;
}
ul li {
display: inline-block;
border-right: 1px solid #d8d8d8;
}
ul li a {
color: #777;
text-decoration: none;
padding: 0 12px;
}
ul li:hover {
background-color: black;
}
ul li.next {
border-right: 0;
}
ul li.next:after {
content: "\f054";
font-family: FontAwesome;
font-size: 12px;
padding: 0 10px;
}
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li class="next">
Next
</li>
</ul>
Remove padding top and bottom from ul
ul {
display: inline-block;
list-style: none;
padding: 0 10px;
margin: 0 auto;
background: #fff;
border-bottom: 2px solid #d8d8d8;
}
And add padding to li
ul li {
display: inline-block;
border-right: 1px solid #d8d8d8;
padding:10px 0px;
}
here is link for jsfiddle https://jsfiddle.net/22upj1yc/6/
!--Sorry for bad English--!
The inline-block elements are adding around 4px space after each element (changes by browser). You can negate this with font-size: 0 on that element and switch your font size to apply directly to the li or a tags.
css
body {
background: #f5f5f5;
// removed font sizing, replaced in ul li below
}
ul {
display: inline-block;
font-size: 0; // get rid of ghost space after inline-blocks
list-style-type: none;
background: #fff;
border-bottom: 2px solid #d8d8d8;
margin: 0; padding: 0;
}
ul li {
display: inline-block;
border-right: 1px solid #d8d8d8;
text-align: center;
margin: 0;
padding: 0px 6px; // added some left/right padding
font: 15px/1.625em "Helvetica Neue", Helvetica, sans-serif; // moved your font sizing here
}
...there were some other padding issues I believe, basically I set all else to 0.
fiddle
https://jsfiddle.net/Hastig/3ezn15a0/1/
I don't know why this not working properly on ie8.
<div id="bluemenu" class="bluetabs">
<ul>
<li class="">
<a rel="dropmenu3_c" href="company/">Company
<span><img width="11"height="7" src="images/arrow_btn.png"></span>
</a>
</li>
</ul>
</div>
This is the css for the navigation ul
.bluetabs ul {
color: #FFFFFF;
float: right;
font: 13px 'Open Sans','Lucida Grande',Arial,"Verdana sans-serif";
list-style-type: none;
margin: 0;
padding: 0;
text-align: left;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
text-transform: uppercase;
}
This is the css for the navigation li
.bluetabs li {
display: inline;
float: left;
height: 36px;
margin: 0;
padding: 0;
}
This is the css for the navigation li a
.bluetabs li a {
background: url("../images/menu_nav_hover_bg.png") repeat-x scroll 0 0 rgba(0, 0, 0, 0);
color: #FFFFFF;
margin: 0;
padding: 5px 15px;
text-decoration: none;
}
Any CSS hacks that I can make this work on IE 8?
I can kind of reproduce this locally, but not entirely.
Gonna take a shot in the dark...
Try:
.bluetabs li a {
background: #ccc;
color: #FFFFFF;
margin: 0;
padding: 5px 15px;
text-decoration: none;
display: inline-block; /* Add this */
}
/* Add this */
.bluetabs li a > span {
display: inline-block;
}
I'm currently building a website using only HTML/CSS3. It displays perfectly on all desktop browsers but not in mobile Safari (which is crucial). The site is currently under construction here: test.scccjapan.com and the problem is with the drop down navigation menu ("blackboard - grammar - verbs" list).
The list is particularly long, but when scrolling down the page to get to the bottom of the list, the menu closes making it impossible to click on any of the links.
After a lot of trial and error, I seem to have narrowed the problem down to the overflow:scroll attribute. If I delete this attribute from the CSS, the menu works perfectly fine, HOWEVER, I also have a fixed background image and deleting the overflow turns the background image from a fixed state into something more like a scroll which is also not what I'm looking for. It seems I can either have:
(a) a fully-functioning menu and a scrolling (static) background or
(b) a fixed background and a "broken" menu.
Short of redesigning this section of my site to cater for this issue, can anyone help!? I don't know Java and a relative noob when it comes to coding so specific information would be useful. I've also scoured the internet for answers and tried anything I could find but to no avail.
Thanks in advance! :)
Here's my CSS (let me know if you need something more):
html {
background: url(Backgrounds/Totoro.png);
background-position: bottom right;
background-repeat: no-repeat;
background-size: 40%;
background-attachment: fixed;
background-color: #666;
height: 100%;
overflow: hidden;
}
body {
height: 100%;
-webkit-overflow-scrolling: touch;
min-width: 900px;
max-width: 100%;
position: relative;
overflow-x: hidden;
overflow-y: scroll;
}
#Menu {
text-align: center;
white-space: normal;
font-size: 15px;
font-weight: bold;
}
/* Main Menu */
#Menu nav ul {
padding: 0 10px;
border-radius: 10px;
list-style: none;
position: relative;
display: inline-table;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
text-align: left;
text-shadow: 0px 1px 1px #fff;
z-index: 99;
-webkit-transform: translateZ(0);
}
#Menu nav img {
height: 65px;
width: 65px;
}
#Menu nav ul li a:hover {
color: #4ed1fe;
background: #bfbebe;
}
#Menu nav ul:after {
content: "";
clear: both;
display: block;
}
#Menu nav ul li {
float: left;
}
#Menu nav ul li:hover {
background-color: #383838;
box-shadow: inset 0px 0px 2px 2px #535353;
}
#Menu nav ul li a {
display: block;
padding: 10px 6px;
color: #262626;
text-decoration: none;
}
#Menu nav ul li:hover a {
cursor: pointer;
color: #fff;
text-outline: #000;
text-shadow: 2px 0px 5px #000;
}
/* Year Levels */
#Menu nav ul ul {
background: #5d5d5d;
border-radius: 1px;
position: absolute;
top: 100%;
-moz-border-radius-bottomleft: 5px;
-moz-border-radius-bottomright: 5px;
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
border-bottom: #9ca7b5 1px solid;
display: none;
box-shadow: 2px 0px 5px #000;
}
#Menu nav ul ul li {
float: none;
position: relative;
}
#Menu nav ul ul li a {
padding: 10px 80px 10px 10px;
color: #fff;
border-top: #fff 0px inset;
}
#Menu nav ul ul li a:hover {
color: #0CF;
background: #bfbebe;
}
#Menu nav ul li:hover > ul {
display: block;
}
/* Terms */
#Menu nav ul ul ul {
position: absolute;
left: 90%;
box-shadow: 0px -3px 100px #000;
top: 10px;
white-space: nowrap;
}
HTML:
<ul id="menu">
<li>Categories 1
<ul id="cat1">
<li class="first">temp1</li>
<li>temp2</li>
<li>temp3</li>
</ul>
</li>
</ul>
CSS:
#menu {
background-color: #0000FF;
height: 20px;
padding: 15px 0 10px;
margin: 5px;
font: 12px Tahoma;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
box-shadow: inset 0px 0px 10px #000;
text-align: center;
}
#menu > li{
display: inline;
}
li a {
color: #fff;
text-decoration: none;
}
.first{
margin-top: 12px;
}
#cat1 > li{
display: block;
background-color: #0000FF;
width: 150px;
margin-right: auto;
}
#cat1 > li > a{
display: block;
padding: 10px;
box-shadow: inset 0px 0px 2px #000;
}
When i use margin-left: auto in #cat > li it is woring properly. margin-right:auto on the other hand doesn't get the full margin, and I don't understand why this is.
Here's my fiddle: http://jsfiddle.net/ZfN7t/25/
Thank you for any and all help!
Mayb you should set <li> inline-block , maybe text-align:center and reset margin/padding of <ul> second level too :)
http://jsfiddle.net/ZfN7t/26/
ul {
margin:0 auto;
padding:0;
}
#menu > li {
display: inline-block;
}
Remove the default padding for html elements and it should work like expected.
ul,li
{
margin:0;padding:0;
}
FIDDLE
I've added markup on a webpage to align a element at bottom of another element. However when I do this the menus on my page aren't displayed in IE7. Here's the markup:
<div id="header">
<div class="panel">
<h1>Heading</h1>
<div class="nav">
<ul>
<li class="hdr"><a class="hdr" href="#">Submenu One</a>
<ul>
<li class="menuitem">Submenu one</li>
<li class="menuitem">Submenu 2</li>
</ul>
</li>
<li class="hdr"><a class="hdr" href="#">Submenu 2</a></li>
<li class="hdr"><a class="hdr" href="#">Submenu 3</a></li>
</ul>
</div>
</div>
</div>
The associated style sheet has the following:
#header
{
position: relative; /* Move to bottom */
height: 100px;
width: 100%;
}
.nav
{
position: absolute; /* Move to bottom */
bottom: 0; /* Move to bottom */
}
#header ul
{
padding-left: 0;
margin-left: 0;
margin: 12px 0px 0px 0px;
list-style: none;
position: relative;
left: -10px;
float: left;
}
#header ul li.hdr
{
display:-moz-inline-stack;
display: inline-block;
zoom: 1;
*display: inline; /* IE Hack */
margin-right: 15px !important;
font-size: 16px;
z-index: 1000;
}
#header ul li a.hdr
{
display: block;
color: white !important;
text-decoration: none;
padding: 9px 11px 11px 11px;
}
#header ul li a.hdr:hover
{
background: #505050;
border: solid 1px #606060;
padding: 8px 10px 10px 10px;
text-shadow: 2px 2px 2px #111;
}
#header ul ul
{
display: none;
border: 1px solid #a0a0a0;
background: #f5f5f5;
position: absolute;
top: 27px;
left: 0px;
zoom: 1;
padding: 10px;
line-height: 20px;
}
#header ul li:hover > ul
{
display: block;
}
#header ul ul li
{
display: block;
}
#header ul ul li a
{
font-size: 12px;
border: none;
color: #000;
background: #f5f5f5;
text-decoration: none;
padding: 8px;
}
The lines with the comment /* Move to bottom */ are responsible for moving the nav div to the bottom of the header. I've tried putting z-index's everywhere, as well as other attributes to ensure IE sees the elements with hasLayout equal to true, but to no avail. I'm pulling my hair out over this, any help much appreciated.
Your IE hack is wrong:
use
*+display: inline; /* IE Hack */
instead of
*display: inline; /* IE Hack */
(star) hack is for IE6 only.
[See here][1]
http://css-tricks.com/how-to-create-an-ie-only-stylesheet/