I don't normally work with IE7 simply because I hate it, but my latest client uses IE7-IE9 as their default browsers (not very consistent or up-to-date I know). So I have a list that renders fine in all newer browsers and IE8+ but in IE7 the UL seem to merge into the LI. Its like the tag didn't exist and the UL was a part of the LI. Each list item is nested inside of the one on top of it. Its hideous. Anyone know of a hack or a way around this? Is my CSS messed up?
<div class="indentList">
<ul class="level1">
<li class="customer">
Title
</li>
<ul class="level2 level" id="level2">
<li class="site">
Text
</li>
<ul class="level3 level" id="level3">
<li class="engineer indent">
Name
</li>
</ul>
<ul class="level2 level" id="level2">
<li class="site">
Text
</li>
<ul class="level3 level" id="level3">
<li class="engineer indent">
Name
</li>
<ul class="level4 level" id="level4">
<li>
Item
</li>
<li>
Item
</li>
</ul>
</ul>
</ul>
</ul>
</div>
.indentList ul {
margin: 0px;
padding: 0px;
float: left;
}
.indentList li a {
width: 770px;
margin: 0px 0px;
padding: 10px 0px;
display: inline-block;
float: left;
}
.indentList li:hover {
background: #E9E9E9;
}
.indentList li a:hover {
text-decoration: none;
}
.indentList li .edit {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
padding: 5px 14px;
width: auto !important;
margin: 4px 0px 0px 5px;
text-align: center;
display: inline;
position: relative;
float: right;
}
.indentList li .edit.frozen {
background: #b51a1a url('images/menuBackgroundRed.png') center;
float: right;
}
.indentList li.customer {
background: #787878 url('images/menuBackgroundTaller.png') center;
color: #FFF;
box-shadow: inset 0px 0px 0px;
-moz-box-shadow: inset 0px 0px 0px;
-webkit-box-shadow: inset 0px 0px 0px;
}
.indentList li.customer a {
color: #FFF;
font-family: 'QuicksandBook', Arial, sans-serif;
font-size: 17px;
}
.level2, .level3, .level4 {
display: block;
}
.indentList ul ul ul li {
margin-left: 50px;
width: 840px;
}
.indentList ul ul ul li a {
width: 770px;
}
.indentList ul ul ul ul li {
margin-left: 90px;
width: 800px;
}
.indentList ul ul ul ul li a {
width: 730px;
}
Not your CSS, but your HTML is messed up.
You should be doing this (pseudocode):
<ul class="first-level">
<li>
<ul class="second-level">
<li>
<ul class="third-level">
<li></li>
</ul>
</li>
</ul>
</li>
</ul>
instead of this:
<ul class="first-level">
<li></li>
<ul class="second-level">
<li></li>
<ul class="third-level">
<li></li>
</ul>
</ul>
</ul>
Related
When I get the cursor on the GOOGLE button, the parent block resizes by itself. I want the grandchild elements outside the parent button.
CODE:
ol {
display: none;
}
li:hover ol {
display: block;
margin-left: -4.2em;
}
#shadow li {
list-style-type: none;
border: 2px solid black;
box-shadow: 5px 5px 5px gray;
margin-bottom: 10px;
text-align: center;
width: 10em;
margin-left: 1.5em;
float: left;
display: block;
}
<body>
<div id="shadow">
<ul>
<li style="margin-left : -2.5em">
GOOGLE
<ol type="a">
<li> google1
</li>
<li> google1
</li>
</ol>
</li>
<li>YOUTUBE</li>
<li>FACEBOOK</li>
</ul>
</div>
</body>
One way to resolve this would be to simply give the li elements the same height on hover:
li:hover {
height: 18px;
}
This can be seen in the following example:
ol {
display: none;
}
li:hover {
height: 18px;
}
li:hover ol {
display: block;
margin-left: -4.2em;
}
#shadow li {
list-style-type: none;
border: 2px solid black;
box-shadow: 5px 5px 5px gray;
margin-bottom: 10px;
text-align: center;
width: 10em;
margin-left: 1.5em;
float: left;
display: block;
}
<body>
<div id="shadow">
<ul>
<li style="margin-left : -2.5em">
GOOGLE
<ol type="a">
<li> google1
</li>
<li> google1
</li>
</ol>
</li>
<li>YOUTUBE</li>
<li>FACEBOOK</li>
</ul>
</div>
</body>
Hope this helps :)
ol {
display: none;
}
li:hover ol {
display: block;
margin-left: -4.2em;
}
#shadow li {
list-style-type: none;
border: 2px solid black;
box-shadow: 5px 5px 5px gray;
margin-bottom: 10px;
text-align: center;
width: 10em;
margin-left: 1.5em;
float: left;
display: block;
}
<body>
<div id="shadow">
<ul>
<li style="margin-left : -2.5em; height: 1em;">
GOOGLE
<ol type="a">
<li> google1
</li>
<li> google1
</li>
</ol>
</li>
<li>YOUTUBE</li>
<li>FACEBOOK</li>
</ul>
</div>
</body>
ol {
display: none;
}
li:hover ol {
display: block;
margin-left: -4.2em;
}
#shadow li {
list-style-type: none;
border: 2px solid black;
box-shadow: 5px 5px 5px gray;
margin-bottom: 10px;
text-align: center;
width: 10em;
margin-left: 1.5em;
float: left;
display: block;
}
<body>
<div id="shadow">
<ul>
<li style="margin-left : -2.5em">
GOOGLE
<ol type="a">
<li> google1
</li>
<li> google1
</li>
</ol>
</li>
<li>YOUTUBE</li>
<li>FACEBOOK</li>
</ul>
</div>
</body>
I added a height attribute to your li tag. I think that's what you were looking for.
I'm having trouble aligning my drop down menu in my nav bar, I've tried every suggestion out there. I've tried left, float: left, right, and pretty much everything else. I think it is possibly something interfering. The drop down menu has everything aligned from center to right of the parent menu item.
https://jsfiddle.net/ethacker/j7tgq95j/3/
My html code:
<header>
<nav>
<h1> Welcome to Mommy Madness</h1>
<ul>
<li class="parentMenu">Home
<ul class="sub-menu">
<li>About</li>
<li>Contact</li>
</ul>
</li>
<li class="parentMenu">Pregnancy
<!--
Gender Predictions:
Old Wive's Tale
Boy vs Girl- The Ramzi Method
-->
<ul class="sub-menu">
<li>Advice</li>
<li>Gender Predictions</li>
<li>Trying To Conceive</li>
</ul>
</li>
<li class="parentMenu">All About Baby
<ul class="sub-menu">
<li>Fetal Development</li>
<li>Guidelines </li>
<li> Milestones</li>
</ul>
</li>
<li class="parentMenu">Party Momma
<!--
Birthdays - Link to 1-10th bdays.
-->
<ul class="sub-menu">
<li>Pregnancy Announcement</li>
<li>Gender Reveal</li>
<li>Baby Shower</li>
<li>Birth Announcement</li>
<li> Birthdays</li>
</ul>
</li>
<li class="parentMenu">Stations
<ul class="sub-menu">
<li>Hospital Bag</li>
<li>Diaper Bag</li>
<li>Changing Station</li>
<li>Baby Gear</li>
</ul>
</li>
<li class="parentMenu">Memory Markers
<!--
Drop Down Menu:
DIY
Purchases
(Both to have holiday/event selectors on right of page)
-->
<ul class="sub-menu">
<li>DIY</li>
<li>Purchases</li>
</ul>
</li>
<li class="parentMenu">Reviews
<ul class="sub-menu">
<li>Games</li>
<li>Gear</li>
<li>Learning</li>
</ul>
</li>
<li class="parentMenu">Blog
<ul class="sub-menu">
<li>Fit Momma</li>
<li>Minimal Momma</li>
<li>Modern Momma</li>
<li>Organic Momma</li>
<li>Organizing Queen</li>
<li>Savings Savvy</li>
<li>Tech Savvy</li>
<li>Traditional Momma</li>
</ul>
</li>
</ul>
</nav>
My css code:
body {
background-color: beige;
color: lightblue;
padding: 0;
margin:0;
}
header {
background-color: lightblue;
padding: 5px 0;
margin: 0;
}
header h1 {
color: cadetblue;
font-family: Arial;
margin: 0;
padding: 5px 15px;
display: inline;
}
.navMenu{
display: inline;
margin: 0;
}
.navMenu .parentMenu {
display: inline-block;
list-style-type: none;
background-color: lightgray;
padding: 5px 10px;
border: thin solid darkgray;
border-radius: 3px;
color: honeydew;
position: relative;
margin: 0;
}
.navMenu .parentMenu a{
color: azure;
}
.navMenu .parentMenu .sub-menu{
display: none;
}
.navMenu .parentMenu:hover .sub-menu{
display: block;
position: absolute;
list-style-type: none;
margin:0;
}
.parentMenu:hover .sub-menu li{
border: thin solid darkgray;
padding: 4%;
background-color: lightgray;
color: honeydew;
text-align: left;
white-space: nowrap;
width: 100%;
list-style-type: none;
margin: 0;
}
.parentMenu .sub-menu li:hover {
background-color: lightsteelblue;
}
.section {
background-color: wheat;
color: darkslategray;
padding: 5px;
float: left;
display: inline;
width: 63%;
margin: 0 1% 1% 1%;
border-radius: 10px;
border: thin solid khaki;
box-shadow: lightgray;
}
#about {
float: right;
width: 30%;
margin: 1% 1% 0 0;
text-align: center;
}
#home{
margin: 1% 0 1% 1%;
}
h4, h3 {
color: lightseagreen;
}
This will align the submenu to the left:
.navMenu .parentMenu .sub-menu {
display: none;
position:absolute;
list-style-type: none;
padding:0;
margin: 0;
left:-1px;
top:27px;
}
.navMenu .parentMenu:hover .sub-menu {
display: block;
}
https://jsfiddle.net/am13qur4/
you did not specify where you want to align your drop down elements. Do you want to align all to the right, center or left. I assumed left so try adding the code below. You may need to adjust the left attribute's value and your hover background styling too.
.sub-menu a{
position: absolute;
left: 3%;
}
Let me know if this helps. Stay warm!
I have whitespace between two html sections that I would like to get rid of. Here is a picture of it:
I removed any whitespace in my html code between /div and div, as suggested by answers from my searches, but it didn't seem to fix the problem.
HTML Code:
<!--website main heading layout-->
<div id="heading">
<h1> Beat Your Pace <h1/>
<h2> The music search tool to boost your running performance! </h2>
</div><div id="topbar">
<!--topbar/menu layout-->
<div id="topbar_wrapper">
<ul id="mainmenu">
<li>Home</li><li>
Search</li><li>
Sort By ▼
<ul id="sortmenu">
<li><a href='#'>Song</a>
<ul class="sortsubmenu">
<li><a href='#'>A to Z</a></li><li>
<a href='#'>Z to A</a></li>
</ul>
</li><li>
<a href='#'>Artist</a>
<ul class="sortsubmenu">
<li><a href='#'>A to Z</a></li><li>
<a href='#'>Z to A</a></li>
</ul>
</li><li>
<a href='#'>Album</a>
<ul class="sortsubmenu">
<li><a href='#'>A to Z</a></li><li>
<a href='#'>Z to A</a></li>
</ul>
</li><li>
<a href='#'>Genre</a>
<ul class="sortsubmenu">
<li><a href='#'>A to Z</a></li><li>
<a href='#'>Z to A</a></li>
</ul>
</li><li>
<a href='#'>BPM</a>
<ul class="sortsubmenu">
<li><a href='#'>Slowest to Fastest</a></li><li>
<a href='#'>Fastest to Slowest</a></li>
</ul>
</li><li>
<a href='#'>Release Date</a>
<ul class="sortsubmenu">
<li><a href='#'>Newest to Oldest</a></li><li>
<a href='#'>Oldest to Newest</a></li>
</ul>
</li>
</ul>
</li><li>
Add Song</li><li>
Contact Us</li>
</ul>
</div>
</div>
body and heading CSS Code:
html, body {
margin: 0px;
padding: 0px;
font-family: Arial;
font-size: 18px;
}
#heading {
background: url("http://cdn4.techlila.com/wp- content/uploads/2011/01/header2.jpg");
background-position: left;
color: black;
text-shadow: -1px 0 #F8F8FF, 0 1px #F8F8FF, 1px 0 #F8F8FF, 0 -1px #F8F8FF;
}
Menu CSS Code:
#topbar {
background-color: #222;
}
#topbar_wrapper {
width: 100%;
margin: 0 auto;
text-align: left;
}
#mainmenu {
list-style-type: none;
padding: 0px;
margin: 0px;
position: relative;
min-width: 200px;
}
#mainmenu > li {
display: inline-block;
width: 200px;
}
#mainmenu li:hover {
background-color: #333;
}
#mainmenu li a{
color: #CCC;
display: block;
padding: 15px;
text-decoration: none;
}
#mainmenu li:hover > ul {
display: block;
}
#sortmenu {
display: none;
position: absolute;
background-color: #333;
border: 5px solid #222;
border-top: 0;
margin-left: -5px;
}
#sortmenu > li {
display: block;
position: relative;
}
#sortmenu li a:hover {
color: #699;
}
#sortmenu li: hover ul {
display: inline-block;
}
.sortsubmenu {
display: none;
position: absolute;
background-color: #333;
border: 5px solid #222;
border-left: 0px;
text-align: right;
top: 0;
left: 100%;
width: auto;
}
.sortsubmenu li{
display: inline;
white-space: nowrap;
}
.sortsubmenu li a:hover {
color: #DB7093;
}
Remove the default on the <h2> element:
#heading h2 {
margin:0;
}
I have learnt CSS online and I am new to web designing. Need some expert opinion here, I may have written something wrong or stupid. Please forgive that as I am a beginner.
Here are my CSS and HTML codes:
#menu {
float: left;
width: 1000px;
height: 30px;
background-color:#0066FF;
border-bottom: 1px solid #333;``
}
#menu ul {
float: left;
width: 1000px;
margin: 0;
padding: 7px 0 0 0;
list-style: none;
}
#menu ul li{
display:inline;
}
li ul {display: none;}
li:hover ul {display: block; position:relative;}
li:hover li a{background: #0066FF;}
#menu ul li a{
float: left;
padding: 0 20px;
font-size: 12px;
font-weight: bold;
text-align: center;
text-decoration: none;
color: #FFFFFF;
}
#menu li a:hover, #menu li .current{
color: #FFFF00;
}
#menu ul li:hover ul{
width: 150px;
white-space: nowrap
height: 10px;
text-align: center;
background:#0066FF;
}
<div id="menu">
<ul>
<li>Home</li>
<li>Quran
<ul>
<li>Translation</li>
<li>Tajweed</li>
<li>Tafseer</li>
<li>Qoutes</li>
</ul>
</li>
<li>Ahadees
<ul>
<li>Sahih Al-Bukhari</li>
<li>Sahih Muslim</li>
<li> Sunan Abu-Dawud</li>
<li>al-Tirmidhi</li>
<li>al-Nasa'i</li>
<li>Ibn Maja </li>
</ul></li>
<li>Wazaif
<ul>
<li>Allah's help</li>
<li>Rizzaq</li>
<li>Aulaad</li>
<li>Marriage</li>
</ul></li>
<li>Rights & Duties
<ul>
<li>As Parents</li>
<li>As Husband</li>
<li>As Wife</li>
<li>As Son</li>
<li>As Daughter</li>
</ul></li>
<li>Videos
<ul>
<li>Molana Tariq Jameel</li>
<li>Dr Zakir Naik</li>
<li>Dr Farhat Hashmi</li>
<li>Naat videos</li>
</ul></li>
<li>Quran & Science</li>
<li>Library
<ul>
<li>Masnoon Duain</li>
<li>Tib-e-Nabvi</li>
<li>Tafseer</li>
<li>Islamic comerace</li>
</ul></li>
<li>FAQs</li>
<li>Blogs</li>
<li>Contacts</li>
</ul>
</div>
It looks like the problem is that you haven't positioned the sub-menus properly.
Because the sub-menu have not been given position:absolute they remain in the documents flow and so disturb other elements when shown.
Adding position:absolute removes them from the flow and solves the problem.
In order to be positioned according to the parent li, that li needs to be a block (hence display:inline-block)(you could float the li too if that's your choice) and be given position:relative.
Here's a suggestion that should help you along the way.
#menu ul li {
display:inline-block;
position: relative;
}
li ul {
display: none;
position: absolute;
top:100%;
left:0;
}
li:hover ul {
display: block;
}
JSfiddle Demo
#menu {
float: left;
width: 1000px;
height: 30px;
background-color: #0066FF;
border-bottom: 1px solid #333;
``
}
#menu ul {
float: left;
width: 1000px;
margin: 0;
padding: 7px 0 0 0;
list-style: none;
}
#menu ul li {
display: inline-block;
position: relative;
}
li ul {
display: none;
position: absolute;
top: 100%;
left: 0;
}
li:hover ul {
display: block;
}
li:hover li a {
background: #0066FF;
}
#menu ul li a {
float: left;
padding: 0 20px;
font-size: 12px;
font-weight: bold;
text-align: center;
text-decoration: none;
color: #FFFFFF;
}
#menu li a:hover,
#menu li .current {
color: #FFFF00;
}
#menu ul li:hover ul {
width: 150px;
white-space: nowrap height: 10px;
text-align: center;
background: #0066FF;
}
<div id="menu">
<ul>
<li>Home
</li>
<li>Quran
<ul>
<li>Translation
</li>
<li>Tajweed
</li>
<li>Tafseer
</li>
<li>Qoutes
</li>
</ul>
</li>
<li>Ahadees
<ul>
<li>Sahih Al-Bukhari
</li>
<li>Sahih Muslim
</li>
<li> Sunan Abu-Dawud
</li>
<li>al-Tirmidhi
</li>
<li>al-Nasa'i
</li>
<li>Ibn Maja
</li>
</ul>
</li>
<li>Wazaif
<ul>
<li>Allah's help
</li>
<li>Rizzaq
</li>
<li>Aulaad
</li>
<li>Marriage
</li>
</ul>
</li>
<li>Rights & Duties
<ul>
<li>As Parents
</li>
<li>As Husband
</li>
<li>As Wife
</li>
<li>As Son
</li>
<li>As Daughter
</li>
</ul>
</li>
<li>Videos
<ul>
<li>Molana Tariq Jameel
</li>
<li>Dr Zakir Naik
</li>
<li>Dr Farhat Hashmi
</li>
<li>Naat videos
</li>
</ul>
</li>
<li>Quran & Science
</li>
<li>Library
<ul>
<li>Masnoon Duain
</li>
<li>Tib-e-Nabvi
</li>
<li>Tafseer
</li>
<li>Islamic comerace
</li>
</ul>
</li>
<li>FAQs
</li>
<li>Blogs
</li>
<li>Contacts
</li>
</ul>
</div>
I am trying to learn HTML/CSS and during the course I thought of creating a CSS based Drop Down Menu Navigation bar. I read almost all of the tutorials I could find and finally built it, but the problem is it doesn't work as expected, I got the Main menu working but, the lists are not showing up. Here's the structure of my HTML:
<div id="Header"/>
<div id="Navigation" >
<ul id="Menu-H">
<li id="HOME">HOME</li>
<li id="ITEMS">ITEMS</li>
<ul >
<li>New Item</li>
<li>Search Item</li>
</ul>
<li id="Category">CATALOG</li>
<li id="Inventory">INVENTORY</li>
</ul>
<a class="LogOutButton" href="#">LOG OUT</a>
And here is the CSS I built:
#Menu-H {
padding: 0;
margin: 0;
list-style-type: none;
margin-left: 50px;
}
#Menu-H li {
float:left;
}
#Menu-H li:hover {
background: #f4f4f4;
border-radius: 5px 5px 0px 0px;
}
#Menu-H li a {
//border-left: 2px solid blue;
//border-right: 2px solid blue;
//background-color: white;
display:block;
padding: 5px 15px 5px 15px;
text-decoration: none;
text-shadow: 1px 1px 1px #FFFFFF
}
#Menu-H li:hover a {
color: #161616;
text-shadow: 1px 1px 1px#FFFFFF;
}
/* Drop Down Menu.........*/
#Menu-H ul {
background: #161616;
background:rgba(255,255,255,0);
list-style: none;
display: none;
}
Menu-H ul li {
padding-top: 1px;;
float: none;
}
Menu-H li:hover ul {
display:block;
}
#Menu-H li:hover a {
background: #6b0c36;
}
#Menu-H li:hover ul li a:hover {
background: #333;
}
I can not find the reason.
Your HTML is't right, You need to place the secondary <ul> inside the parent <li>
<ul id="Menu-H">
<li id="HOME">HOME</li>
<li id="ITEMS">ITEMS
<ul>
<li>New Item</li>
<li>Search Item</li>
</ul>
</li>
<li id="Category">CATALOG</li>
<li id="Inventory">INVENTORY</li>
</ul>
Also you forgot to add the # in the CSS for two id-s. Here's a fiddle I made where you can see I made some changes that I was talking about and it works:
http://jsfiddle.net/SJQ9B/