Reputation: 434
Hover function will not work in css and html.
I have a navigation menu across the top and i would like a drop down menu off one of the menu icons. I have positioned everything correctly however the hover just wont work.
My code is as follows:
@charset "utf-8";
body {
margin: 0px;
color: #151515;
font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
background-color: #EFF5F8;
}
#wrapper {
background-color: #FFFFFF;
width: 100%;
width: 860px;
margin-left: auto;
margin-right: auto;
}
#slideshow {
margin-top: 20px;
margin-left: auto;
margin-right: auto;
padding-bottom: 10px;
position: relative;
clear: left;
width: 860px;
height: 470px;
padding-right: 0px;
padding-left: 0px;
}
h1,
h2 {
color: #3399CC;
font-style: normal;
font-weight: 600;
font-family: source-sans-pro;
}
h1 {
font-size: 75px;
text-align: center;
text-transform: uppercase;
margin-top: 0px;
margin-bottom: 0px;
}
#main {
width: 58%;
margin-left: 2%;
float: left;
}
#sidebar {
width: 34%;
margin-left: 4%;
float: left;
}
footer {
clear: left;
padding-top: 2px;
padding-bottom: 2px;
padding-left: 2%;
background-color: #43A6CB;
color: #FFFFFF;
}
figure {
width: 420px;
}
figure img {
padding: 10px;
background-color: #FFFFFF;
-webkit-box-shadow: 1px 1px 15px #999999;
box-shadow: 1px 1px 15px #999999;
}
figcaption {
display: block;
text-align: center;
font-weight: bold;
font-size: 14px;
}
.centered {
margin-left: auto;
margin-right: auto;
}
.floatleft {
margin-right: 10px;
float: left;
}
.floatright {
margin-left: 10px;
float: right;
}
a {
font-weight: bold;
text-decoration: none;
}
a:link {
color: #FF6600;
}
a:visited {
color: #FF944C;
}
a:hover,
a:active,
a:focus {
color: #7F3300;
text-decoration: underline;
}
#mainnav ul {
list-style-type: none;
margin: 0px;
padding: 0px;
}
#mainnav a {
width: 20%;
display: block;
float: left;
background-color: #4D4D4D;
text-align: center;
color: #FFFFFF;
text-transform: uppercase;
padding-top: 6px;
padding-bottom: 6px;
}
#mainnav a:hover,
#mainnav a:active,
#mainnav a:focus,
#mainnav a.thispage {
text-decoration: none;
background-color: #43A6CB;
}
article,
aside,
figure,
footer,
header,
nav {
display: block;
}
ol {
font-weight: 600;
fobt-size: 25px;
color: red;
}
#dropdown1 {
visibility: hidden;
display: block;
position: absolute;
top: 208px;
left: 345px;
z-index: 1;
}
#dropdown1 > li {
width: 861px;
float: left;
}
.review:hover ul {
visibility: visible;
z-index: 10;
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Movie Night Reviews</title>
<link href="styles/main.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<header id="top">
<h1>Movie Night Reviews</h1>
<nav id="mainnav">
<ul>
<li><a href="index.html" class="thispage">Home</a>
</li>
<li><a href="trailers.html">Trailers</a>
</li>
<li class="review"><a href="reviews.html">Reviews</a>
<ul id="dropdown1">
<li><a href="civil_war.html">Civil War</a>
</li>
<li><a href="furious_7.html">Furious 7</a>
</li>
<li><a href="fantastic_four.html">Fantastic Four</a>
</li>
<li><a href="jurassic_world.html">Jurassic World</a>
</li>
<li><a href="agents_of_shield.html">Agents of Shield</a>
</li>
</ul>
</li>
<li><a href="about_us.html">About Us</a>
</li>
<li><a href="contact_us.html">Contact Us</a>
</li>
</ul>
</nav>
</header>
<div id="slideshow">
<div id="comslider_in_point_720546"></div>
<script type="text/javascript">
var oCOMScript720546 = document.createElement('script');
oCOMScript720546.src = "comslider720546/comsliderd.js?timestamp=1437916662";
oCOMScript720546.type = 'text/javascript';
document.getElementsByTagName("head").item(0).appendChild(oCOMScript720546);
</script>
</div>
<article id="main">
<h2>Top 10 Highest Grossing Movies</h2>
<p>The following list is of the highest grossing movies ever made. Director James Cameron currently holds the top two spots after directing both Avartar and Titanic.</p>
<ol>
<li>Avatar</li>
<li>Titanic</li>
<li>Juassic World</li>
<li>The Avengers</li>
<li>Furious 7</li>
<li>Avengers: Age of Ultron</li>
<li>Harry Potter and the Deathly Hallows – Part 2</li>
<li>Frozen</li>
<li>Iron Man 3</li>
<li>Transformers: Dark of the Moon</li>
</ol>
<figure class="centered">
<img src="Images/titanic.jpg" width="400" height="266" alt="" />
<figcaption>Titanic, the oldest film in the top 10 still sits in a comfy second place just below Avatar. Both directed by world-renowned director James Cameron.</figcaption>
</figure>
<h2>Top 10 Highest Grossing Movie Franchises</h2>
<p>The following list is of the Top 10 Highest Grossing Movie Franchises of all time. The Marvel Cinematic Universe franchise currently sits at the top nearly a billion higher than Harry Potter and roughly 2.5 billion higher than James Bond which is
the closest franchise that is also still running.</p>
<ol>
<li>Marvel Cinematic Universe</li>
<li>Harry Potter</li>
<li>James Bond</li>
<li>Middle-Earth</li>
<li>Star Wars</li>
<li>Spider-Man</li>
<li>The Fast and the Furious</li>
<li>Batman</li>
<li>Transformers</li>
<li>Pirates of the Caribbean</li>
</ol>
<figure class="centered">
<img src="Images/antman.jpg" width="400" height="266" alt="" />
<figcaption>Ant-Man, the latest film in the Marvel Cinematic Universe franchise looks set to push them even further ahead than the rest of the Top 10.</figcaption>
</figure>
</article>
<aside id="sidebar">
<h2>Tweets by IMDb</h2>
<a class="twitter-timeline" href="https://twitter.com/IMDb" data-widget-id="625318734555693056">Tweets by @IMDb</a>
<script>
! function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
p = /^http:/.test(d.location) ? 'http' : 'https';
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = p + "://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
}
}(document, "script", "twitter-wjs");
</script>
</aside>
<footer>
<p>© Copyright 2013 Bayside Beat</p>
</footer>
</div>
</body>
</html>
The big white gap is an image slideshow not just a massive gap.
If anyone an help me get this working it would be appreciated.
Upvotes: 0
Views: 69
Reputation: 669
Updated your code to make it work.
you need to use .review > a:hover + #dropdown1 to change the visibility.
#dropdown1 {
visibility: hidden;
display: block;
position: absolute;
top: 208px;
left: 345px;
z-index: 10;
}
#dropdown1:hover {
visibility: visible;
}
#dropdown1 > li {
width: 861px;
float: left;
}
.review > a:hover + #dropdown1 {
visibility: visible;
}
problem is your menu is too far away to stay visible when you leave .review. you need to bring the menu up closer or use a thick white border at the top so it still looks spaced how you have it
https://jsfiddle.net/gL54eevn/3/
Upvotes: 1