<div id="hero" class="wrapper">
<div id="hero-left">
<div id="selectors-div">
<span>Some text</span>
</div>
</div>
<div id="hero-right">
</div>
</div>
As you can see, #hero-left, comes before #hero-right, but for some reason, #hero-left is being pushed down all the way to the bottom until the text in the <span> aligns with the baseline of #hero-right.
I thought it was very odd behaviour since this hasn't happened to me before, so I started messing around with setting vertical-align: top, but even stranger is that nothing happened when I set that property value in any of the relevant elements... eventually, I randomly tried placing that same property value into #hero-right, and Voila... by setting that value to the latter element, the former is affected...
Why does this happen? I was taught that vertical-align only affects itself and inherently the position of its children (based off itself), yet it won't affect itself, its parent, its parent's parent... What am I missing?
WORKING EXAMPLE:
body {
font-family: 'Kanit', sans-serif;
margin: 0;
}
.wrapper {
width: 80%;
margin: 0 auto;
}
#header {
height: 100px;
display: flex;
}
#header-left {
margin: auto 0 auto 25px;
}
#header-left>img {
height: 50px;
margin: auto 0;
}
#header-right {
margin: auto 0 auto auto;
}
#header-list {
list-style-type: none;
display: inline-block;
margin: auto 0;
}
#header-list>li {
display: inline;
font-weight: bold;
font-size: 13px;
}
#header-list>li>a {
text-decoration: none;
color: black;
}
#header-list>li>a:hover {
color: #2C85D0;
}
#vertical-spacer {
height: 26px;
width: 1px;
margin: 0px 5px;
display: inline-block;
background-color: darkgray;
vertical-align: middle
}
#navbar {
height: 60px;
background-color: #252835;
}
.menu-left {
margin: 0;
padding: 0;
height: 100%;
font-size: 0;
}
.menu-left>li {
text-decoration: none;
display: inline-block;
height: 100%;
}
.menu-item-div {
height: 100%;
width: 200px;
border-right: 1px solid darkgray;
}
.menu-item-div>span {
line-height: 60px;
margin-left: 20px;
font-size: 18px;
color: white;
}
#section-type {
height: 100px;
background-color: darkgrey;
}
#section-type>span {
line-height: 100px;
margin-left: 20px;
font-size: 35px;
}
#hero {
height: 1000px;
background-color: red;
font-size: 0;
}
#hero-left {
display: inline-block;
width: 20%;
height: 100%;
background-color: blue;
font-size: 13px;
}
#hero-right {
display: inline-block;
width: 70%;
height: 100%;
background-color: orange;
font-size: 18px;
}
#selectors-div {
height: 100%;
}
#selectors-div>span {}
<link href="https://fonts.googleapis.com/css?family=Kanit" rel="stylesheet">
<div id="header" class="wrapper">
<div id="header-left">
<img src="https://pcbuilding2017.files.wordpress.com/2017/03/pcpartpicker.png?w=669&h=144&crop=1" alt="">
</div>
<div id="header-right">
<ul id="header-list">
<li><span style="font-weight: normal;">Welcome</span></li>
<li>Username</li>
<li><span id="vertical-spacer"></span></li>
<li>Inventory</li>
<li><span id="vertical-spacer"></span></li>
<li>Favorite Parts</li>
<li><span id="vertical-spacer"></span></li>
<li>Saved Parts Lists</li>
<li><span id="vertical-spacer"></span></li>
<li>Log Out</li>
<li><span id="vertical-spacer"></span></li>
<li>Canada</li>
<li><span id="vertical-spacer"></span></li>
</ul>
</div>
</div>
<div id="navbar" class="wrapper">
<ul class="menu-left">
<li>
<div class="menu-item-div">
<span>Desktop</span>
</div>
</li>
<li>
<div class="menu-item-div">
<span>Laptop</span>
</div>
</li>
<li>
<div class="menu-item-div">
<span>All-in-One</span>
</div>
</li>
<li>
<div class="menu-item-div">
<span>Mini</span>
</div>
</li>
</ul>
</div>
<div id="section-type" class="wrapper">
<span>Choose a Desktop</span>
</div>
<div id="hero" class="wrapper">
<div id="hero-left">
<div id="selectors-div">
<span>a</span>
</div>
</div>
<div id="hero-right" style="vertical-align: top;">
</div>
</div>
BROKEN EXAMPLE
body {
font-family: 'Kanit', sans-serif;
margin: 0;
}
.wrapper {
width: 80%;
margin: 0 auto;
}
#header {
height: 100px;
display: flex;
}
#header-left {
margin: auto 0 auto 25px;
}
#header-left>img {
height: 50px;
margin: auto 0;
}
#header-right {
margin: auto 0 auto auto;
}
#header-list {
list-style-type: none;
display: inline-block;
margin: auto 0;
}
#header-list>li {
display: inline;
font-weight: bold;
font-size: 13px;
}
#header-list>li>a {
text-decoration: none;
color: black;
}
#header-list>li>a:hover {
color: #2C85D0;
}
#vertical-spacer {
height: 26px;
width: 1px;
margin: 0px 5px;
display: inline-block;
background-color: darkgray;
vertical-align: middle
}
#navbar {
height: 60px;
background-color: #252835;
}
.menu-left {
margin: 0;
padding: 0;
height: 100%;
font-size: 0;
}
.menu-left>li {
text-decoration: none;
display: inline-block;
height: 100%;
}
.menu-item-div {
height: 100%;
width: 200px;
border-right: 1px solid darkgray;
}
.menu-item-div>span {
line-height: 60px;
margin-left: 20px;
font-size: 18px;
color: white;
}
#section-type {
height: 100px;
background-color: darkgrey;
}
#section-type>span {
line-height: 100px;
margin-left: 20px;
font-size: 35px;
}
#hero {
height: 1000px;
background-color: red;
font-size: 0;
}
#hero-left {
display: inline-block;
width: 20%;
height: 100%;
background-color: blue;
font-size: 13px;
}
#hero-right {
display: inline-block;
width: 70%;
height: 100%;
background-color: orange;
font-size: 18px;
}
#selectors-div {
height: 100%;
}
#selectors-div>span {}
<link href="https://fonts.googleapis.com/css?family=Kanit" rel="stylesheet">
<div id="header" class="wrapper">
<div id="header-left">
<img src="https://pcbuilding2017.files.wordpress.com/2017/03/pcpartpicker.png?w=669&h=144&crop=1" alt="">
</div>
<div id="header-right">
<ul id="header-list">
<li><span style="font-weight: normal;">Welcome</span></li>
<li>Username</li>
<li><span id="vertical-spacer"></span></li>
<li>Inventory</li>
<li><span id="vertical-spacer"></span></li>
<li>Favorite Parts</li>
<li><span id="vertical-spacer"></span></li>
<li>Saved Parts Lists</li>
<li><span id="vertical-spacer"></span></li>
<li>Log Out</li>
<li><span id="vertical-spacer"></span></li>
<li>Canada</li>
<li><span id="vertical-spacer"></span></li>
</ul>
</div>
</div>
<div id="navbar" class="wrapper">
<ul class="menu-left">
<li>
<div class="menu-item-div">
<span>Desktop</span>
</div>
</li>
<li>
<div class="menu-item-div">
<span>Laptop</span>
</div>
</li>
<li>
<div class="menu-item-div">
<span>All-in-One</span>
</div>
</li>
<li>
<div class="menu-item-div">
<span>Mini</span>
</div>
</li>
</ul>
</div>
<div id="section-type" class="wrapper">
<span>Choose a Desktop</span>
</div>
<div id="hero" class="wrapper">
<div id="hero-left">
<div id="selectors-div">
<span>a</span>
</div>
</div>
<div id="hero-right">
</div>
</div>
</body>
</html>
Related
I want to create a webpage like this.So far I have written a code in html and css like this but I cannot align the top nav bar above the nav-menu items?
HTML
<body>
<div class="top-header">
<div class="header">
<div class="logo">
<div class="logo-left">
<img src="images/logo.jpg" alt="logo-truck">
</div>
<div class="logo-right">
<h3>kuncham</h3>
<p>logistic service</p>
</div>
</div>
<div class="top-bar">
<div class="top-bar__content">
<div class="top-bar-content">call:(007)123-456-7890</div>
<div class="top-bar-content">email:enquiry#domain.com</div>
<div class="top-bar-content">mon-sun:12pm to 12am</div>
<div class="top-bar-content">
<i class="fa fa-twitter"></i>
<i class="fa fa-facebook"></i>
<i class="fa fa-linkedin"></i>
<i class="fa fa-google-plus"></i></div>
</div>
</div>
<ul class="nav__nav-bar">
<li><a class="active" href="#home">Home</a></li>
<li>about us</li>
<li>services</li>
<li>news</li>
<li>request a quote</li>
<li>contact us</li>
<li>track your item</li>
</ul>
</div>
</body>
CSS
-------------------------------------------------------------------------------------------------------
.nav__nav-bar {
flex-direction: row;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: white;
color: black;
font-weight: bold;
margin-top: -102px;
margin-left: 184px;
}
.nav__nav-bar li {
float: left;
}
.nav__nav-bar li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
color:black;
font-weight:bold;
text-transform: uppercase;
}
.nav__nav-bar li a:hover {
background-color: yellow;
}
.top-bar__content{
display:inline-block;
}
.top-header {
border:2px solid black;
background-color: black;
}
.header {
background-color: #fff;
height: 80px;
width: 90%;
}
.logo {
padding: 17px;
}
.logo .logo-left {
float: left;
font-size:50px;
color: darkorange;
padding-right: 5px;
}
.logo .logo-right h3 {
padding: 0;
margin: 0;
font-family: serif;
}
.logo .logo-right p {
line-height: 0;
}
.top-bar {
border: 2px solid red;
display: inline-grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
width: 76%;
margin-left: 280px;
height: 52px;
margin-top: -100px;
}
.top-bar-content{
display:inline;
}
The top-nav bar is not getting aligned at the top.I tried using flex but it does not work properly. Also the menu items are not aligned properly.Can anyone help me regarding this issue?
Codepen
<div class="top-header">
<div class="header">
<div class="logo">
<div class="logo-left">
<img src="images/logo.jpg" alt="logo-truck">
</div>
<div class="logo-right">
<h3>kuncham</h3>
<p>logistic service</p>
</div>
</div>
<div class="header-right">
<div class="top-bar">
<div class="top-bar__content">
<div class="top-bar-content">call:(007)123-456-7890</div>
<div class="top-bar-content">email:enquiry#domain.com</div>
<div class="top-bar-content">mon-sun:12pm to 12am</div>
<div class="top-bar-content">
<i class="fa fa-twitter"></i>
<i class="fa fa-facebook"></i>
<i class="fa fa-linkedin"></i>
<i class="fa fa-google-plus"></i></div>
</div>
</div>
<ul class="nav__nav-bar">
<li><a class="active" href="#home">Home</a></li>
<li>about us</li>
<li>services</li>
<li>news</li>
<li>request a quote</li>
<li>contact us</li>
<li>track your item</li>
</ul>
</div>
</div>
`.top-header {
border: 2px solid black;
background: black;
}
.header {
background: white;
height: 80px;
width: 100%;
display: flex;
}
.logo {
padding: 0 17px;
flex: 0 0 400px;
align-self: center;
}
.header-right {
flex: auto;
padding: 0 0 0 20px;
}
.top-bar {
background: #000000;
color: white;
padding: 8px 18px;
border-radius: 0 0 0 8px;
}
.nav__nav-bar {
margin: 0;
float: none;
list-style: none;
text-align: right;
display: flex;
padding: 0;
}
.top-bar__content {
display: flex;
}
.top-bar-content {
padding: 0 16px 0 0;
}
.nav__nav-bar li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
color: black;
font-weight: bold;
text-transform: uppercase;
}
.nav__nav-bar li a:hover {
background: yellow;
}
.logo .logo-left {
float: left;
font-size:50px;
color: darkorange;
padding-right: 5px;
}
.logo .logo-right h3 {
padding: 0;
margin: 0;
font-family: serif;
}
.logo .logo-right p {
line-height: 0;
}`
[https://codepen.io/kinjalpatel2207/pen/MWwapLz][1]
I've been going around the web trying to find an answer to how to center my navbar but none of the solution worked.
The code below will show what I have so far with both HTML and CSS.
header {
background: #ffffff;
color: #000000;
padding-top: 30px;
min-height: 70px;
border-bottom: #000000 3px solid;
}
header a {
color: #000000;
text-decoration: none;
text-transform: uppercase;
font-size: 16px;
}
header li {
float: center;
display: inline;
padding: 0 20px 0 20px;
}
header nav {
margin-left: auto;
margin-right: auto;
margin-top: 10px;
}
header #smcontent {
float: left;
}
header #smcontent a {
margin: 0;
}
header #smcontent img {
width: 20px;
}
header .logoimg .center {
display: block;
margin-left: auto;
margin-right: auto;
width: 20%;
}
header a:hover {
color: #cccccc;
font-weight: bold;
}
<header>
<div class="container">
<div id="smcontent">
<a href="https://twitter.com/">
<img src="./images/twitter.png">
</a>
<a href="https://facebook.com/">
<img src="./images/facebook.png">
</a>
</div>
<div class="logoimg">
<a href="index.html">
<img class="center" src="./images/portfolio.png">
</a>
</div>
<nav>
<ul>
<li class="current">Home</li>
<li>Story</li>
<li>Product</li>
<li>Clinique</li>
<li>Promotions</li>
</ul>
</nav>
</header>
This is how it looks like right now:
I have also noticed that in CSS, when I did "float: center;" it had no difference with when I did "float: left;". But when I did "float: right;" it would shift to the right.
ul {
margin: 0 auto;
text-align: center;
}
header {
background: #ffffff;
color: #000000;
padding-top: 30px;
min-height: 70px;
border-bottom: #000000 3px solid;
}
header a {
color: #000000;
text-decoration: none;
text-transform: uppercase;
font-size: 16px;
}
header li {
float: center;
display: inline;
padding: 0 20px 0 20px;
}
header nav {
margin-left: auto;
margin-right: auto;
margin-top: 10px;
margin: 0 auto;
}
header #smcontent a {
margin: 0;
}
header #smcontent img {
width: 20px;
}
header .logoimg .center {
display: block;
margin-left: auto;
margin-right: auto;
width: 20%;
}
header a:hover {
color: #cccccc;
font-weight: bold;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<header>
<div class="container">
<div id="smcontent">
<a href="https://twitter.com/">
<img src="./images/twitter.png">
</a>
<a href="https://facebook.com/">
<img src="./images/facebook.png">
</a>
</div>
<div class="logoimg">
<a href="index.html">
<img class="center" src="./images/portfolio.png">
</a>
</div>
<nav>
<ul>
<li class="current">Home</li>
<li>Story</li>
<li>Product</li>
<li>Clinique</li>
<li>Promotions</li>
</ul>
</nav>
</div>
</header>
</body>
</html>
I have removed the below css from your code
header #smcontent {
float: left;
}
and added margin: 0 auto; text-align: center; to the ul
Try absolute position with float none, left 50% and a left translate of 50% to center your nav bar perfectly.
CSS: add
header .newCenter {
float: none;
position: absolute;
left: 50%;
transform: translate(-50%, 0);
}
HTML: add
<nav class="newCenter">
<ul>
<li class="current">Home</li>
<li>Story</li>
<li>Product</li>
<li>Clinique</li>
<li>Promotions</li>
</ul>
</nav>
Float only applies to left and right. I added display: grid and justify-content: center to your header. I removed float: left; in header #smcontent.
header {
background: #ffffff;
color: #000000;
padding-top: 30px;
min-height: 70px;
border-bottom: #000000 3px solid;
display: grid; //or flex
justify-content: center;
}
header a {
color: #000000;
text-decoration: none;
text-transform: uppercase;
font-size: 16px;
}
header li {
display: inline;
padding: 0 20px;
}
header nav {
margin: 10px auto 0;
}
header #smcontent a {
margin: 0;
}
header #smcontent img {
width: 20px;
}
header .logoimg .center {
display: block;
margin: 0 auto;
width: 20%;
}
header a:hover {
color: #cccccc;
font-weight: bold;
}
<header>
<div class="container">
<div id="smcontent">
<a href="https://twitter.com/">
<img src="./images/twitter.png">
</a>
<a href="https://facebook.com/">
<img src="./images/facebook.png">
</a>
</div>
<div class="logoimg">
<a href="index.html">
<img class="center" src="./images/portfolio.png">
</a>
</div>
<nav>
<ul>
<li class="current">Home</li>
<li>Story</li>
<li>Product</li>
<li>Clinique</li>
<li>Promotions</li>
</ul>
</nav>
</header>
To align text horizontally center use text-align:center. In your to align nav bar content center just add text-align:center to header nav
header nav {
margin-left: auto;
text-align:center;
margin-right: auto;
margin-top: 10px;
}
In below code snippet I have added some images for demonstration purpose.
header {
background: #ffffff;
color: #000000;
padding-top: 30px;
min-height: 70px;
border-bottom: #000000 3px solid;
}
header a {
color: #000000;
text-decoration: none;
text-transform: uppercase;
font-size: 16px;
}
header li {
float: center;
display: inline;
padding: 0 20px 0 20px;
}
header nav {
margin-left: auto;
text-align:center;
margin-right: auto;
margin-top: 10px;
}
header #smcontent {
float: left;
}
header #smcontent a {
margin: 0;
}
header #smcontent img {
width: 20px;
}
header .logoimg .center {
display: block;
margin-left: auto;
margin-right: auto;
width: 20%;
}
header a:hover {
color: #cccccc;
font-weight: bold;
}
<header>
<div class="container">
<div id="smcontent">
<a href="https://twitter.com/">
<img src="https://image.shutterstock.com/image-photo/kiev-ukraine-may-26-2015twitter-260nw-281505518.jpg">
</a>
<a href="https://facebook.com/">
<img src="https://image.shutterstock.com/image-photo/kiev-ukraine-april-27-2015-260nw-278925056.jpg">
</a>
</div>
<div class="logoimg">
<a href="index.html">
<img class="center" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png">
</a>
</div>
<nav>
<ul>
<li class="current">Home</li>
<li>Story</li>
<li>Product</li>
<li>Clinique</li>
<li>Promotions</li>
</ul>
</nav>
</div>
</header>
I have tried this. But it doesn't work. I don't know why it makes the parent div appear like that. I want the divisionContainer to contain them. But it doesn't appear like that.
* {
box-sizing: border-box;
}
body {
font-family: arial;
}
.mainContainer {
border: 1px solid #000;
width: 65%;
}
.header {
width: 100%;
height: 85px;
background: #19578c;
}
.header .container {
padding: 5px;
float: right;
}
.header .headerTitle {
color: #4e94d0;
;
font-family: monospace;
margin: 0;
font-size: 300%;
}
.header .navBar li {
display: inline;
padding: 5px;
}
/* here's the problem */
.divisionContainer {
border: 1px solid #000;
margin-top: 2px;
}
.sidebarContainer {
width: 30%;
float: left;
}
.contentContainer {
width: 70%;
float: right;
}
/* here's the problem */
.navBar {
list-style: none;
padding: 0;
margin: 5px 0 0 0;
color: white;
}
<html>
<head>
<title>thepoopstation</title>
</head>
<body>
<div class="mainContainer">
<div class="header">
<div class="container">
<h1 class="headerTitle">[thepoopstation]</h1>
<ul class="navBar">
<li>home</li>
<li>search</li>
<li>global</li>
</ul>
</div>
</div>
<div class="divisionContainer">
<div class="sidebarContainer">
<div class="container">
<ul class="navBar">
<li>my profile</li>
<li>my friends</li>
</ul>
</div>
</div>
<div class="contentContainer">
<div class="container">
<div class="containerHeading">about thepoopstation</div>
<div>
</div>
</div>
</div>
</body>
</html>
It appears as if the parent divisionContainer is not containing them at all. I wanna fix it.
It because how float works...floated elements are out of flow..so you will need to put a in-flow elements below that div to enforce the parent div to take all the inner element space using :after pseudo element
Stack Snippet
* {
box-sizing: border-box;
}
body {
font-family: arial;
}
.mainContainer {
border: 1px solid #000;
width: 65%;
}
.header {
width: 100%;
height: 85px;
background: #19578c;
}
.header .container {
padding: 5px;
float: right;
}
.header .headerTitle {
color: #4e94d0;
;
font-family: monospace;
margin: 0;
font-size: 300%;
}
.header .navBar li {
display: inline;
padding: 5px;
}
/* here's the problem */
.divisionContainer {
border: 1px solid #000;
margin-top: 2px;
}
.sidebarContainer {
width: 30%;
float: left;
}
.contentContainer {
width: 70%;
float: right;
}
/* here's the problem */
.navBar {
list-style: none;
padding: 0;
margin: 5px 0 0 0;
color: white;
}
.divisionContainer:after {
content: "";
display: table;
clear: both;
}
<div class="mainContainer">
<div class="header">
<div class="container">
<h1 class="headerTitle">[thepoopstation]</h1>
<ul class="navBar">
<li>home</li>
<li>search</li>
<li>global</li>
</ul>
</div>
</div>
<div class="divisionContainer">
<div class="sidebarContainer">
<div class="container">
<ul class="navBar">
<li>my profile</li>
<li>my friends</li>
</ul>
</div>
</div>
<div class="contentContainer">
<div class="container">
<div class="containerHeading">about thepoopstation</div>
<div>
</div>
</div>
</div>
</div>
</div>
body {
margin: 0px;
font-family: verdana, georgia;
overflow-x: hidden;
}
/*****************Blocks*********************/
.navbar {
background-color: #fff;
height: 90px;
width: 100%;
top:0px;
margin-left: 250px;
}
.topContent {
background-color: #eceff1;
height: 200px;
width:100%;
margin-left: 250px;
}
.mainContent {
background-color: #e5e5e5;
height: 800px;
width:800px;
margin-left: 250px;
}
.leftSideNav1 {
height: 100%;
width: 80px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #37474f;
}
.leftSideNav2 {
height: 100%;
width: 200px;
position: fixed;
z-index: 1;
top: 0;
left: 80px;
background-color: #263238;
text-decoration: none;
}
/*****************Elements*********************/
.leftSideNav1__lists a{
font-size: 10px;
color: #eee;
padding-top: 30px;
margin-left: 10px;
text-decoration: none;
}
.leftSideNav2 {
font-size: 12px;
}
.leftSideNav2 .leftSideNav2__lists > ul{
padding-top: 80px;
}
.leftSideNav2__lists ul {
list-style: none;
padding-bottom: 10px;
}
<body>
<div class="container">
<div class="navbar">
</div>
<div class="topContent">
</div>
<div class="mainContent">
</div>
<div class="leftSideNav1">
<div class="leftSideNav1__lists">
<!-- <i class="fa fa-home w3-large"></i> -->
<i class="Tiny material-icons">home</i><br>
Home<br>
<i class="material-icons">pause</i><br>
YouTubers<br>
<i class="material-icons">assignment</i><br>
Campaigns<br>
<i class="material-icons">message</i><br>
Messages<br>
<i class="material-icons">pause</i><br>
Videos<br>
</div>
</div>
<div class="leftSideNav2">
<div class="leftSideNav2__lists">
<ul class="leftSideNav2__list1">Videos
<li>Action Required</li>
<li>Fund YouTuber</li>
<li>Hired & Funded</li>
<li>Edit Requested</li>
</ul>
<ul class="leftSideNav2__list2">Proposals
<li>New</li>
<li>Declined</li>
<li>Changes Required</li>
<li>Changes Declined</li>
</ul>
<ul class="leftSideNav2__list3">Approvals
<li>Waiting for Approval</li>
<li>Approved / Completed</li>
<li>Video in Dispute</li>
</ul>
</div>
</div>
</div>
</body>
Codepen
I have an issue with the anchor links and lists in the sidebars. I am unable to align the anchor links and lists in the 2 sidebars. I am trying to apply the CSS properties but they aren't applying perhaps due to improper hierarchical style of applying.
Currently, this is how it looks:
But this is how I want it to look:
you can do it setting the parent container
.leftSideNav1__lists{
text-align:center;
}
an also removing the left margin from each a tag..
codepen
body {
margin: 0px;
font-family: verdana, georgia;
overflow-x: hidden;
}
/*****************Blocks*********************/
.navbar {
background-color: #fff;
height: 90px;
width: 100%;
top:0px;
margin-left: 250px;
}
.topContent {
background-color: #eceff1;
height: 200px;
width:100%;
margin-left: 250px;
}
.mainContent {
background-color: #e5e5e5;
height: 800px;
width:800px;
margin-left: 250px;
}
.leftSideNav1 {
height: 100%;
width: 80px;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #37474f;
}
.leftSideNav2 {
height: 100%;
width: 200px;
position: fixed;
z-index: 1;
top: 0;
left: 80px;
background-color: #263238;
text-decoration: none;
}
/*****************Elements*********************/
.leftSideNav1__lists a{
display: block;
text-align: center;
font-size: 10px;
color: #eee;
text-decoration: none;
margin-bottom: 20px;
}
.leftSideNav2 {
font-size: 12px;
}
.leftSideNav2 .leftSideNav2__lists > ul{
}
.leftSideNav2__lists ul {
list-style: none;
}
.leftSideNav1__lists > i{
display: block;
text-align: center;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<body>
<div class="container">
<div class="navbar">
</div>
<div class="topContent">
</div>
<div class="mainContent">
</div>
<div class="leftSideNav1">
<div class="leftSideNav1__lists">
<!-- <i class="fa fa-home w3-large"></i> -->
<i class="Tiny material-icons">home</i>
Home
<i class="material-icons">pause</i>
YouTubers
<i class="material-icons">assignment</i>
Campaigns
<i class="material-icons">message</i>
Messages
<i class="material-icons">pause</i>
Videos
</div>
</div>
<div class="leftSideNav2">
<div class="leftSideNav2__lists">
<ul class="leftSideNav2__list1">Videos
<li>Action Required</li>
<li>Fund YouTuber</li>
<li>Hired & Funded</li>
<li>Edit Requested</li>
</ul>
<ul class="leftSideNav2__list2">Proposals
<li>New</li>
<li>Declined</li>
<li>Changes Required</li>
<li>Changes Declined</li>
</ul>
<ul class="leftSideNav2__list3">Approvals
<li>Waiting for Approval</li>
<li>Approved / Completed</li>
<li>Video in Dispute</li>
</ul>
</div>
</div>
</div>
</body>
Try this.
W3Schools
Hello,
I've been trying to integrate a drop down menu based upon the hover over function of an image. I've gone to the above website which gives an example, but I cannot figure it out. Below is my current HTML. The image I would like to have the hover over function work on and from that have a drop down menu is the Logo.png file. I simply cannot figure out how to integrate this into my code. Any direction or help would be appreciated.
::-webkit-scrollbar {
display: none;
}
body {
margin: 0;
background-color: #808080;
}
#menu {
position: fixed;
width: 100%;
height: 140px;
background-color: #555555;
}
#logopic {
height: 100px;
width: 140px;
}
#logo {
float: left;
margin: 1%;
width: 160px;
}
.menuoptions {
border: 1px solid white;
border-radius: 50px;
padding: 14px;
float: left;
letter-spacing: 2px;
list-style-type: none;
color: #FFFFFF;
margin-top: 30px;
margin-left: 45px;
font-size: 125%;
font-weight: bold;
}
.menuoptions:hover {
color: #00b9f1;
background-color: #FFFFFF;
}
#topsection {
padding-top: 150px;
}
ul li {
list-style-position: inside;
}
<div id="menu">
<div id="logodiv">
<a href="index.html">
<img id="logo" src="images/Logo.png">
</a>
</div>
<div id="menulinks">
<ul id="options">
<a href="#income">
<li class="menuoptions">INCOME</li>
</a>
<a href="#expenses">
<li class="menuoptions">EXPENSES</li>
</a>
<a href="#incomedistribution">
<li class="menuoptions">INCOME DISTRIBUTION</li>
</a>
<a href="#spending">
<li class="menuoptions">SPENDING</li>
</a>
<a href="#sidemenu">
<li class="menuoptions">SIDE MENU</li>
</a>
</ul>
</div>
</div>
Use the sibligns selector "+"
::-webkit-scrollbar {
display: none;
}
body {
margin: 0;
background-color: #808080;
}
#menu {
position: fixed;
width: 100%;
height: 140px;
background-color: #555555;
}
#logopic {
height: 100px;
width: 140px;
}
#logo {
float: left;
margin: 1%;
width: 160px;
}
.menuoptions {
border: 1px solid white;
border-radius: 50px;
padding: 14px;
float: left;
letter-spacing: 2px;
list-style-type: none;
color: #FFFFFF;
margin-top: 30px;
margin-left: 45px;
font-size: 125%;
font-weight: bold;
}
.menuoptions:hover {
color: #00b9f1;
background-color: #FFFFFF;
}
#topsection {
padding-top: 150px;
}
ul li {
list-style-position: inside;
}
#menulinks {
display: none;
}
#logodiv:hover + #menulinks {
display: block
}
<div id="menu">
<div id="logodiv">
<a href="index.html">
<img id="logo" src="images/Logo.png">
</a>
</div>
<div id="menulinks">
<ul id="options">
<a href="#income">
<li class="menuoptions">INCOME</li>
</a>
<a href="#expenses">
<li class="menuoptions">EXPENSES</li>
</a>
<a href="#incomedistribution">
<li class="menuoptions">INCOME DISTRIBUTION</li>
</a>
<a href="#spending">
<li class="menuoptions">SPENDING</li>
</a>
<a href="#sidemenu">
<li class="menuoptions">SIDE MENU</li>
</a>
</ul>
</div>
</div>
Germano Plebani > I believe it won't work, because when you stop hovering the logo, the menu will disappear again.
I changed your code a bit to make it a bit more simple (at least, in my opinion) :
<div id="menu">
<ul>
<li id="logo"><img src="your_path"></li>
<li class="menuoptions">INCOME</li>
<li class="menuoptions">EXPENSES</li>
<li class="menuoptions">INCOME DISTRIBUTION</li>
<li class="menuoptions">SPENDING</li>
<li class="menuoptions">SIDE MENU</li>
</ul>
::-webkit-scrollbar {
display: none;
}
body {
margin: 0;
background-color: #808080;
}
#menu {
position: fixed;
width: 100%;
height: 140px;
background-color: #555555;
}
#logo {
height:140px;
}
#logo img{
width:160px;
}
ul{
height:inherit;
width:160px; /* Your menu has the size of your logo */
}
ul:hover {
width:auto; /* when you hover your menu, it will take 100% of the width of it's container */
}
ul li {
float: left;
list-style:none;
}
ul:hover .menuoptions {
display:block;
}
.menuoptions {
border: 1px solid white;
border-radius: 50px;
padding: 14px;
letter-spacing: 2px;
list-style-type: none;
color: #FFFFFF;
margin-top: 30px;
margin-left: 45px;
font-size: 125%;
font-weight: bold;
display:none;
}
.menuoptions:hover {
color: #00b9f1;
background-color: #FFFFFF;
}
I didn't go for optimization neither, but it works fine.