I can't seem to get my menu 100% of the browser. I want a logo beside the menu in the header to. I tried in the CSS to add a background colour and width or 100% but this didn't work
Here is my code
#logo {
padding-top: 10px;
padding-left: 85px;
float: left;
}
/*----- Top Level -----*/
#menu2 {
background: #3b3b3b;
}
.menu > ul > li {
float: left;
display: inline-block;
position: relative;
font-size: 19px;
}
.menu > ul > li > a {
padding: 10px 40px;
display: inline-block;
text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.4);
}
.menu > ul > li:hover > a,
.menu > ul > .current-item > a {
background: #2e2728;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
z-index: 1;
opacity: 1;
}
.sub-menu {
width: 160%;
padding: 5px 0px;
position: absolute;
top: 100%;
left: 0px;
z-index: -1;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.2);
background: #2e2728;
}
.sub-menu li {
display: block;
font-size: 16px;
}
.sub-menu li a {
padding: 10px 30px;
display: block;
}
.sub-menu li a:hover,
.sub-menu .current-item a {
background: #3e3436;
}
<div id="menu2">
<div id="logo">
<img src="logo2.png" alt="logo" />
</div>
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Home
</li>
<li>About Us
</li>
<li>
What's On
<ul class="sub-menu">
<li>Sunday Services
</li>
<li>Speical Events
</li>
<li>Sunday School
</li>
<li>Youth Group
</li>
<li>Prayer Meeting
</li>
<li>Coffee Morning
</li>
<li>Woman's Fellowship
</li>
<li>Craft Class
</li>
<li>Diners Club
</li>
</ul>
</li>
<li>Get In Touch
</li>
<li class="current-item">Find Us
</li>
</ul>
</nav>
</div>
You just need to clear the floats: It's call a clearfix
There are many method of doing this...one is to add overflow:hidden to the wrapper
#menu2 {
background: #3b3b3b;
overflow: hidden;
/* quick clearfix */
}
Codepen Demo
#logo {
padding-top: 10px;
padding-left: 85px;
float: left;
}
/*----- Top Level -----*/
#menu2 {
background: #3b3b3b;
overflow: hidden;
/* quick clearfix */
}
.menu > ul > li {
float: left;
display: inline-block;
position: relative;
font-size: 19px;
}
.menu > ul > li > a {
padding: 10px 40px;
display: inline-block;
text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.4);
}
.menu > ul > li:hover > a,
.menu > ul > .current-item > a {
background: #2e2728;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
z-index: 1;
opacity: 1;
}
.sub-menu {
width: 160%;
padding: 5px 0px;
position: absolute;
top: 100%;
left: 0px;
z-index: -1;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.2);
background: #2e2728;
}
.sub-menu li {
display: block;
font-size: 16px;
}
.sub-menu li a {
padding: 10px 30px;
display: block;
}
.sub-menu li a:hover,
.sub-menu .current-item a {
background: #3e3436;
}
<div id="menu2">
<div id="logo">
<img src="logo2.png" alt="logo" />
</div>
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Home
</li>
<li>About Us
</li>
<li>
What's On
<ul class="sub-menu">
<li>Sunday Services
</li>
<li>Speical Events
</li>
<li>Sunday School
</li>
<li>Youth Group
</li>
<li>Prayer Meeting
</li>
<li>Coffee Morning
</li>
<li>Woman's Fellowship
</li>
<li>Craft Class
</li>
<li>Diners Club
</li>
</ul>
</li>
<li>Get In Touch
</li>
<li class="current-item">Find Us
</li>
</ul>
</nav>
</div>
The background in the css should be background-color: #FFFFFF
Related
I have site with menu and submenu under it, I need to show second level submenu at right after hovering over first level submenu item, how can I achive this?
I add another UL under my submenu item but is showed this under submenu item, I tried to hide it and than show them with hover but it doesn't appear. I am not familiar to CSS syntax, some help will be appreciated.
Thanks
EDIT: now after adding some css suggested by Tahir Iqbal it show second level submenu, but it shows "one level" down, I will attach screen.
Here is the screenshot
this is my code
.main-menu ul.navbar-nav li {
float: left;
position: relative;
}
.main-menu ul.navbar-nav > li >a {
background: rgba(0, 0, 0, 0) none repeat scroll 0 0;
color: #444;
font-size: 13px;
font-weight: 500;
padding: 36px 0px;
text-transform: uppercase;
font-family: 'Montserrat', sans-serif;
margin: 0px 15px;
}
.main-menu ul.navbar-nav li a:hover{
color: #FFA100;
}
.main-menu ul.navbar-nav >li:hover > a:before, .main-menu ul.navbar-nav >li.active > a::before {
width: 100%;
}
.main-menu ul.navbar-nav li.active a:focus {
color: #333;
}
.main-menu ul.navbar-nav li.active a {
background: rgba(0, 0, 0, 0) none repeat scroll 0 0;
color: #FFA100;
position: relative;
z-index: 9999999;
}
.navbar {
border: medium none;
margin-bottom: 0;
}
.navbar-default {
background: rgba(0, 0, 0, 0) none repeat scroll 0 0;
}
.main-menu ul.navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .navbar-default .navbar-nav > .active > a:focus {
background: none;
color:#333;
}
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
background-color: transparent;
color: #fff;
}
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus {
background: none;
}
.main-menu ul.nav li ul.sub-menu {
background: #fff;
border-top: 2px solid #FFA100;
left: 0;
opacity: 0;
position: absolute;
top: 115%;
transition: all 0.3s ease 0s;
visibility: hidden;
width: 220px;
z-index: -99;
}
.pagess {
position: relative;
}
.navbar.navbar-default {
float: right;
}
.main-menu ul.nav li ul.sub-menu li {
border-bottom: 1px solid #ddd;
padding: 0;
position: relative;
width: 100%;
}
.main-menu ul.nav li:hover ul.sub-menu {
top: 92%;
opacity: 1;
z-index: 999;
visibility: visible;
}
.main-menu ul.nav li ul.sub-menu li a {
color: #444;
display: block;
font-size: 12px;
font-weight: 500;
padding: 10px 15px;
text-transform: uppercase;
font-family: 'Montserrat', sans-serif;
}
.main-menu ul.nav li:hover ul.sub-menu li a:hover{
color:#FFA100;
}
.main-menu ul.nav li ul.sub-menu li:last-child {
border:none;
}
.main-menu ul.sub-menu ul {
display: none;
position: absolute;
left: -100%;
top:0;
}
.main-menu ul.sub-menu li:hover > ul {
display: block;
left: 100%;
}
<nav class="navbar navbar-default">
<div class="collapse navbar-collapse" id="navbar-example">
<div class="main-menu">
<ul class="nav navbar-nav navbar-right">
<li><a class="pagess" href="index.html">Home</a>
<ul class="sub-menu">
<li>Home 01
<ul class="sub-menu">
<li>Test</li>
</ul>
</li>
<li>Home 02
<ul class="sub-menu">
<li>Test</li>
</ul>
</li>
<li>Home 03</li>
<li>Home 04
<ul class="sub-menu">
<li>Test</li>
</ul>
</li>
<li>Home 05</li>
<li>Home 06</li>
</ul>
</li>
<li><a class="pagess" href="#">About us</a>
<ul class="sub-menu">
<li>About us
<ul class="sub-menu">
<li>Test</li>
</ul>
</li>
<li>Team</li>
<li>Review</li>
<li>FAQ</li>
<li>Error</li>
</ul>
</li>
<li><a class="pagess" href="#">Services</a>
<ul class="sub-menu">
<li>All Services</li>
<li>Services Details</li>
<li>Services Details 2</li>
<li>Services Fullwidth</li>
</ul>
</li>
<li><a class="pagess" href="#">Projects</a>
<ul class="sub-menu">
<li>Project 2 Column</li>
<li>Project 3 Column</li>
<li>Project 4 Column</li>
<li>Project Details</li>
</ul>
</li>
<li><a class="pagess" href="#">Blog</a>
<ul class="sub-menu">
<li>Blog grid</li>
<li>Blog Left Grid</li>
<li>Blog Right Grid</li>
<li>Blog Left list</li>
<li>Blog Right List</li>
<li>Blog Details</li>
</ul>
</li>
<li>contacts</li>
</ul>
</div>
</div>
</nav>
here is how you can show it sub menu on mouse hover
here is the change
.main-menu ul.nav li ul.sub-menu ul.sub-menu {
display: none;
top: -2px;
left: 100%;
}
.main-menu ul.nav li ul.sub-menu li:hover > ul {
display: block;
}
complete code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>title</title>
<style>
.main-menu ul.navbar-nav li {
float: left;
position: relative;
}
.main-menu ul.navbar-nav > li > a {
background: rgba(0, 0, 0, 0) none repeat scroll 0 0;
color: #444;
font-size: 13px;
font-weight: 500;
padding: 36px 0px;
text-transform: uppercase;
font-family: 'Montserrat', sans-serif;
margin: 0px 15px;
}
.main-menu ul.navbar-nav li a:hover {
color: #ffa100;
}
.main-menu ul.navbar-nav > li:hover > a:before,
.main-menu ul.navbar-nav > li.active > a::before {
width: 100%;
}
.main-menu ul.navbar-nav li.active a:focus {
color: #333;
}
.main-menu ul.navbar-nav li.active a {
background: rgba(0, 0, 0, 0) none repeat scroll 0 0;
color: #ffa100;
position: relative;
z-index: 9999999;
}
.navbar {
border: medium none;
margin-bottom: 0;
}
.navbar-default {
background: rgba(0, 0, 0, 0) none repeat scroll 0 0;
}
.main-menu ul.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
background: none;
color: #333;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
background-color: transparent;
color: #fff;
}
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:focus {
background: none;
}
.main-menu ul.nav li ul.sub-menu {
background: #fff;
border-top: 2px solid #ffa100;
left: 0;
opacity: 0;
position: absolute;
top: 115%;
transition: all 0.3s ease 0s;
visibility: hidden;
width: 220px;
z-index: -99;
}
.pagess {
position: relative;
}
.navbar.navbar-default {
float: right;
}
.main-menu ul.nav li ul.sub-menu li {
border-bottom: 1px solid #ddd;
padding: 0;
position: relative;
width: 100%;
}
.main-menu ul.nav li:hover ul.sub-menu {
top: 92%;
opacity: 1;
z-index: 999;
visibility: visible;
}
.main-menu ul.nav li ul.sub-menu li a {
color: #444;
display: block;
font-size: 12px;
font-weight: 500;
padding: 10px 15px;
text-transform: uppercase;
font-family: 'Montserrat', sans-serif;
}
.main-menu ul.nav li:hover ul.sub-menu li a:hover {
color: #ffa100;
}
.main-menu ul.nav li ul.sub-menu li:last-child {
border: none;
}
.main-menu ul.nav li ul.sub-menu ul.sub-menu {
display: none;
top: -2px;
left: 100%;
}
.main-menu ul.nav li ul.sub-menu li:hover > ul {
display: block;
}
</style>
</head>
<body>
<nav class="navbar navbar-default">
<div class="collapse navbar-collapse" id="navbar-example">
<div class="main-menu">
<ul class="nav navbar-nav navbar-right">
<li>
<a class="pagess" href="index.html">Home</a>
<ul class="sub-menu">
<li>
Home 01
<ul class="sub-menu">
<li>Test</li>
</ul>
</li>
<li>
Home 02
<ul class="sub-menu">
<li>Test</li>
</ul>
</li>
<li>Home 03</li>
<li>
Home 04
<ul class="sub-menu">
<li>Test</li>
</ul>
</li>
<li>Home 05</li>
<li>Home 06</li>
</ul>
</li>
<li>
<a class="pagess" href="#">About us</a>
<ul class="sub-menu">
<li>
About us
<ul class="sub-menu">
<li>Test</li>
</ul>
</li>
<li>Team</li>
<li>Review</li>
<li>FAQ</li>
<li>Error</li>
</ul>
</li>
<li>
<a class="pagess" href="#">Services</a>
<ul class="sub-menu">
<li>All Services</li>
<li>Services Details</li>
<li>Services Details 2</li>
<li>Services Fullwidth</li>
</ul>
</li>
<li>
<a class="pagess" href="#">Projects</a>
<ul class="sub-menu">
<li>Project 2 Column</li>
<li>Project 3 Column</li>
<li>Project 4 Column</li>
<li>Project Details</li>
</ul>
</li>
<li>
<a class="pagess" href="#">Blog</a>
<ul class="sub-menu">
<li>Blog grid</li>
<li>Blog Left Grid</li>
<li>Blog Right Grid</li>
<li>Blog Left list</li>
<li>Blog Right List</li>
<li>Blog Details</li>
</ul>
</li>
<li>contacts</li>
</ul>
</div>
</div>
</nav>
</body>
</html>
this is what I did for you I hope it helps you
.main-menu ul.navbar-nav li {
float: left;
position: relative;
margin:0;
transition:background .17s
}
.main-menu ul.navbar-nav > li >a {
background: rgba(0, 0, 0, 0) none repeat scroll 0 0;
color: #444;
font-size: 13px;
font-weight: 500;
padding: 36px 0px;
text-transform: uppercase;
font-family: 'Montserrat', sans-serif;
margin: 0px 15px;
}
.main-menu ul.navbar-nav >li:hover > a:before, .main-menu ul.navbar-nav >li.active > a::before {
width: 100%;
}
.main-menu ul.navbar-nav li.active a:focus {
color: #333;
}
.navbar {
border: medium none;
margin-bottom: 0;
}
.navbar-default {
background: rgba(0, 0, 0, 0.13) none repeat scroll 0 0;
}
.main-menu ul.navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .navbar-default .navbar-nav > .active > a:focus {
background: none;
color:#333;
}
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
background-color: transparent;
color: #fff;
}
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus {
background: none;
}
.main-menu ul.nav li ul.sub-menu {
background: #fff;
border-top: 2px solid #FFA100;
left: 0;
right: 0;
float: right;
margin-top: 0;
padding: 0;
opacity: 0;
position: absolute;
top: 115%;
transition: all 0.3s ease 0s;
visibility: hidden;
width: 300px;
z-index: -99;
}
.pagess {
position: relative;
}
.navbar.navbar-default {
float: right;
}
.main-menu ul.nav li ul.sub-menu li {
border-bottom: 1px solid #ddd;
padding: 0;
position: relative;
width: 100%;
}
.main-menu ul.nav li:hover ul.sub-menu {
top: 92%;
opacity: 1;
z-index: 999;
visibility: visible;
}
.main-menu ul.nav li ul.sub-menu li a {
color: #444;
display: block;
height: 36px;
font-size: 11px;
font-weight: 500;
padding: 10px 15px;
text-transform: uppercase;
font-family: 'Montserrat', sans-serif;
border: 0;
border-bottom: 1px solid rgba(255,255,255,0.05);
transition: all .17s ease;
line-height: 36px;
box-sizing: border-box;
margin: 0;
}
.main-menu ul.nav li:hover ul.sub-menu li a:hover{
color:#FFA100;
}
.main-menu ul.nav li ul.sub-menu li:last-child {
border:none;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
.main-menu ul > li > ul > li {
display: block;
}
.main-menu #main-menu-nav > li > a{
text-transform:uppercase;
font-weight:700
}
.main-menu .sub-menu li > ul {
position: absolute;
float: right;
right: 300px;
top: -2px;
width: 180px;
background-color: #fff;
z-index: 99999;
margin-top: 0;
padding: 0;
border-top: 2px solid #FFA100;
visibility: hidden;
opacity: 0;
}
.main-menu ul > li > ul > li > ul{
position: absolute;
float: right;
top: 0;
right: 100%;
margin: -2px 0px 0;
}
.main-menu ul > li > ul > li{
display:block;
float:none;
position:relative
}
.main-menu ul > li > ul > li:hover{
background:rgba(0, 0, 0, 0.13) none repeat scroll 0 0
}
.main-menu ul > li > ul > li:hover > a{
color:#fff
}
.main-menu ul > li.sub-menu > a:after{
content:'\f107';
float:right;
font-family:FontAwesome;
font-size:12px;
font-weight:400;
margin:0 0 0 5px
}
.main-menu .sub-menu > ul{
width:100%;
box-sizing:border-box;
padding:20px 10px
}
.main-menu .mega-menu > ul.mega-menu-inner{
overflow:hidden
}
.main-menu ul > li:hover > ul,#main-menu ul > li > ul > li:hover > ul{
visibility:visible;
opacity:1
}
.main-menu ul ul{
transition:all .25s ease
}
<nav class="navbar navbar-default">
<div class="collapse navbar-collapse" id="navbar-example">
<div class="main-menu">
<ul class="nav navbar-nav navbar-right">
<li><a class="pagess" href="https://some URL">Home</a></li>
<li><a class="pagess" href="#">Some menu item</a>
<ul>
<li>
</li>
</ul>
</li>
<li><a class="pagess" href="#">some menu item</a>
<ul class="sub-menu">
<li><a class="pagess" href="#">some menu item</a>
<ul>
<li><a class="pagess" href="#">test</a></li>
<li><a class="pagess" href="#">test</a></li>
<li><a class="pagess" href="#">test</a></li>
<li><a class="pagess" href="#">test</a></li>
</ul>
</li>
<li><a class="pagess" href="#">some menu item</a></li>
<li><a class="pagess" href="#">some menu item</a></li>
<li><a class="pagess" href="#">some menu item</a></li>
<li><a class="pagess" href="#">Financial services in Georgia</a></li>
</ul>
</li>
<li><a class="pagess" href="#">Why Georgia</a>
<ul>
<li>
</li>
</ul>
</li>
<li><a class="pagess" href="/contact">Contact</a>
<ul>
<li>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
I'm a beginner when it comes to html and css, I have to make a website as a school project. I want to add the search bar in the navbar using css, I'v been searching but I couldn't find the answer.
Here's my code:
jQuery(function($) {
$('#search-trigger').click(function() {
$('#search-input').toggleClass('search-input-open');
});
$(document).click(function(e) {
if (!$(e.target).closest('.ngen-search-form').length) {
$('#search-input').removeClass('search-input-open');
}
})
});
body {
padding: 0;
margin: 0;
overflow-y: scroll;
font-family: Arial;
font-size: 18px;
background-image: url("Background5.gif");
background-size: 1366px 800px;
background-repeat: no-repeat;
}
#header img {
max-width: 100%;
height: 100%;
}
#nav {
background-color: #222;
}
#nav_wrapper {
width: 960 px;
margin: 0 auto;
text-align: left;
}
#nav ul {
list-style-type: none;
padding: 0;
margin: 0;
position: relative;
}
#nav ul li {
display: inline-block;
}
#nav ul li:hover {
background-color: #333;
}
#nav ul li a,
visited {
color: #ccc;
display: block;
padding: 15px;
text-decoration: none;
}
#nav ul li a:hover {
color: #ccc;
text-decoration: none;
}
#nav ul li:hover ul {
display: block;
}
#nav ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul li {
display: block;
}
#nav ul ul li a,
visited {
color: #ccc;
}
#nav ul li li a:hover {
color: #099;
}
#nav ul ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul ul li {
display: block;
}
#nav ul ul ul li a,
visited {
color: #ccc;
}
#nav ul ul li li a:hover {
color: #099;
}
#nav ul ul ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul ul ul li {
display: block;
}
#nav ul ul ul ul li a,
visited {
color: #ccc;
}
#nav ul ul ul li li a:hover {
color: #099;
}
#nav ul ul ul ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul ul ul ul li {
display: block;
}
#nav ul ul ul ul ul li a,
visited {
color: #ccc;
}
#nav ul ul ul ul li li a:hover {
color: #099;
}
.form {
padding: 0px 0px 0px 0px;
float: right;
}
.form-search-input {
width: 0px;
height: 55px;
border: 0;
outline: 0;
font-size: 21px;
padding: 0px 0px 0px 0px;
color: #151515;
transition: all 0.5s;
}
.search-input-open {
width: 410px !important;
padding: 0px 0px 0px 20px !important;
display: initial !important;
}
.form-search-submit {
display: inline-block;
width: 55px;
height: 43px;
border: 0;
outline: 0;
background-color: #151515;
font-size: 21px;
color: #FFF;
cursor: pointer;
text-align: center;
}
<div id="maincontainer">
<div id="header">
<img src="C:\Users\Shogun\Desktop\The Witcher 3 Website\Banner.jpg" alt="the witcher 3 banner" id="thewitcherIMG" />
</div>
<div id="nav">
<div id="nav wrapper"></div>
<ul>
<li><a class="active" href="#">Home</a>
</li>
<li>
Story
<ul>
<li>Child of Prophecy
</li>
<li>
The Wild Hunt
</li>
<li>
Romance
</li>
<li>
Choice & Consequence
</li>
</ul>
</li>
<li>
Regions
<ul>
<li>White Orchard
</li>
<li>
Velen-No Man's Land
</li>
<li>
Novigrad
</li>
<li>
Royal Palace in Vizima
</li>
<li>
The Skellige Isles
</li>
<li>
Kaer Morhen
</li>
</ul>
</li>
<li>
Bestiary
<ul>
<li>Beasts
</li>
<li>
Cursed Ones
</li>
<li>
Draconians
</li>
<li>
Elementals
</li>
<li>
Hybrids
</li>
<li>
Insectoids
</li>
<li>
Necrophages
</li>
<li>
Ogroids
</li>
<li>
Relicts
</li>
<li>
Specters
</li>
<li>
Vampires
</li>
</ul>
</li>
<li>
Monster Hunts
</li>
<li>
DLC's
<ul>
<li>Heaarts of Stone
</li>
<li>
Blood and Wine
</li>
</ul>
</li>
<li>
CD Projekt Red
</li>
</ul>
<div>
<div class="form">
<form class="form-search ngen-search-form" action="" method="get">
<input type="text" name="q" id="search-input" class="form-search-input" placeholder="Search..." dir="ltr">
<span id="search-trigger" class="form-search-submit">🔎</span>
</form>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Try this:
jQuery(function($) {
$('#search-trigger').click(function() {
$('#search-input').toggleClass('search-input-open');
});
$(document).click(function(e) {
if (!$(e.target).closest('.ngen-search-form').length) {
$('#search-input').removeClass('search-input-open');
}
})
});
body {
padding: 0;
margin: 0;
overflow-y: scroll;
font-family: Arial;
font-size: 18px;
background-image: url("Background5.gif");
background-size: 1366px 800px;
background-repeat: no-repeat;
}
#header img {
max-width: 100%;
height: 100%;
}
#nav {
background-color: #222;
}
#nav_wrapper {
width: 960 px;
margin: 0 auto;
text-align: left;
}
#nav ul {
list-style-type: none;
padding: 0;
margin: 0;
position: relative;
}
#nav ul li {
display: inline-block;
}
#nav ul li:hover {
background-color: #333;
}
#nav ul li a,
visited {
color: #ccc;
display: block;
padding: 15px;
text-decoration: none;
}
#nav ul li a:hover {
color: #ccc;
text-decoration: none;
}
#nav ul li:hover ul {
display: block;
}
#nav ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul li {
display: block;
}
#nav ul ul li a,
visited {
color: #ccc;
}
#nav ul li li a:hover {
color: #099;
}
#nav ul ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul ul li {
display: block;
}
#nav ul ul ul li a,
visited {
color: #ccc;
}
#nav ul ul li li a:hover {
color: #099;
}
#nav ul ul ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul ul ul li {
display: block;
}
#nav ul ul ul ul li a,
visited {
color: #ccc;
}
#nav ul ul ul li li a:hover {
color: #099;
}
#nav ul ul ul ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul ul ul ul li {
display: block;
}
#nav ul ul ul ul ul li a,
visited {
color: #ccc;
}
#nav ul ul ul ul li li a:hover {
color: #099;
}
.form {
padding: 0px 0px 0px 0px;
float: right;
}
.form-search-input {
width: 0px;
height: 55px;
border: 0;
outline: 0;
font-size: 21px;
padding: 0px 0px 0px 0px;
color: #151515;
transition: all 0.5s;
}
.search-input-open {
width: 410px !important;
padding: 0px 0px 0px 20px !important;
display: initial !important;
}
.form-search-submit {
display: inline-block;
width: 55px;
height: 43px;
border: 0;
outline: 0;
background-color: #151515;
font-size: 21px;
color: #FFF;
cursor: pointer;
text-align: center;
}
<div id="maincontainer">
<div id="header">
<img src="C:\Users\Shogun\Desktop\The Witcher 3 Website\Banner.jpg" alt="the witcher 3 banner" id="thewitcherIMG" />
</div>
<div id="nav">
<div id="nav wrapper"></div>
<ul>
<li><a class="active" href="#">Home</a>
</li>
<li>
Story
<ul>
<li>Child of Prophecy
</li>
<li>
The Wild Hunt
</li>
<li>
Romance
</li>
<li>
Choice & Consequence
</li>
</ul>
</li>
<li>
Regions
<ul>
<li>White Orchard
</li>
<li>
Velen-No Man's Land
</li>
<li>
Novigrad
</li>
<li>
Royal Palace in Vizima
</li>
<li>
The Skellige Isles
</li>
<li>
Kaer Morhen
</li>
</ul>
</li>
<li>
Bestiary
<ul>
<li>Beasts
</li>
<li>
Cursed Ones
</li>
<li>
Draconians
</li>
<li>
Elementals
</li>
<li>
Hybrids
</li>
<li>
Insectoids
</li>
<li>
Necrophages
</li>
<li>
Ogroids
</li>
<li>
Relicts
</li>
<li>
Specters
</li>
<li>
Vampires
</li>
</ul>
</li>
<li>
Monster Hunts
</li>
<li>
DLC's
<ul>
<li>Heaarts of Stone
</li>
<li>
Blood and Wine
</li>
</ul>
</li>
<li>
CD Projekt Red
</li>
<li>
<div class="form">
<form class="form-search ngen-search-form" action="" method="get">
<input type="text" name="q" id="search-input" class="form-search-input" placeholder="Search..." dir="ltr">
<span id="search-trigger" class="form-search-submit">🔎</span>
</form>
</div>
</li>
</ul>
<div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
I am creating a nav bar with further sub lists. The first sub list displays exactly how I want it, but the one below that does not. Rather than display horizontally below the initial sub nav bar, it displays vertically and to the right of it.
Does anyone have any idea why this is, I believe I am missing something but for the life of me cant find it.
I added a photo to explain what I would like. The red should appear where the blue is.
Appreciate your time!
nav {
margin: 0 auto;
text-align: center;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
color: white;
background: #787878;
background: linear-gradient(top, #787878 0%, #272727 100%);
background: -moz-linear-gradient(top, #787878 0%, #272727 100%);
background: -webkit-linear-gradient(top, #787878 0%, #272727 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 20px;
border-radius: 25px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: "";
clear: both;
display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #A8A8A8;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block;
padding: 15px 50px;
color: white;
text-decoration: none;
}
nav ul ul {
background: #505050;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul li {
float: left;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 8px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #A8A8A8;
}
nav ul ul ul {
position: absolute;
left: 100%;
top: 0;
}
nav ul ul.ul-right {
right: 0;
}
<nav>
<ul>
<li>Players
<ul>
<li>Wonderkids
</li>
<li>Cheap Players
</li>
<li>Player Comparisons
</li>
</ul>
</li>
<li>Clubs
<ul>
<li>Club Info
</li>
<li>Transfer Budgets
</li>
<li>Sugar Daddys
</li>
</ul>
</li>
<li>Downloads
<ul>
<li>Tactics
</li>
<li>Shortlists
<ul>
<li>Various Shortlists
</li>
<li>Positional Shortlists
</li>
<li>Staff Shortlists
</li>
</ul>
</li>
</ul>
</li>
<li>Write-Ups
</li>
<li>Social
<ul class="ul-right">
<li>Facebook
</li>
<li>Twitter
</li>
<li>Youtube
</li>
<li>Affiliates
</li>
</ul>
</li>
<li>About Us
</li>
</ul>
</nav>
If You have no problem setting the width of the ul this might be a solution:
nav {
margin: 0 auto;
text-align: center;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
color: white;
background: #787878;
background: linear-gradient(top, #787878 0%, #272727 100%);
background: -moz-linear-gradient(top, #787878 0%, #272727 100%);
background: -webkit-linear-gradient(top, #787878 0%, #272727 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 20px;
border-radius: 25px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: "";
clear: both;
display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #A8A8A8;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block;
padding: 15px 50px;
color: white;
text-decoration: none;
}
nav ul ul {
background: #505050;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul li {
float: left;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 8px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #A8A8A8;
}
nav ul ul ul {
position: absolute;
top: 100%;
width: 578px;
}
nav ul ul.ul-right {
right: 0;
}
<nav>
<ul>
<li>Players
<ul>
<li>Wonderkids
</li>
<li>Cheap Players
</li>
<li>Player Comparisons
</li>
</ul>
</li>
<li>Clubs
<ul>
<li>Club Info
</li>
<li>Transfer Budgets
</li>
<li>Sugar Daddys
</li>
</ul>
</li>
<li>Downloads
<ul>
<li>Tactics
</li>
<li>Shortlists
<ul>
<li>Various Shortlists
</li>
<li>Positional Shortlists
</li>
<li>Staff Shortlists
</li>
</ul>
</li>
</ul>
</li>
<li>Write-Ups
</li>
<li>Social
<ul class="ul-right">
<li>Facebook
</li>
<li>Twitter
</li>
<li>Youtube
</li>
<li>Affiliates
</li>
</ul>
</li>
<li>About Us
</li>
</ul>
</nav>
So the problem I have is that if I select the last option on my nav bar, because the drop down has so many options, it exceeds the length left of the nav bar and wraps underneath, creating a grid of options 2x2.
I would much prefer if it used the space to the left rather than wrapping down. how can I make this possible.
nav {
margin: 0 auto;
text-align: center;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
color: white;
background: #787878;
background: linear-gradient(top, #787878 0%, #272727 100%);
background: -moz-linear-gradient(top, #787878 0%, #272727 100%);
background: -webkit-linear-gradient(top, #787878 0%, #272727 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 20px;
border-radius: 25px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: "";
clear: both;
display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #A8A8A8;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block;
padding: 15px 50px;
color: white;
text-decoration: none;
}
nav ul ul {
background: #505050;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul li {
float: left;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 15px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #A8A8A8;
}
nav ul ul ul {
position: absolute;
left: 100%;
top: 0;
}
<nav>
<ul>
<li>Players
<ul>
<li>Wonderkids
</li>
<li>Cheap Players
</li>
<li>Player Comparisons
</li>
</ul>
</li>
<li>Clubs
<ul>
<li>Club Info
</li>
<li>Transfer Budgets
</li>
<li>Sugar Daddys
</li>
</ul>
</li>
<li>Downloads
<ul>
<li>Tactics
</li>
<li>Shortlists
<ul>
<li>Various Shortlists
</li>
<li>Positional Shortlists
</li>
<li>Staff Shortlists
</li>
</ul>
</li>
</ul>
</li>
<li>Write-Ups
</li>
<li>Social
<ul>
<li>Facebook
</li>
<li>Twitter
</li>
<li>Youtube
</li>
<li>Affiliates
</li>
</ul>
</li>
<li>About Us
</li>
</ul>
</nav>
The problem is that the submenu is aligned on the left edge of the parent item in the main menu. Let's align the submenu on the right edge of the main menu.
Add class ul-right to the corresponding <ul>.
Add CSS-code nav ul ul.ul-right { right: 0; }.
Check the result:
nav {
margin: 0 auto;
text-align: center;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
color: white;
background: #787878;
background: linear-gradient(top, #787878 0%, #272727 100%);
background: -moz-linear-gradient(top, #787878 0%, #272727 100%);
background: -webkit-linear-gradient(top, #787878 0%, #272727 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 20px;
border-radius: 25px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: "";
clear: both;
display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #A8A8A8;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block;
padding: 15px 50px;
color: white;
text-decoration: none;
}
nav ul ul {
background: #505050;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul.ul-right {
right: 0;
}
nav ul ul li {
float: left;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 15px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #A8A8A8;
}
nav ul ul ul {
position: absolute;
left: 100%;
top: 0;
}
<nav>
<ul>
<li>Players
<ul>
<li>Wonderkids
</li>
<li>Cheap Players
</li>
<li>Player Comparisons
</li>
</ul>
</li>
<li>Clubs
<ul>
<li>Club Info
</li>
<li>Transfer Budgets
</li>
<li>Sugar Daddys
</li>
</ul>
</li>
<li>Downloads
<ul>
<li>Tactics
</li>
<li>Shortlists
<ul>
<li>Various Shortlists
</li>
<li>Positional Shortlists
</li>
<li>Staff Shortlists
</li>
</ul>
</li>
</ul>
</li>
<li>Write-Ups
</li>
<li>Social
<ul class="ul-right">
<li>Facebook
</li>
<li>Twitter
</li>
<li>Youtube
</li>
<li>Affiliates
</li>
</ul>
</li>
<li>About Us
</li>
</ul>
</nav>
I know there have been a lot of similar questions but none of the solutions worked for me. the predominant answer was to have overflow: hidden; on the ul but that's no good for me because the way i have overflow coded is essential for the menu and its transitions.
essentially i have a 2 column drop-down menu. the left column is the submenu list, the right column is an image. each main menu item has a different number of submenu items and sometimes even less than the height of the img. i want to fill the background of the ul class="twinsub" but i can't get it to pick up same as the height of the tallest list whether that be the image or the submenu list. i have tried everything i can think of with no success.
here are a couple of images to illustrate what i am trying to do:
here is the code:
Updated JS FIDDLE
HTML:
<section id="menuWrapper">
<nav id="menu" class="cf" role="navigation">
<!-- Main Nav Start -->
<ul id="main-nav" class="clearfix">
<!----------------------------------------- Solutions ------------------>
<li id="technology" class="parent menu-item">Solutions
<ul class="twinsub">
<li class="twinmultisub twinleft">
<ul>
<li id="solutions-turnkey" class="menu-item">Turnkey Development
</li>
<li id="solutions-financing" class="menu-item">Financial Modeling
</li>
<li id="solutions-execution" class="menu-item">World-Class Execution
</li>
</ul>
</li>
<li class="twinmultisub twinimg">
<section>
<img class="menuimage" src="http://milkytech.com/images/industry.png" />
</section>
</li>
</ul>
</li>
<li id="technology" class="parent menu-item">Services
<ul class="twinsub">
<li class="twinmultisub twinleft">
<ul>
<li id="services-devlopment" class="menu-item">Development & Financing
</li>
<li id="services-design" class="menu-item">Design & Engineering
</li>
<li id="services-construction" class="menu-item">Construction & Procurement
</li>
<li id="services-operations" class="menu-item">Operations & Maintenance
</li>
</ul>
</li>
<li class="twinmultisub twinimg">
<section>
<img class="menuimage" src="http://milkytech.com/images/industry.png" />
</section>
</li>
</ul>
</li>
</ul>
</nav>
CSS:
#menu {
display:inline-block;
clear:both;
height:auto;
}
#menu ul {
margin:0;
}
#menu li {
float:left;
position:relative;
}
#menu > ul > li > a {
display:block;
line-height: .4em;
}
/* Submenu (second level) */
#menu li > ul {
position:absolute;
top:auto;
left:0;
width:180px;
max-height:0;
visibility: hidden;
z-index:99999;
overflow:hidden;
}
#menu ul li:hover ul {
visibility: visible;
max-height: 330px;
width: 204px;
overflow: visible;
}
#menu ul li > ul:hover {
overflow:visible;
}
#menu li > ul li {
height:36px;
width:100%;
}
#menu li > ul li:last-child {
height: 35px;
}
#menu li > ul li a {
padding: 11px 15px;
height: 35px;
color: #FFF;
width: 100%;
display: block;
}
ul.twinsub {
clear: both;
display: inline-block;
width:408px !important;
border-right: none !important;
background-color: #5d6f82 !important;
overflow: hidden;
}
ul.twinsub > li {
display: inline-block;
border-top: none !important;
background: #FFF;
line-height: 38px;
}
li.twinmultisub {
display: block;
width: 50% !important;
}
.menuimage {
width: 100% !important;
margin-left: 1px;
border-right: none;
}
li.twinimg {
float: left;
border: none;
}
li.twinleft {
clear: both;
float: left;
border-right: none !important;
}
li.twinheader {
width: 50% !important;
text-align: left;
padding-left: 14px;
font-size: .9em;
background-color: #5d6f82 !important;
color: #FFF;
opacity: 1;
}
How about adding a wrapping div around the inner ul, and add a background color to that one.
This example should make a good beginning
.wrapp {
background: #13385F;
}
body {
margin: 0;
overflow-x: hidden;
}
article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary {
display: block;
}
a {
background: transparent;
text-decoration: none;
}
a:active, a:hover {
outline: 0;
}
nav ul, nav ol {
list-style: none;
list-style-image: none;
margin: 0;
padding: 0;
}
h1, h2, h3, h4 {
margin: 0;
padding: 0;
border: 0;
vertical-align:baseline;
font-family:'Open Sans', sans-serif;
}
* {
box-sizing:border-box;
-moz-box-sizing:border-box;
}
#menu a {
text-decoration: none;
}
#menuWrapper {
display: block;
text-align: center;
margin: 15px auto 15px;
}
#menu {
display:inline-block;
clear:both;
height:auto;
-webkit-box-shadow: 0px 9px 10px -9px rgba(35, 35, 35, 0.8);
-moz-box-shadow: 0px 9px 10px -9px rgba(35, 35, 35, 0.8);
box-shadow: 0px 9px 10px -9px rgba(35, 35, 35, 0.8);
}
#menu ul {
margin:0;
}
#menu li {
float:left;
position:relative;
}
#menu > ul > li > a {
padding:25px 19px 20px;
border-bottom:3px solid transparent;
margin-right:0px;
color:#6D6E70;
font: 1em'Open Sans', sans-serif;
font-weight:bold;
text-align:center;
text-transform: uppercase;
display:block;
line-height: .4em;
}
#menu > ul > li:last-child > a {
font-size: 1em;
}
#menu > ul > li:hover > a {
color:#5999db;
border-bottom: 3px solid #5999db;
}
#menu > ul li.selected > a, #menu > ul li.selected:hover > a {
color:#3F9944;
border-color:#FFF100;
}
/* Submenu (second level) */
#menu li > .wrapp > ul {
position:absolute;
top:auto;
left:0;
width:180px;
max-height:0;
/* -webkit-box-shadow: 0px 2px 7px 1px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 0px 2px 7px 1px rgba(0, 0, 0, 0.4);
box-shadow: 0px 2px 7px 1px rgba(0, 0, 0, 0.4); */
visibility: none;
z-index:99999;
overflow:hidden;
-webkit-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
-moz-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
-o-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
-ms-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
transition: max-height 0.2s ease, visibility 0s linear 0.5s;
background: inherit !important;
}
#menu ul li:hover ul {
visibility: visible;
max-height: 330px;
width: 204px;
transition-delay: 0s;
overflow: visible;
border: 1px solid #EEE;
border-top: 0;
}
#menu ul li > ul:hover {
overflow:visible;
}
#menu li > ul li {
height:36px;
width:100%;
border-bottom: 1px solid #EEE;
padding-top:0;
font-weight: 600;
background-color: #13385F;
color: #FFF;
opacity: 1;
}
#menu li > ul li:last-child {
border-bottom:none;
height: 35px;
}
#menu li > ul li a {
background: rgba(19, 57, 95, 0.3);
padding: 11px 15px;
height: 35px;
color: #FFF;
width: 100%;
font: 10px'Open Sans', sans-serif;
font-weight: bold;
text-align: left;
text-transform: uppercase;
display: block;
opacity: 1;
}
#menu li > ul li:hover > a {
color: #3B3B3B;
background: #5999db;
}
#menu li > ul li.selected > a, #menu li > ul li.selected:hover > a {
color: #3B3B3B;
background: #FFF;
}
ul.twinsub {
clear: both;
display: inline-block;
width:408px !important;
border-right: none !important;
background-color: #5d6f82 !important;
overflow: hidden;
}
ul.twinsub > li {
display: inline-block;
border-top: none !important;
background: #FFF;
line-height: 38px;
}
li.twinmultisub {
display: block;
width: 50% !important;
}
.menuimage {
width: 100% !important;
margin-left: 1px;
border-right: none;
line-height: 0 !important;
font-size: 0 !important;
}
li.twinimg {
float: left;
border: none;
}
li.twinimg section {
line-height: 0;
}
.borderleft {
border-left: 1px solid #EEE;
}
li.twinleft {
clear: both;
float: left;
border-right: none !important;
}
li.twinheader {
width: 50% !important;
text-align: left;
padding-left: 14px;
font-size: .9em;
background-color: #5d6f82 !important;
color: #FFF;
opacity: 1;
}
<section id="menuWrapper">
<nav id="menu" class="cf" role="navigation">
<!-- Main Nav Start -->
<ul id="main-nav" class="clearfix">
<!----------------------------------------- Solutions ------------------>
<li id="technology" class="parent menu-item">Solutions
<div class="wrapp">
<ul class="twinsub">
<li class="twinmultisub twinleft">
<ul>
<li id="solutions-turnkey" class="menu-item">Turnkey Development
</li>
<li id="solutions-financing" class="menu-item">Financial Modeling
</li>
<li id="solutions-execution" class="menu-item">World-Class Execution
</li>
</ul>
</li>
<li class="twinmultisub twinimg">
<section>
<img class="menuimage" src="http://milkytech.com/images/industry.png" />
</section>
</li>
</ul>
</div>
</li>
<li id="technology" class="parent menu-item">Services
<div class="wrapp">
<ul class="twinsub">
<li class="twinmultisub twinleft">
<ul>
<li id="services-devlopment" class="menu-item">Development & Financing
</li>
<li id="services-design" class="menu-item">Design & Engineering
</li>
<li id="services-construction" class="menu-item">Construction & Procurement
</li>
<li id="services-operations" class="menu-item">Operations & Maintenance
</li>
<li id="services-construction" class="menu-item">Construction & Procurement
</li>
<li id="services-operations" class="menu-item">Operations & Maintenance
</li>
</ul>
</li>
<li class="twinmultisub twinimg">
<section>
<img class="menuimage" src="http://milkytech.com/images/industry.png" />
</section>
</li>
</ul>
</div>
</li>
</ul>
</nav>
</section>
Just remeber to fix the css on the menu. And the section around the image, and the image itself needs a line-height of 0.