Reputation: 2504
The styling does not change the display to block when hovering. I would appreciate any comments.
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title>CSS Selectors</title>
<style>
div ul li:hover> ul {
display:block;
}
</style>
</head>
<body>
<div id="container">
<ul>
<li> List Item
<ul style="display:none;">
<li> Child </li>
</ul>
</li>
<li> List Item </li>
<li> List Item </li>
<li> List Item </li>
</ul>
</div>
</body>
</html>
Upvotes: 0
Views: 132
Reputation: 20239
Use !important for display: block;
Try
div ul li:hover > ul {
display:block!important;
}
Upvotes: 1
Reputation: 5490
There are three reasons:
You cannot have a space in the pseudo selector.
Inline styles take precedence over embedded, so even if your selector is correct, the display: block;
will have no effect.
You are selecting a ul which is a direct child of the div, whereas the ul that is set to not display is a child of the ul which is inside of the div, so that won't work.
Try something like this:
div ul ul {
display: none;
}
div:hover ul ul {
display:block;
}
Upvotes: 9