CSS: Possibly Collapsed Margins? - html

I have tried applying a Overflow: hidden/auto to varios classes of CSS.
I have tried applying a Clear: both to various CSS sections as well, so far no go.
I am just unsure on how to fix this.
https://codepen.io/Tsukiyono/pen/KXLZbP
If you change the Codepen to a mobile size, the hamburger menu pops up, when clicked there is a small grey box that should cover the whole screen, but it only goes about 50px down or so. It used to work correctly, but I made a change at some point and something broke and now I cant seem to fix it.
If one of the above options is the correct fix, could someone help me figure out the correct CSS (or combination of CSS) that I can add it to to fix my issue?
//Variables
var overlay = document.querySelector(".fa-bars");
var times = document.querySelector(".fa-times");
var menuSelect = document.querySelector("#hiddenNav")
var quoteFade = document.querySelector(".toggleOff")
var navScroll = document.querySelector("#navbar");
//Hamburger Menu Display Overlay
overlay.addEventListener("click", function(){
if (times.classList.contains("closed")){
//toggle Display property for hiddenNav
menuSelect.classList.add("toggle");
//FadeOut Hamburger
overlay.classList.add("closed");
//FadeIn X Menu
times.classList.remove("closed");
}
})
//Closes Out Overlay Display Menu
times.addEventListener("click", function(){
if (overlay.classList.contains("closed")){
//toggle Display Property for hiddenNav
menuSelect.classList.remove("toggle");
//FadeIn Hamburger
overlay.classList.remove("closed");
//FadOut X Menu
times.classList.add("closed");
}
})
//Loads text after the page loads with transition
function onStart() {
quoteFade.classList.add("toggleOn");
quoteFade.classList.remove("toggleOff");
}
window.onload = onStart;
//Change Navbar Opacity on Scroll
window.onscroll = function (){
if (document.body.scrollTop >= 100){
navScroll.classList.add("colored");
navScroll.classList.remove("transparent");
alert("working");
}
else {
navScroll.classList.add("transparent");
navScroll.classList.remove("colored");
}
};
/* Simple Resets */
html, body {
background-color: #fff;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
font-family: 'Raleway', sans-serif;
}
/*------------------------------------------------------------------
[1. NavBar - Primary]
*/
div.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 30px;
}
nav {
float: left;
width: 100%;
outline: none;
position: fixed;
}
/* used to make Navbar change color on Scroll */
nav.transparent {
background-color: transparent;
}
nav.colored {
background-color: white;
transition: 1s;
}
nav h1 {
padding-left: .5em;
color: #000;
text-transform: uppercase;
float: left;
font-size: 1.5em;
}
nav ul {
list-style-type: none;
padding: 0;
margin: 10px;
float: right;
}
nav ul li {
display: inline-block;
}
nav ul li:hover {
font-weight: bold;
text-decoration: underline;
transition: .7s;
}
nav ul li a {
padding: 1em;
color: #000;
display: block;
text-transform: uppercase;
text-decoration: none;
}
i.fa-bars {
color: blue;
float: right;
font-size: 28px;
padding: 5px;
margin-top: 20px;
display: none;
}
/*------------------------------------------------------------------
[1.5 NavBar - Hidden Overlay]
*/
div.overlay {
background-color: rgba(0,0,0,0.7);
position: absolute;
width: 100%;
height: 100%;
display: none;
transition: .7s;
}
/* Allows Hidden Nav to be displayed */
div.overlay.toggle {
display: block;
}
i.fa-times {
color: #fff;
font-size: 2.5em;
padding: 5px;
position: absolute;
right: 30px;
top: 20px;
display: block;
}
/* Shuts down the FA Icons on click with JS */
i.fa-bars.closed,
i.fa-times.closed {
display: none;
transition: .7s;
}
div.overlay ul{
padding: 0;
margin: 100px 0 0 0;
display: block;
width: 100%;
text-align: center;
}
div.overlay ul li {
display: block;
}
div.overlay ul li a {
font-size: 1.25em;
padding: 1em;
color: #fff;
display: block;
text-transform: uppercase;
text-decoration: none;
}
/*------------------------------------------------------------------
[2 Hero Image]
*/
.hero-section {
width: 100%;
height: 50em;
margin: auto;
background: url("img/alexandru-tudorache-17852.jpg") no-repeat 50% 50%;
display: table;
top: 0;
background-size: cover;
}
/*------------------------------------------------------------------
[2.5 Quote Text]
*/
#quoteBox .container-fluid {
padding-top: 9em;
text-align: center;
}
.toggleOn {
opacity: 1;
transition: 3s;
}
.toggleOff{
opacity: 0;
}
#content {
height: 35em;
}
p#quote {
max-width: 25em;
color: white;
text-shadow: 0 0 3px #000;
font-family: "Adobe Caslon Pro", "Hoefler Text", Georgia, Garamond, Times, serif;
letter-spacing: 0.1em;
text-align: center;
margin: 40px auto;
text-transform: lowercase;
line-height: 145%;
font-size: 2.1em;
font-variant: small-caps;
}
/*------------------------------------------------------------------
[9 Footer]
*/
footer {
background-color: #000;
height: 6em;
width: 100%;
margin: 0;
padding: 0;
}
footer p {
margin-bottom: .5em;
}
.social-media-contact {
color: white;
text-align: center;
}
.social-media-contact i {
padding: 0 .5em;
margin: 0px 10px;
}
.social-media-contact .fa {
font-size: 1.5em;
}
.footerNav ul {
text-transform: uppercase;
list-style-type: none;
margin-right: 3em;
}
.footerNav ul li {
display: inline;
color: #fff;
}
.footerNav ul li a {
color: #fff;
padding: .4em;
text-decoration: none;
}
.footerNav li:not(:first-child):before {
content: "|";
padding: .3em;
}
/*------------------------------------------------------------------
[10 Media Queries]
*/
/* Navbar */
#media all and (max-width: 768px){
nav ul {
display: none;
}
i.fa-bars {
display: block;
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Marlee Branding Site</title>
<!-- Google Fonts - RaleWay -->
<link href="https://fonts.googleapis.com/css?family=Raleway:400,700" rel="stylesheet">
<!--Font Awesome -->
<link rel="stylesheet" href="assets/fa/css/font-awesome.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!-- Navbar -->
<nav class="transparent" id="navbar">
<!-- Collapsed Navbar -->
<div class="overlay" id="hiddenNav">
<div class="container">
<i class="fa fa-times closed" aria-hidden="true"></i>
<ul class="nav">
<li>Home</li>
<li>About</li>
<li>Now</li>
<li>Blog</li>
<li>Contact</li>
</ul> <!-- End Collapse Nav -->
</div>
</div>
<!-- Standard Navbar -->
<div class="container" id="navbar">
<h1>Logo</h1>
<ul class="nav">
<li>Home</li>
<li>About</li>
<li>Now</li>
<li>Blog</li>
<li>Contact</li>
</ul> <!-- End Nav -->
<i class="fa fa-bars" aria-hidden="true"></i>
</div> <!-- End Container -->
</nav><!-- End Nav -->
<!-- Hero Image and Quote -->
<section class="hero-section">
<div class="hero-image">
<div id="quoteBox">
<div class="container-fluid full toggleOff">
<div id="content">
<p id="quote">"Action is the foundational key to all success"
<br> — Pablo Picasso</p>
</div>
</div>
</div>
</div>
</section>
<footer>
<div class="social-media-contact container">
<p>Connect With Me</p>
<i class="fa fa-facebook-official" aria-hidden="true"></i>
<i class="fa fa-linkedin" aria-hidden="true"></i>
<i class="fa fa-instagram" aria-hidden="true"></i>
<i class="fa fa-envelope" aria-hidden="true"></i>
<div class="footerNav">
<ul>
<li>Home</li>
<li>About</li>
<li>Now</li>
<li>Blog</li>
<li>Contact</li>
</ul>
</div>
</div>
</footer>
<!-- Custom JS -->
<script src="scripts.js"></script>
</body>
</html>

This is because of this CSS rule:
div.overlay {
height: 100%;
}
Removing this makes it work:
Note: It's not because of overflow, but just limited in height.
A better alternative would be using min-height (thanks to G-Cyr):
div.overlay {
min-height: 100%;
}

Related

Issue with button dropdown

I'm pretty new to web coding, but working currently on a small project for a community of mine, where I try to create a small simple website with basic information.
My issue here is I can't get to work with my dropdown menu, it wont show on hove over or show my dropdown menu, but once I remove button my dropdown menu will work proberly.
body {
font-family: Arial;
}
/* used # is id="" under html code */
/* used . is class="" under html code */
/* Change value inside #navbar, will change style on main menu */
#navbar {
overflow: hidden;
position: fixed;
list-style-type: none;
top: 0;
width: 100%;
text-align: center;
text-transform: uppercase;
font-weight: bold;
}
#navbar a {
float: left;
display: block;
color: #732119;
text-align: center;
padding: 10px 10px;
text-decoration: none;
font-size: 12px;
}
#navbar a:hover {
background: #F2CDA0;
color: #732119;
opacity: 0.7;
}
/* Change value inside navdown, will change style on Dropdown menu */
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 12px;
font-weight: bold;
text-transform: uppercase;
border: 0;
outline: 0;
padding: 10px 10px;
background-color: inherit;
color: #732119;
}
.dropdown-content {
display: none;
position: absolute;
background-color: inherit;
min-width: 140px;
z-index: 1;
}
.dropdown-content a {
float: none;
color: #732119;
padding: 10px 10px;
text-decoration: none;
display: block;
text-align: center;
}
.dropdown-content a:hover .dropbtn {
background: #F2CDA0;
color: #732119;
}
/* Change value inside this, will change logo on the site */
#img_center {
display: block;
margin-right: auto;
margin-left: auto;
}
/* Center everything on the side inside <table> */
#table_main {
margin-left: auto;
margin-right: auto;
}
/* Footer style, customize footer bar here */
#footer {
position: fixed;
text-transform: uppercase;
text-align: center;
font-size: 12px;
font-weight: bold;
color: black;
left: 0;
bottom: 0;
width: 100%;
}
#h2_headertext {
font-size: 16px;
text-transform: uppercase;
}
<table id="table_main">
<tr>
<td>
<!-- Main Menu -->
<ul id="navbar">
<li>Forside</li>
<li>Bliv Medlem</li>
<li>Medlemsfordele</li>
<!-- Dropdown Menu -->
<div class="dropdown">
<button class="dropbtn">Information</button>
<div class="dropdown-content">
Vedtægter
Regler
Hvem er vi
Bestyrelsen
</div>
</div>
<li><a class="active" href="#kontakt">Kontakt</a></li>
</ul>
<!--Center picture of the side -->
<div id="img_center">
<img src="images/logo.png" alt="">
<h2 id="h2_headertext">Velkommen</h2>
</div>
</td>
</tr>
</table>
<div id="footer">
<p>Copyright 2022</p>
</div>
Please study the following model code carefully. It shows the principle of a dropdown menu on CSS . There is literally nothing there. Learn to understand how it works.
ul,
li {
list-style: none;
padding: 0;
}
.submenu {
display: none;
}
.item:hover>.submenu {
display: block;
}
<ul class="menu">
<li class="item">
Hover me!
<ul class="submenu">
<li class="subitem">subitem1</li>
<li class="subitem">subitem2</li>
<li class="subitem">subitem3</li>
</ul>
</li>
</ul>

How to incorporate links inside a hamburger menu?

I am having a hard time on how to re-arrange my HTML/CSS code in order to move a few links inside of a hamburger nav menu.
I would like to have 'home' always visible but then, I would like the other linked pages to fall inside the hamburger menu, only visible when clicking the menu...
I would like the following to be inside the hamburger menu:
About
Contact
Portfolio ,etc.
Any suggestions on how to achieve this?
* {
text-decoration: none;
}
body {
background-color: #f3f3f3;
}
header {
background-color: #fff;
width: 100%;
height: 100px;
display: table-cell;
}
.header-logo img {
height:100px;
padding: 10px 0px 10px 10px;
float: left;
}
header nav ul {
display: block;
margin: 0 auto;
width: fit-content;
padding-top: 30px;
}
header nav ul li {
display: inline-block;
padding: 0 5px;
}
header nav ul li a {
font-family:'Sorts Mill Goudy', serif;
font-size: 16px;
color: #111;
text-transform: uppercase;
}
.sub {
display: none;
background-color: rgb(70, 149, 223);
margin-left: 5%;
height: auto;
}
/* HAMBURGER MENU */
.nav div {
height: 4px;
background-color: rgb(20, 15, 15);
margin: 5px 0;
border-radius: 25px;
transition: 0.3s;
}
.nav {
width: 30;
display: block;
float: right;
margin: 1em 0 0 1em;
padding-right: 10px;
}
.one {
width: 30px;
}
.two {
width: 20px;
}
.three {
width: 25px;
}
.nav:hover div{
width: 30px;
}
ul li a:hover {
color: rgb(255, 255, 255);
}
<header>
<div class="header-logo">
<img src="img/Milestonehackers.jpg" alt="Milestonehackers logo">
</div>
<nav>
<ul> <li>Home</li></ul>
<ul>
<a href="#" class="nav">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
<li>Podcast</li>
<li>Newsletter</li>
<li>Blog</li>
<li>Contact</li>
<div class="sub">
<li>Subscribe</li>
</div>
</a>
</ul>
</nav>
</header>
What you are looking for is called toggle. For this you need to use javascript or jquery (a simplified javascript "version"). To easy explain this, put for example a parent div for the child elements you want to toggle. Then in your css display this parent div none. Then you use jquery to be able to tell what you want to be clickable and then later what you want to toggle.
//Script.js
$(document).ready(function(){ //Use ready to make a function available after the document is loaded
$(".nav").click(function(){
$("#hamburger").toggle(250);
});
});
/* Style.css */
* {
text-decoration: none;
}
body {
background-color: #f3f3f3;
}
header {
background-color: #fff;
width: 100%;
height: 100px;
display: table-cell;
}
.header-logo img {
height:100px;
padding: 10px 0px 10px 10px;
float: left;
}
header nav ul {
display: block;
margin: 0 auto;
width: fit-content;
padding-top: 30px;
}
header nav ul li {
display: inline-block;
padding: 0 5px;
}
header nav ul li a {
font-family:'Sorts Mill Goudy', serif;
font-size: 16px;
color: #111;
text-transform: uppercase;
}
.sub {
display: none;
background-color: rgb(70, 149, 223);
margin-left: 5%;
height: auto;
}
/* HAMBURGER MENU */
.nav div {
height: 4px;
background-color: rgb(20, 15, 15);
margin: 5px 0;
border-radius: 25px;
transition: 0.3s;
}
.nav {
width: 30;
display: block;
float: right;
margin: 1em 0 0 1em;
padding-right: 10px;
}
.one {
width: 30px;
}
.two {
width: 20px;
}
.three {
width: 25px;
}
.nav:hover div{
width: 30px;
}
#hamburger{
display:none;
}
ul li a:hover {
color: rgb(255, 255, 255);
}
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type = "text/javascript" src = "script.js">
</head>
<header>
<div class="header-logo">
<img src="https://milestonehackers.com/img/Milestonehackers.jpg" alt="Milestonehackers logo">
</div>
<nav>
<ul> <li>Home</li></ul>
<ul>
<a href="#" class="nav">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
<div id = "hamburger">
<li>Podcast</li>
<li>Newsletter</li>
<li>Blog</li>
<li>Contact</li>
</div>
<div class="sub">
<li>Subscribe</li>
</div>
</a>
</ul>
</nav>
</header>
Edit: I added the src to the new script.js file which should contain your click function:)
Don't think you could achieve what you want only using CSS, maybe with a lot of CSS "hacks". I'd suggest adding some javascript to show on click.
I'd recommend checking this page https://www.w3schools.com/howto/howto_js_mobile_navbar.asp since they have an example just like the one you trying to achieve.

Responsive Centering HTML5

Okay, here it goes:
I am creating my first website. Immediately come across a problem which seems difficult to overcome.
I want to center my image between the header and footer which will stay centered vertically and horizontally, regardless of screen size.
I've seen examples using flexbox where you can center text and whatnot in the middle of the target area. Seems like its useful. I tried it but maybe i haven't applied it correctly.
My code so far
#import 'https://fonts.googleapis.com/css?family=Alegreya+Sans';
* {
margin: 0;
padding: 0;
border: 0;
}
body {
color: grey;
font-family: 'Alegreya', sans-serif;
margin: 0;
}
img {
max-width: 100%;
height: auto;
width: auto;
}
.banner {
width: 100%;
height: 100%;
display: flex;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
align-items: center;
justify-content: center;
}
.banner-inner {
max-width: 60%;
margin: 0 auto;
}
header {
width: 100%;
height: 80px;
display: block;
}
#header-inner {
max-width: 1200px;
margin: 0 auto;
}
/*--- START NAVIGATION --*/
nav {
float: right;
/* Top, Right, Bottom, Left */
padding: 25px 20px 0 0;
}
#menu-icon {
display: hidden;
width: 40px;
height: 40px;
background: url(img/nav.png) center;
}
a:hover#menu-icon {
border-radius: 4px 4px 0 0;
}
ul {
list-style-type: none;
}
nav ul li {
font-family: 'Alegreya Sans', sans-serif;
font-size: 150%;
display: inline-block;
float: left;
padding: 10px;
font-weight: bold;
}
nav ul li a {
color: grey;
text-decoration: none;
font-weight: bolder;
}
nav ul li a:hover {
color: lightgrey;
}
.current {
color: black;
}
/* --- MUSIC PAGE --*/
.music-wrapper {
width: 100%;
text-align: center;
}
.album-list figure {
display: inline-block;
margin: 10%;
}
.album-list figcaption {
text-align: center;
font-size: 150%;
font-family: 'Alegreya Sans', sans-serif;
font-weight: bold;
margin: 2%;
}
.album-list a {
text-decoration: none;
}
/* --- SOCIAL AND FOOTER --*/
footer {
width: 100%;
}
.social {
list-style-type: none;
text-align: center;
}
.social li {
display: inline;
}
.social i {
font-size: 200%;
margin: 0.5%;
padding: 0.5% 4% 0.5% 4%;
color: grey;
}
.social i:hover {
color: lightgrey;
}
footer.second {
max-height: 100px;
position: fixed;
bottom: 0px;
z-index: 10;
background: white;
border-top: 1px solid grey;
}
footer.second p {
padding-bottom: 5px;
text-align: center;
color: grey;
font-weight: bold;
}
/*---- MEDIA QUERIES---- */
#media screen and (max-width: 760px) {
header {
position: absolute;
}
#logo {
margin: 15px 0 20px -25px;
background: url(img/SA_mobile.png) no-repeat center;
}
.banner {
padding-top: 150px;
}
#menu-icon {
display: inline-block;
color: #000000;
}
nav ul, nav:active ul {
display: none;
z-index: 1000;
position: absolute;
padding: 20px;
right: 20px;
top: 60px;
border: 2px solid #000000;
border-radius: 5px 0 5px 5px;
width: 50%;
}
nav:hover ul {
display: block;
background: #FFF;
}
nav li {
text-align: center;
width: 100%;
padding: 10px 0;
}
.social i {
font-size: 150%;
padding: 2% 4% 2% 4%;
}
/*--- MUSIC PAGE --*/
.music-wrapper {
padding-top: 25%;
padding-bottom: 25%;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--Content fits mobile screens-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.12/css/all.css" integrity="sha384-G0fIWCsCzJIMAVNQPfjH08cyYaUtMwjJwqiRKxxE/rx96Uroj1BtIQ6MLJuheaO9" crossorigin="anonymous">
<title>SPAZ Attack</title>
</head>
<body>
<header>
<div class="header-inner">
<nav>
<!--- Icon For Moblie Version -->
<ul>
<li>Home</li>
<!--- Albums/Videos/Audio -->
<li>Music</li>
<!--- Calander gig dates/book us -->
<li>Gigs</li>
<!--- About the band -->
<li>Bio</li>
<!--- Merchandise -->
<li>Merch</li>
<!--- Contact Info -->
<li>Contact</li>
</ul>
</nav>
</div>
</header>
<!--- END HEADER -->
<section class="banner">
<div class="banner-inner">
<img src="img/spazAttackLogoSmaller1.png">
</div>
</section>
<!-- END BANNER -->
<!--- END FOOTER -->
<footer class="second">
<div>
<ul class="social">
<li><i class="fab fa-facebook"></i></li>
<li><i class="fab fa-youtube"></i></li>
<li><i class="fab fa-bandcamp"></i></li>
<!-- Don't Have YET
<li><i class="fa fa-instagram"></i></li>
<li><i class="fa fa-twitter"></i></li>
-->
</ul>
</div>
<p>© SPAZ Attack</p>
</footer>
<!--- END SOCKET -->
</body>
</html>
Checkout this fiddle: https://jsfiddle.net/8cyjc9qw/
.mid {
height: 70vh;
display: flex;
justify-content: center;
align-items: center;
}
I have used some other examples to demonstrate how it would look. I have used vh for header and footer and assign the remaining height to main content section and use flexbox to center the image. Hope this helps.

I want to have my nav bar in my header next to my logo

I've made a website for a school project and want to improve the design a little more. I think the logo makes the header a little bit to big. So I want to move my navbar from under the header to inside the header, to make it look smaller. That's all. I'll post the code and photos underneath.
This is how it looks now
How I want it to be
/* -----------------------
Layout
------------------------*/
.container {
max-width: 70em;
margin: 0 auto;
}
.header {
font-family: 'Handlee', cursive;
color: #fff;
background: #7eabac;
padding: 0.5em 0em;
}
.header-heading {
margin: 0;
max-width: 300px;
margin-left: 400px;
max-height: 300px;
}
.nav-bar {
background: #e9f1f1;
padding: 0;
}
.content {
overflow: hidden;
padding: 1em 1.25em;
background-color: #fff;
}
.main,
.zijkant {
margin-bottom: 1em;
}
.footer {
color: #fff;
background: #656565;
padding: 1em 1.25em;
}
/* -----------------------
Navbar
------------------------*/
.nav {
margin: 0;
padding: 0;
list-style: none;
font-family: 'Open Sans Condensed', sans-serif;
}
.nav li {
display: inline;
margin: 0;
}
.nav a {
display: block;
padding: .7em 1.25em;
color: #black;
text-decoration: none;
border-bottom: 1px solid gray;
}
.nav a:link {
color: black;
}
.nav a:visited {
color: black;
}
.nav a:focus {
color: black;
background-color: white;
}
.nav a:hover {
color: black;
background-color: #eededb;
}
.nav a:active {
color: white;
background-color: #f4ebe9;
}
<!DOCTYPE html>
<html lang="nl">
<head>
<link rel="stylesheet" href="etc/css/styles.css">
</head>
<script type="text/javascript">
function zoom() {
document.body.style.zoom = "-20%"
}
</script>
<body onload="zoom()">
<div class="header">
<div class="container">
<img src="etc/img/logo-wec.png" class="header-heading"></img>
</div>
</div>
<div class="nav-bar">
<div class="container">
<ul class="nav">
<li><a class="active" href="index.html">Home</a>
</li>
<li>Nieuws
</li>
<li>Producten
</li>
<li>ROC
</li>
<li>Contact
</li>
</ul>
</div>
</div>
</body>
</html>
Put the image container and navbar in the same container:
<div class="header">
<div class="container">
<img src="etc/img/logo-wec.png" class="header-heading"></img>
</div>
<div class="nav-bar">
<div class="container">
<ul class="nav">
<li><a class="active" href="index.html">Home</a>
</li>
<li>Nieuws
</li>
<li>Producten
</li>
<li>ROC
</li>
<li>Contact
</li>
</ul>
</div>
</div>
</div>
Give the header position relative and the position the navbar using absolute positioning:
.header {
font-family: 'Handlee', cursive;
color: #fff;
background: #7eabac;
padding: 0.5em 0em;
position: relative;
}
.nav-bar{
position: absolute;
right: 0;
top: 0;
bottom: 0;
margin: auto;
height: 50px;//adjust to center vertically
width: 300px;//adjust to your liking
}
You have to set a height to nav-bar in order to make sure it is centered vertically

linearly curved header at the bottom?

Sorry for repeating this question similar to SO here: Can I create a div with a Curved bottom?
But method there does not fulfill my customization need of header.
But what i want to achieve is not quite similar to what i've achieve with the border border-bottom-left-radius and border-bottom-right-radius.
As you can see the images that header i want to achieve is linearly curved throughout the bottom but with what i've achieved is that i'm having more curvy border at the left and right portion of header and curved is not linear throughout the bottom. It becomes straight after short distance. I've tried to increase the %age but it becomes even more curved at edges.
Is there any other way of doing this so that i get linearly curved throughout the bottom?
Here is my code:
CSS Code:
header{
background-color: #000;
border-bottom-left-radius:25%;
border-bottom-right-radius:25%;
padding: 10px;
opacity: 0.35;
position: fixed;
width: 100%;
z-index: 1000;
}
Here is the link JSfiddle link: https://jsfiddle.net/ozqneuha/
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,600,700);
/* --Global CSS-- */
.header-container {
margin: 0 auto;
width: 1170px;
}
ul {
padding: 0;
margin: 0;
}
/* Header CSS*/
header {
background-color: #000;
border-bottom-left-radius: 25%;
border-bottom-right-radius: 25%;
padding: 10px;
opacity: 0.35;
position: fixed;
width: 100%;
z-index: 1000;
}
header nav ul {
list-style-type: none;
}
header .logo {
display: inline-block;
}
header .header-nav {
display: inline-block;
float: right;
padding: 7px;
}
header li {
float: left;
margin-left: 20px;
}
header li a {
color: #fff;
font: 600 16px'Open Sans';
text-transform: uppercase;
text-decoration: none;
}
header li a:hover,
header li a:active {
color: #e51937;
text-decoration: none;
}
<header>
<div class="header-container">
<div class="logo">
<a href="#">
<img src="http://i.imgur.com/2JbjOqY.png" alt="logo">
</a>
</div>
<div class="header-nav">
<nav>
<ul>
<li>Search
</li>
<li>Map
</li>
<li>Properties
</li>
<li>Parking
</li>
<li>Residents
</li>
<li>Pay Online
</li>
</ul>
</nav>
</div>
<!-- /.header-nav -->
</div>
<!-- /.header-container -->
</header>
You could give clip-path a try, but make sure to check browser support.
Can I use CSS clip-path property
You basically just use an ellipse to clip your header div.
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,600,700);
body {
margin: 0;
}
/* --Global CSS-- */
.header-container{
margin: 0 auto;
width: 1170px;
text-align: right;
}
ul{
padding: 0;
margin:0;
}
/* Header CSS*/
header{
background-color: #000;
/*
border-bottom-left-radius:25%;
border-bottom-right-radius:25%;
*/
padding: 10px;
opacity: 0.35;
position: fixed;
width: 100%;
z-index: 1000;
min-height: 50px;
-webkit-clip-path: ellipse(60% 100% at 50% 0%);
clip-path: ellipse(60% 100% at 50% 0%);
}
header nav ul{
list-style-type: none;
}
header .logo {
display: inline-block;
float: left;
}
header .header-nav{
display: inline-block;
/*float: right;*/
padding: 7px;
}
header li{
float: left;
margin-left: 20px;
}
header li a{
color: #fff;
font: 600 16px 'Open Sans';
text-transform: uppercase;
text-decoration: none;
}
header li a:hover,
header li a:active{
color: #e51937;
text-decoration: none;
}
#media screen and (max-width: 1169px) {
.header-container {
width: 840px;
}
header .header-nav{
display: inline-block;
}
}
#media screen and (max-width: 996px) {
.header-container {
width: 100%;
}
header .logo {
float: none;
display: block;
text-align: center;
}
header .header-nav{
display: none;
}
}
<header>
<div class="header-container">
<div class="logo">
<a href="#">
<img src="http://i.imgur.com/2JbjOqY.png" alt="logo" />
</a>
</div>
<div class="header-nav">
<nav>
<ul>
<li>Search</li>
<li>Map</li>
<li>Properties</li>
<li>Parking</li>
<li>Residents</li>
<li>Pay Online</li>
</ul>
</nav>
</div><!-- /.header-nav -->
</div><!-- /.header-container -->
</header>
Can you try this way?
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,600,700);
/* --Global CSS-- */
.header-container {
margin: 0 auto;
width: 1170px;
}
ul {
padding: 0;
margin: 0;
}
/* Header CSS*/
header {
background-color: #000;
border-bottom-left-radius: 50%;
border-bottom-right-radius: 50%;
padding: 10px 10px 35px;
opacity: 0.35;
position: fixed;
width: 100%;
z-index: 1000;
}
header nav ul {
list-style-type: none;
}
header .logo {
display: inline-block;
}
header .header-nav {
display: inline-block;
float: right;
padding: 7px;
}
header li {
float: left;
margin-left: 20px;
}
header li a {
color: #fff;
font: 600 16px'Open Sans';
text-transform: uppercase;
text-decoration: none;
}
header li a:hover,
header li a:active {
color: #e51937;
text-decoration: none;
}
<header>
<div class="header-container">
<div class="logo">
<a href="#">
<img src="http://i.imgur.com/2JbjOqY.png" alt="logo">
</a>
</div>
<div class="header-nav">
<nav>
<ul>
<li>Search
</li>
<li>Map
</li>
<li>Properties
</li>
<li>Parking
</li>
<li>Residents
</li>
<li>Pay Online
</li>
</ul>
</nav>
</div>
<!-- /.header-nav -->
</div>
<!-- /.header-container -->
</header>
This is how I did it:
.overlay {
position: absolute;
z-index: -1;
height: 100%;
border-radius: 50%;
width: 150%;
left: -25%;
top: -60%;
background: rgba(121, 121, 121, 0.8);
pointer-events:none;
}
Here is the JSFiddle demo
Adjust the width, left and top percentage to your liking :)
I've finally figured out out the solution of this problem. I've used pesudo class :before for the solution.
/* --Global CSS-- */
.header-container {
display: table;
margin: 0 auto;
width: 1170px;
height: 100%;
}
ul {
padding: 0;
margin: 0;
}
/* Header CSS*/
header {
padding: 10px;
position: fixed;
width: 100%;
z-index: 1000;
}
header:before {
background-color: rgba(0, 0, 0, 0.35);
width: 150%;
content: '';
height: 150px;
border-bottom-left-radius: 50%;
border-bottom-right-radius: 50%;
top: -76px;
position: absolute;
z-index: -1;
margin-left: -25%;
}
header ul {
list-style-type: none;
}
header .logo {
display: table-cell;
vertical-align: middle;
}
header .header-nav {
display: table-cell;
float: right;
padding: 7px;
vertical-align: middle;
}
header li {
display: inline-block;
}
header li a {
color: #fff;
font: 600 16px'Open Sans';
padding: 0 15px 0 15px;
text-transform: uppercase;
text-decoration: none;
transition: all 0.3s;
}
header li a:hover,
header li a:active {
color: #e51937;
text-decoration: none;
}
<header>
<div class="header-container">
<div class="logo">
<a href="#">
<img src="http://i.imgur.com/2JbjOqY.png" alt="logo">
</a>
</div>
<div class="header-nav">
<nav>
<ul>
<li>Search
</li>
<li>Map
</li>
<li>Properties
</li>
<li>Parking
</li>
<li>Residents
</li>
<li>Pay Online
</li>
</ul>
</nav>
</div>
<!-- /.header-nav -->
</div>
<!-- /.header-container -->
</header>