Put Logo In Css Nav Bar - html

I want to know how to put a logo in my css navbar because I don't know how to put a logo in my css navbar. I have no clue on how to put the logo in the css navbar so it would be very nice if one of yall can help me out.
body {
margin: 0px;
}
ul {
list-style-type: none;
overflow: hidden;
margin: 0px auto;
background: #222;
padding: 0px;
}
li {
float: right;
font-size: 20px;
}
li a {
text-decoration: none;
color: white;
padding: 20px 20px;
display: block;
text-align: center;
}
ul li a:hover {
border-bottom: 3px solid grey;
padding-bottom: 17px;
}
img {
height: 70px;
}
<img src="https://oyster.ignimgs.com/mediawiki/apis.ign.com/minecraft/a/ad/Bat.png?width=325">
<ul>
<li>Contact</li>
<li>About</li>
<li>Home</li>
</ul>

The first thing you need to do is to create a columnar structure and have the background on the parent. And then add the logo to the left and links to the right. The best way to do is to use the <header> and <nav> tags as they are really semantic.
Here's something you might find useful:
body {
margin: 0px;
}
/* Add these */
header {
overflow: hidden;
background: #666;
}
header h1 {
float: left;
padding: 0 20px;
}
header nav {
float: right;
padding: 20px 0 0;
}
/* End Add these */
ul {
list-style-type: none;
overflow: hidden;
margin: 0px auto;
padding: 0px;
}
li {
float: left; /* Changed here. */
font-size: 20px;
}
li a {
text-decoration: none;
color: white;
padding: 20px 20px;
display: block;
text-align: center;
}
ul li a:hover {
border-bottom: 3px solid grey;
padding-bottom: 17px;
}
img {
height: 70px;
}
<header>
<h1>
<img src="https://oyster.ignimgs.com/mediawiki/apis.ign.com/minecraft/a/ad/Bat.png?width=325" />
</h1>
<nav>
<ul>
<li>Contact</li>
<li>About</li>
<li>Home</li>
</ul>
</nav>
</header>
Also, I just changed the background colour from #222 to #666 to keep it websafe and also make the logo visible. Feel free to change it.
Preview

Here is a fiddle that I hope will help you get you on the right track;
https://jsfiddle.net/Lyrw49mj/7/
HTML
<ul>
<li class="NavHeader"><a><img src="https://oyster.ignimgs.com/mediawiki/apis.ign.com/minecraft/a/ad/Bat.png?width=325"></a></li>
<li>Contact</li>
<li>About</li>
<li>Home</li>
</ul>
CSS
body {
margin: 0px;
}
ul {
list-style-type: none;
overflow: hidden;
margin: 0px auto;
background: #222;
padding: 0px;
}
li {
float: right;
font-size: 20px;
}
li a {
text-decoration: none;
color: white;
padding: 20px 20px;
display: block;
text-align: center;
}
ul li a:hover {
border-bottom: 3px solid grey;
padding-bottom: 17px;
}
.NavHeader a img{
position: relative;
top: 0px;
left: 0px;
height: 70px;
width: auto;
}
.NavHeader a:hover{
border-bottom: none;
padding-bottom: 20px;
}

Related

How do I include short vertical lines in between links in navbar?

What I'm looking for:
/
What I've got:
I want to include small vertical lines, evenly spaced with matching color, in between the links in my navbar. Below is the CSS code I've written. I'm new to coding and I've searched Google but I keep seeing the same answer which got me these huge lines that I don't want. ???
/* GLOBAL */
body {
margin: 0 auto;
background: grey;
font-family: 'Arial', 'Helvetica Neue', Helvetica, sans-serif;
font-weight: 300;
}
/* NAVBAR */
header {
background: #ffffff;
max-width: 100%;
border-bottom: 2px solid #777777;
}
header::after {
content: '';
display: table;
clear: both;
}
.container {
margin: 0 auto;
max-width: 960px;
}
.logo {
float: left;
background-color: #4aaaa5;
color: #ffffff;
margin: 0;
padding: 20px 30px;
display: inline-block;
font-family: 'Georgia', Times, 'Times New Roman', serif;
}
nav {
float: right;
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
padding-top: 30px;
margin-left: 20px;
**border-right: 1px solid #777777;**
}
nav a {
color: #777777;
text-decoration: none;
}
nav li:last-of-type {
**border-right: none;**
}
nav a:hover {
color: #4aaaa5;
}
===========================================================================
<body>
<header>
<div class="container">
<h1 class="logo">Name</h1>
<nav>
<ul>
<li><a class="active" href="about.html">About</a></li>
<li>Portfolio</li>
<li>Content</li>
</ul>
</nav>
</div>
</header>
</body>
You can consider using pseudo elements. That'll do the trick.
Have a look at this
ul {
list-style:none;
}
ul li{
display:inline-block;
padding:0 7px;
position:relative;
}
ul li:not(:last-child)::after{
content:"";
border:1px solid #e2e2e2;
border-width: 1px 1px 0 0;
position:absolute;
right:-3px;
top:0;
height:100%;
}
<ul>
<li>Home</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
Try adding the border-right to each li tag except the last li tag. And add padding to the each li tag.
like the below code
.nav li{
border-right: 2px solid #c4c4c4;
display: inline-block;
float: left;
padding: 0 15px;
}
.nav li:last-child {
border-right:0;
}
Below is the full working demo here. Hope it helps you.
.nav{
list-style: none;
padding: 0;
margin: 0;
margin-top: 25px;
float: left;
}
.nav li{
border-right: 2px solid #c4c4c4;
display: inline-block;
float: left;
padding: 0 15px;
}
.nav li:last-child {
border-right:0;
}
<ul class="nav">
<li>About</li>
<li>Home</li>
<li>Contact</li>
</ul>
You can do this by using border-right or the way below.
.nav{
list-style: none;
padding: 0;
margin: 0;
margin-top: 25px;
float: left;
}
.nav li{
display: inline-block;
position: relative;
float: left;
padding: 0 15px;
}
.nav li::after {
position: absolute;
width: 2px;
right: 0;
content: ' ';
height: 100%;
background: rgba(0, 0, 0, 0.2);
}
.nav li:last-child::after {
width: 0;
}
<ul class="nav">
<li>About</li>
<li>Home</li>
<li>Contact</li>
</ul>
working demo
<ul class="nav">
<li>About</li>
<li>Home</li>
<li>Contact</li>
</ul>
.nav{
list-style: none;
padding: 0;
margin: 0;
margin-top: 25px;
float: left;
}
nav li {
display: inline-block;
padding-top: 30px;
padding-left:10px
padding-right:10px;
}
.nav li:after{
content:'|';
display:inline-block;
color:#dddddd;
vertical-align:middle;
}
.nav li:last-child:after {
display:none;
}
Add the separator image as a background image on the li.
#nav li + li {
background:url('seperator.gif') no-repeat top left;
padding-left: 10px
}

Style for pills in navbar

How can i make custom pills for navbar like on
screenshot?
I did it by myself, but pills are inside of navbar and the text is not in the center of pill.
I understand, that the problem is inside of .menu li a:hover:not and .menu li a:hover:not(.active). But i don't know, how to make outside of navbar(i mean borders of the pills like on screenshot)
.menu {
padding-top: 10px;
padding-bottom: 10px;
font-size: 20px;
margin-left: auto;
margin-right: auto;
}
.menu ul {
margin: 0 auto;
padding: 0px;
overflow: hidden;
display: block;
list-style:none;
border-radius: 20px 0 0 0;
background-color: #0b78ad;
text-align: center;
}
.menu li {
list-style-type: none;
text-align: center;
display: inline-block;
}
.menu ul li a {
padding: 10px;
padding-left: 50px;
margin: 0px;
display: block;
text-align: center;
}
.menu li a:hover:not(.active) {
color: #325491;
}
.menu li.active a {
border-radius: 20px 0 20px 0;
border-style: solid;
border-width: 2px;
border-color: #325491;
color: #325491;
background-color: white;
}
<div class="menu">
<ul>
<li class="active">startseite</li>
<li>über uns</li>
<li>zell-linien</li>
<li>downloads</li>
<li>kontakt</li>
</ul>
</div>
.menu {
font-family: Arial, sans-serif;
}
.menu ul {
padding: 0;
list-style: none;
background-color: #0b78ad;
text-align: center;
white-space: nowrap;
height: 34px;
margin: 30px 0;
}
.menu li {
position: relative;
top: -10px;
list-style-type: none;
text-align: center;
display: inline-block;
margin: 0 10px;
}
.menu ul li a {
position: relative;
display: block;
padding: 18px;
border-top-left-radius: 10px;
border-bottom-right-radius: 10px;
border: 2px solid transparent;
text-align: center;
text-decoration: none;
text-transform: uppercase;
color: #FFF;
font-weight: 700;
line-height: 1;
transition: all .1s ease-in-out;
}
.menu ul li a.active,
.menu ul li a:hover {
background-color: #FFF;
border: 2px solid #0b78ad;
color: #0b78ad;
}
<div class="menu">
<ul>
<li>Home</li>
<li>About</li>
<li>Skill</li>
<li>Contact</li>
</ul>
</div>
You can do it with just a plain border-radius, like any other property it starts with top, right, bottom and right
.button {
display: inline-block;
background-color: #ededed;
border: 1px solid deepskyblue;
border-radius: 10px 0 10px 0;
padding: 10px 16px;
text-align: center;
}
<div class="button">shape</div>
You can do like this.
1. Navbar you can give a 'max-height' property so that we can set a height for the first-child.
#nav-id {
max-height: 65px;
margin-top: 20px;
}
2.We can set the first 'li' 'margin-top' or 'position'
li:first-child {
border-radius: 15px 50px;
padding: 20px;
width: 200px;
height: 106px;
background: blue;
background-position: center;
margin-top:-20px;
z-index:1;
text-align:center;
}
Here is the working copy:
https://codepen.io/nabanitadasgupta/pen/aLNGgo

CSS display block not working with anchor links

I am trying to make a dropdown-menu. So for this purpose, I've created a div and some anchor links inside, but the display: block; is not working. The cursor is default & the anchor does not seem to be a link.
Here is my HTML:
<div id="custom-wrapper">
<ul>
<li>View full profile</li>
<li>Logout</li>
</ul>
</div>
The CSS:
div#custom-wrapper
{
width: 200px;
height: auto;
position: fixed;
right: 15px;
top: 38px;
border-radius: 6px;
background: #fff;
border: 1px solid lightgrey;
}
div#custom-wrapper ul
{
list-style-type: none;
}
div#custom-wrapper ul li
{
width: 100%;
height: 50px;
line-height: 50px;
text-align: center;
}
div#custom-wrapper ul li a
{
text-decoration: none;
display: block;
color: grey;
font-family: sans-serif;
border-bottom: 1px solid lightgrey;
}
What's wrong with my code?
Display block element works perfect, Just you need to remove padding and margin for ul element.
/*** Default CSS Attributes ***/
#custom-wrapper ul {
margin: 0;
padding: 0;
}
/*** Overwrite CSS Attributes ***/
#custom-wrapper ul {
margin: 0 !important;
padding: 0 !important;
}
div#custom-wrapper {
width: 200px;
height: auto;
position: fixed;
right: 15px;
top: 38px;
border-radius: 6px;
background: #fff;
border: 1px solid lightgrey;
}
div#custom-wrapper ul {
list-style-type: none;
margin: 0;
padding: 0;
}
div#custom-wrapper ul li {
width: 100%;
height: 50px;
line-height: 50px;
text-align: center;
}
div#custom-wrapper ul li a {
text-decoration: none;
display: block;
color: grey;
font-family: sans-serif;
border-bottom: 1px solid lightgrey;
}
<div id="custom-wrapper">
<ul>
<li>View full profile</li>
<li>Logout</li>
</ul>
</div>
There is a padding for ul. Remove it:
div#custom-wrapper ul
{
list-style-type: none;
padding:0;
}
That is not the right way to build a dropdown. Check this (you would need to include Bootstrap library though, which by the way may make your life much easier).

making nav li reach end of page

I am trying to figure out how to remove the last black section of my secondary nav.
I want the "wishlist" link to be the last thing there, not have the border and then more black space afterwards basically. I'm just not sure how to do this.
my html:
<title>LOST Collector</title>
<link rel="stylesheet" type="text/css" href="main.css"/>
</head>
<body>
<!--Header-->
<header>
<a href="http://www.lostcollector.com">
<img src="images/logo.png" alt="Lost Collector" title="Lost Collector"/>
</a>
<!--Primary navigation-->
<nav>
<ul>
<li>Home</li>
<li>About Us</li>
<li>Contact</li>
</ul>
</nav>
</header>
<!-- Secondary Navigation -->
<ul id="navigation_layout">
<li>Artwork</li>
<li>Autographs</li>
<li>Books/Magazines</li>
<li>Clothing</li>
<li>Dvds and Cds</li>
<li>Film Crew</li>
<li>Original Props</li>
<li>Special Events</li>
<li>Toys and games</li>
<li>Trading cards</li>
<li>Everything else</li>
<li>Wish list</li>
</ul>
my css:
body {
width: 1200px;
height: 130px;
margin: 0 auto;
background-color: #ffffff;
color: #111111;
font-family: "Georgia", "Times New Roman", serif;
font-size: 90%;
}
header a {
float:left;
display:inline-block;
}
header a img {
margin-top: 10px;
margin-bottom: 10px;
margin-left: 10px;
margin-right:10px;
display: inline;
height: 112px;
width:; 113px;
}
nav {
display: inline;
float: right;
}
nav ul {
list-style: none;
display: inline;
}
nav ul li {
display: inline-block;
text-decoration: none;
font-size: 90%;
font-weight: bold;
color: #000000;
margin-right: 50px;
padding: 40px 30px;
padding: right 10px;
}
nav li a {
display: inline-block;
padding: 4px 3px;
text-decoration: none;
font-size: 90%;
font-weight: bold;
color: #000000;
}
nav li a:hover {
color: #ff0000;
background-color: #ffffff;
}
/*secondary navigation*/
#navigation_layout {
width: 100%;
float: left;
margin: 0 0 3em 0;
padding: 0;
list-style: none;
background-color: #000000;
border-bottom: 1px solid #ffffff;
border-top: 1px solid #ffffff;
}
#navigation_layout li {
float: left;
}
#navigation_layout li a {
display: block;
padding: 4px 3px;
text-decoration: none;
font-size: 90%;
font-weight: bold;
color: #ffffff;
border-right: 2px solid #ffffff;
}
#navigation_layout li a:hover {
color: #ff0000;
background-color: #fff;
}
I have put it into a jsfiddle here, so it is clearer what I am trying to do.
https://jsfiddle.net/thzfm0fe/1/
Apply the background color to your list items <li> and not the <ul>.
Remove background-color from here:
#navigation_layout {
width: 100%;
float: left;
margin: 0 0 3em 0;
padding: 0;
list-style: none;
/* background-color: #000000; */
border-bottom: 1px solid #ffffff;
border-top: 1px solid #ffffff;
}
And add to here:
#navigation_layout li {
float: left;
background-color: black;
}
https://jsfiddle.net/thzfm0fe/3/
A <ul> by default is a block level element and will fill up the full width of the parent element. Your list items <li> did not fill up the full width of the parent but your <ul> did, hence the extra black after your list items.
By applying the background color to the <li> you don't need to add white border to your anchors anymore. You could apply a margin instead.

CSS: horizontal align two inner divs vertically

I got a major problem, that I don't seem to solve. I'm trying to get a logo (text) and a navbar (text) to align horizontally, but when that's completed, it seems like it doesn't align so, that the navbar stays at the same line as the logo.
Can anyone help me?
#navbar {
width: 100%;
margin: 0px auto;
}
#logo {
width: 40%;
float: left;
margin: 0px;
padding: 0px;
}
#navbar-links {
width: 40%;
float: right;
margin: 0px;
padding: 0px;
list-style: none;
}
#navbar-links ul {
width: 40%;
padding: 8px 0px;
margin: 0px;
float: right;
}
#navbar-links li {
display: inline;
padding: 0px;
}
#navbar-links li a:link {
color: #000000;
text-decoration: none;
}
#navbar-links li a:visited {
color: #000000;
text-decoration: none;
}
#navbar-links li a:hover {
color: #c3c3c3;
text-decoration: none;
}
#navbar-links li a:active {
color: #c3c3c3;
text-decoration: none;
}
<div id="navbar">
<div id="Logo">
<h1>NUMBERS</h1>
</div>
<div id="navbar-links">
<ul>
<li>Home
</li>
<li>Two
</li>
<li>Three
</li>
</ul>
</div>
</div>
Reposition the #navbar-links before #Logo:
#navbar {
width: 100%;
margin: 0px auto;
}
#logo {
width: 40%;
float: left;
margin: 0px;
padding: 0px;
}
#navbar-links {
width: 40%;
float: right;
margin: 0px;
padding: 0px;
list-style: none;
}
#navbar-links ul {
width: 40%;
padding: 8px 0px;
margin: 0px;
float: right;
}
#navbar-links li {
display: inline;
padding: 0px;
}
#navbar-links li a:link {
color: #000000;
text-decoration: none;
}
#navbar-links li a:visited {
color: #000000;
text-decoration: none;
}
#navbar-links li a:hover {
color: #c3c3c3;
text-decoration: none;
}
#navbar-links li a:active {
color: #c3c3c3;
text-decoration: none;
}
<div id="navbar">
<div id="navbar-links">
<ul>
<li>Home
</li>
<li>Two
</li>
<li>Three
</li>
</ul>
</div>
<div id="Logo">
<h1>NUMBERS</h1>
</div>
</div>
Don't use float for the layout, then you can simply use the vertical-align property.
#logo,
#navbar-links {
display: inline-block;
margin-right: -.25em // If you are not compressing html
vertical-align: middle;
width: 50%; //adjust to taste.
}
#navbar-links {
text-align: right;
}
The issue you are facing is very simple one ...
you had id in the HTML as "Logo" and in css it is "logo".
So because of the case sensitivity, browser is not connecting the CSS to HTML.
#Logo { //Its case sensitive so not "logo"
width: 40%;
float: left;
margin: 0px;
padding: 0px;
}
You can refer this link for the code correction