I made a dropdown menu and it works perfect in safari, however when I open it up in chrome i can't see the dropdown when I hover over the link. Why is this? I obviously need it to work in both browsers for compatibility reasons.
* {
box-sizing: border-box;
}
h1 {
font-family: 'Arial';
font-size: 6vw;
}
h3 {
font-family: Arial;
font-size: 1.7vw;
text-align: center;
}
p {
font-family: 'Arial';
font-size: 1.7vw;
}
p1 {
font-family: 'Arial';
font-size: 3vw;
}
.header {
background-color: whitesmoke;
padding: 20px;
text-align: center;
}
body {
margin: 0;
background: whitesmoke;
font-family: 'Arial';
font-weight: 300;
font-size: 100%;
}
.main-nav {
display: flex;
}
.main-nav ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
position: sticky;
position: -webkit- sticky;
background-color: #DF744A;
top: 0;
width: 100%;
}
.main-nav li {
float: left;
}
.main-nav li a,
.dropdown {
display: block;
padding: 1.2em 2.2em;
text-decoration: none;
color: black;
text-align: center;
font-family: 'Arial';
font-size: 1.2vw;
}
.main-nav li a:hover {
background-color: #FFAE89;
}
li.products {
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #DF744A;
min-width: 8vw;
z-index: 1;
}
.dropdown-content a {
color: black;
text-decoration: none;
display: block;
text-align: center;
}
.products:hover .dropdown-content {
display: block;
}
.mainbody {
display: flex;
flex-wrap: wrap;
}
.updates {
flex: 20%;
background-color: #FEDCD2;
}
.section-1 {
flex: 80%;
background-color: whitesmoke;
display: flex;
}
.footer {
padding: 20px;
text-align: center;
background: #bfd8d2;
}
#media screen and (max-width: 600px) {
.main-body {
flex-direction: column;
}
}
.bands {
flex: 50%;
padding: 1em;
}
<div class="header">
<h1>Elle and Belle Design</h1>
<p1>Bespoke Handmade Headbands and Accessories</p>
</div>
<nav class="main-nav">
<ul>
<li>Home</li>
<li>About Us</li>
<li class="products">
Products
<div class="dropdown-content">
Headbands
Earrings
Other
</div>
</li>
<li>Contact Us</li>
</ul>
</nav>
<div class="mainbody">
<div class="updates">
<h3>Updates</h3>
</div>
<div class="section-1">
<div class="bands">
<img src="oliviaband.jpg" alt="Olivia Band" width="330" height="400">
<img src="goldband.jpg" alt="Gold Band" width="330" height="400">
</div>
</div>
</div>
<div class="footer">
<h2>Footer</h2>
</div>
Few points:
.main-nav ul had overflow: hidden which was hiding .dropdown-content which overflows the ul.
li.products was missing position: relative this stops your .dropdown-content position: absolute spanning full browser width.
.dropdown-content I added left: 0 and right: 0 so it uses the width of the position: relative (li.products) parent.
I've updated your code in the below snippet.
* {
box-sizing: border-box;
}
h1 {
font-family: 'Arial';
font-size: 6vw;
}
h3 {
font-family: Arial;
font-size: 1.7vw;
text-align: center;
}
p {
font-family: 'Arial';
font-size: 1.7vw;
}
p1 {
font-family: 'Arial';
font-size: 3vw;
}
.header {
background-color: whitesmoke;
padding: 20px;
text-align: center;
}
body {
margin: 0;
background: whitesmoke;
font-family: 'Arial';
font-weight: 300;
font-size: 100%;
}
.main-nav {
display: flex;
}
/* This had overflow: hidden; */
.main-nav ul {
list-style-type: none;
margin: 0;
padding: 0;
position: sticky;
position: -webkit- sticky;
background-color: #DF744A;
top: 0;
width: 100%;
}
.main-nav li {
float: left;
}
.main-nav li a,
.dropdown {
display: block;
padding: 1.2em 2.2em;
text-decoration: none;
color: black;
text-align: center;
font-family: 'Arial';
font-size: 1.2vw;
}
.main-nav li a:hover {
background-color: #FFAE89;
}
/* Requires position: relative;*/
li.products {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
left: 0;
right: 0;
background-color: #DF744A;
min-width: 8vw;
z-index: 5;
}
.dropdown-content a {
color: black;
text-decoration: none;
display: block;
text-align: center;
}
.products:hover .dropdown-content {
display: block;
}
.mainbody {
display: flex;
flex-wrap: wrap;
}
.updates {
flex: 20%;
background-color: #FEDCD2;
}
.section-1 {
flex: 80%;
background-color: whitesmoke;
display: flex;
}
.footer {
padding: 20px;
text-align: center;
background: #bfd8d2;
}
#media screen and (max-width: 600px) {
.main-body {
flex-direction: column;
}
}
.bands {
flex: 50%;
padding: 1em;
}
<div class="header">
<h1>Elle and Belle Design</h1>
<p1>Bespoke Handmade Headbands and Accessories</p>
</div>
<nav class="main-nav">
<ul>
<li>Home</li>
<li>About Us</li>
<li class="products">
Products
<div class="dropdown-content">
Headbands
Earrings
Other
</div>
</li>
<li>Contact Us</li>
</ul>
</nav>
<div class="mainbody">
<div class="updates">
<h3>Updates</h3>
</div>
<div class="section-1">
<div class="bands">
<img src="oliviaband.jpg" alt="Olivia Band" width="330" height="400">
<img src="goldband.jpg" alt="Gold Band" width="330" height="400">
</div>
</div>
</div>
<div class="footer">
<h2>Footer</h2>
</div>
first issue is that the main-nav is hiding any content that flows outside of it's borders change to:
.main-nav ul {
overflow: visible;
}
Second is that the menu item you want to snap to needs to have position relative set, this tells any children with position absolute what it's reference container should be
li.products {
position: relative;
}
Lastly set the dropdowns position co-ordinates
.products:hover .dropdown-content {
top: 100%;
left: 0;
position: absolute;
}
.main-nav {
display: flex;
position: fixed;
top: 0;
background-color: rgba(0, 0, 0, 0.35);
z-index: 0.9;
height: 5vw;
width: 100%;
}
.main-nav ul {
list-style-type: none;
margin: 0 0 0 20vw;
padding: 0;
overflow: visible;
top: 0;
width: 100%;
height: 5vw;
}
.main-nav ul li {
display: inline-block;
text-align: center;
margin-left: 2vw;
height: 5vw;
}
.main-nav li {
float: left;
height: 5vw;
}
.logoimg {
height: 5vw;
width: auto;
float: left;
position: fixed;
margin-left: 1vw;
z-index: 1;
}
.main-nav li a, .dropdown {
display: block;
padding: 1.2em 2.2em;
text-decoration: none;
color: whitesmoke;
text-align: center;
font-family: 'tenderness';
font-size: 1.5vw;
height: 5vw;
border-bottom: 0.3vw solid transparent;
}
.main-nav li a:after {
display: block;
content: '';
border-bottom: 0.3vw solid whitesmoke;
transform: scaleX(0);
transition: transform 0.3s ease-in-out;
min-width: 6vw;
height: 1.15vw;
}
.main-nav li a:hover:after {
height: 1.15vw;
transform: scaleX(1);
}
li.products {
display: inline-block;
position: relative;
height: 5vw;
}
.dropdown-content {
display: none;
position: absolute;
background-color: rgba(0, 0, 0, 0.35);
min-width: 8vw;
z-index: 1;
left: 0;
right: 0;
}
.dropdown-content a {
color: black;
text-decoration: none;
display: block;
text-align: center;
height: 5vw;
}
.products:hover .dropdown-content {
display: block;
}
This is my new code. I have added the bottom border to each li as you can see when the user hovers. However, I am wanting it to align with the bottom of the navigation bar, rather than directly under the text.
I have just put an estimated height in of 1.2vw so it looks just about right, however, it isn't exact and I was just wondering if there was a more precise and not so makeshift way of doing this?
Thanks
Mary
Related
Layout of what I'mm trying to achieve
I've done the top half of the nav bar and I'm trying to do the second part where the boxes (represent words), which I have circled in the image. I'm trying to directly make that section below the logo sign centered like the image shows but I am unsure on how to do that.
body {
margin: 0;
font-weight: 800;
}
.container {
width: 80%;
height: 100%;
margin: 0 auto;
display: flex;
/* align-items: center; */
justify-content: center;
}
header {
background: #ffe9e3;
height: 100px;
}
.logo {
text-align: center;
margin: 0;
display: block;
}
.business {
position: absolute;
right: 0;
top: 0;
padding: 10px;
}
.menu {}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
}
nav a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 14px;
}
nav a:hover {
color: #000;
}
nav a::before {
content: '';
display: block;
height: 5px;
background-color: #444;
position: absolute;
top: 0;
width: 0%;
transition: all ease-in-out 250ms;
}
nav a:hover::before {
width: 100%;
}
<header>
<div class="container">
<h1 class="logo"><i>LOGO</i></h1>
<nav class=m enu>
<ul>
<li>Hair</li>
<li>Nails</li>
<li>Makeup</li>
<li>Face</li>
</ul>
</nav>
<nav class=b usiness>
<ul>
<li>List Your Business</li>
</ul>
</nav>
<<div class="menu">
<nav>
</nav>
</div>
</div>
</header>
I have done the way you wanted it to look
CSS Part :
* {
padding: 0;
margin: 0;
}
body {
background: #333333;
min-width: 100vw;
min-height: 100vh;
}
.header {
height: 150px;
background: pink;
}
.logo {
padding: 10px;
text-align: center;
}
.nav > ul {
display: flex;
justify-content: space-evenly;
padding: 10px;
margin-top: 20px;
}
.nav > ul > li {
width: 100px;
list-style: none;
border: 2px solid #000;
border-radius: 20px;
}
.nav > ul > li > a {
text-decoration: none;
color: #fff;
font-size: 1.3rem;
padding: 3px 5px;
display: flex;
justify-content: center;
}
check the whole code here: https://codepen.io/the-wrong-guy/pen/GRoyKMa?editors=1100
And you have made a lot of syntax errors like not giving double quotes to the class names
right now the purple just covers the text but it should be a nice block of colour like the dropdown is. Also, I have a bar under my nav img that should not be there when I hover. I know it is a width/height thing, but no matter where I put the code it does not work.
https://codepen.io/Smoki248/pen/NWxrOWK
li {
list-style: none;
}
a {
color: #f2f2f2;
text-decoration: none;
}
a:hover {
background-color: #8781bd;
}
.container {
max-width: 100%;
width: 100%;
margin: 0 auto;
text-align: center;
}
.btn {
padding: 0 20px;
height: 40px;
font-size: 1em;
font-weight: 400;
font-family: "Amatic SC", Roboto, sans-serif;
border: 1px #8781bd solid;
border-radius: 2px;
background: #8781bd;
color: #f2f2f2;
cursor: pointer;
}
.grid {
display: flex;
}
header {
position: fixed;
top: 0;
min-height: 75px;
padding: 0px 0px;
display: flex;
align-items: center;
background-color: #2f2f2f;
}
#media (max-width: 600px) {
header {
flex-wrap: wrap;
}
}
.logo {
width: 60vw;
}
#media (max-width:650px) {
.logo {
margin-top: 15px;
width: 100%;
position: relative;
}
}
.logo > img {
width: 100%;
height: 100%;
max-width: 100px;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
margin-left: 20px;
}
#media (max-width: 650px) {
.logo > img {
margin: 0 auto;
}
}
nav {
font-weight: 400;
}
#media (max-width: 650px) {
nav {
margin-top: 10px;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
padding: 0 50px;
}
}
h1 {
font-family: "Amatic SC", Raleway, Roboto, sans-serif;
font-size: 35pt;
width: 100%;
text-align: center;
}
h2 {
font-family: "Amatic SC", Raleway, Roboto, sans-serif;
font-size: 24pt;
width: 100%;
text-align: center;
}
nav li {
padding-bottom: 30px 0px;
}
nav > ul {
width: 30vw;
display: flex;
flex-direction: row;
justify-content: space-around;
}
#media (max-width: 650px) {
nav > ul {
flex-direction: column;
}
}
.dropdown > li{
float: right;
overflow: hidden;
}
.dropdown > li a {
font-size: 16px;
border: none;
outline: none;
color: #f4f4f4;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
nav > li a:hover, .dropdown:hover a {
background-color: #8781bd;
color:#f4f4f4;
}
.dropdown-content {
display: none;
position: absolute;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
color: #f4f4f4;
z-index: 1;
margin-top: 20px;
min-width: 100px;
}
.dropdown-content li a {
float: none;
color: #f4f4f4;
padding: 10px 14px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content li a:hover {
background-color: #625aa9;
color: #f4f4f4;
}
.dropdown:hover .dropdown-content {
display: block;
}
<header id="page-wrapper">
<header id="header">
<div class="logo">
<nav>
<a href="http://www.wrecklessdevelopment.com"><img id="header-img"
src="images/wreckless-development-logo.gif" alt="Wreckless Development Logo"/></a>
</nav>
</div>
<h1>Wreckless Development</h1>
<nav id="navbar">
<ul>
<li>About</li>
<li>Services</li>
<div class="dropdown">
<li><i class="fa fa-caret-down"></i> Portfolio<li>
<div class="dropdown-content">
<ul>
<li>Photography</li>
<li>Composite</li>
<li>Logos</li>
<li>Branding</li>
<li>Advertising</li>
</ul>
</div>
</div>
<li>Contact</li>
<li>Blog</li>
</ul>
</nav>
</header>
</header>
The problem is tag a's default display is inline, so if you want to adjust height of a tag, you have to change it's default display to display: inline-block like this, and then you may be able to do whatever you want with that a tag, you can refer my code below for more details:
#header a {
display: inline-block; // change display style
height: 75px;
line-height: 75px; // center the text
padding-left: 12px;
padding-right: 12px;
}
.dropdown > li > a {
padding: 0 16px; // no need to padding top and bottom because we already had line-height and height
}
.dropdown-content{
margin-top: 75px; // push the .dropdown-content further to fit new css
}
#header .dropdown-content li a{
display: block; // set an <a> tag to full with of the dropdown
height: auto;
line-height: 16px; // center the text with current font-size
}
you can take a look in my codepen.io for more details here. Hope it will help
I was not able to align in same horizontal line both the content. I was using flex. How to align both the navigation menu and another flex content?
const navButton = document.querySelector('button[aria-expanded]');
function toggleNav({
target
}) {
const expanded = target.getAttribute('aria-expanded') === 'true' || false;
navButton.setAttribute('aria-expanded', !expanded);
}
navButton.addEventListener('click', toggleNav);
* {
box-sizing: border-box;
margin: 0;
padding: 0;
overflow: hidden;
font-family: 'Roboto', sans-serif;
}
.wrap {
width: 100%;
margin: 0 auto;
}
[aria-controls="menu-list"] {
display: none;
}
.menu ul {
list-style: none;
display: flex;
justify-content: space-between;
width: 90%;
margin: 20px auto;
}
.menu ul li {
flex-grow: 1;
flex-basis: 1px;
padding: 10px;
}
.menu ul li a {
display: block;
text-align: center;
text-decoration: none;
font-size: 20px;
font-weight: 700;
background: #ffc600;
padding: 10px;
color: black;
}
.main {
width: 100%;
}
.cat1 {
margin-right: 20px;
flex: 6;
background: url(https://jolly-kalam-23776e.netlify.com/restaurantwebsite/images/taco.jpg);
height: 400px;
z-index: -1;
}
.c1title {
z-index: 1;
color: black;
background: #ffc600;
position: absolute;
top: 130px;
left: 130px;
font-size: 30px;
padding: 5px;
font-weight: 600;
}
.c1para {
z-index: 1;
color: black;
background: #ffc600;
position: absolute;
top: 250px;
left: 130px;
font-size: 16px;
padding: 5px;
font-weight: 600;
}
.cat {
flex: 2;
display: flex;
flex-direction: column;
margin-right: 20px;
}
.cat2 {
flex: 1;
background: #ffc600;
margin-bottom: 25px;
display: flex;
}
.c2title {
font-size: 30px;
font-weight: 600;
text-align: center;
margin: auto;
}
.small {
display: block;
font-size: 16px;
font-weight: 600;
}
.cat3 {
flex: 1;
background: #ffc600;
display: flex;
}
.c3title {
font-size: 30px;
font-weight: 600;
text-align: center;
margin: auto;
}
#media (min-width: 900px) {
.hero {
width: 90%;
display: flex;
margin: 0 auto;
}
}
#media (max-width: 1000px) {
.menu {
perspective: 800px;
}
[aria-controls="menu-list"] {
display: block;
margin-bottom: 10px;
}
.menu ul {
max-height: 0;
overflow: hidden;
transform: rotateX(90deg);
transition: all 0.5s;
}
[aria-expanded="true"]~ul {
display: grid;
max-height: 500px;
transform: rotateX(0);
}
[aria-expanded="false"] .close {
display: none;
}
[aria-expanded="true"] .close {
display: inline-block;
}
[aria-expanded="true"] .open {
display: none;
}
}
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
<div class="wrap">
<nav class="menu">
<button aria-expanded="false" aria-controls="menu-list">
<span class="open">☰</span>
<span class="close">×</span>
Menu
</button>
<ul id="menu-list">
<li>Tacos</li>
<li>Beers</li>
<li>Wines</li>
<li>Deserts</li>
<li>Reservations</li>
</ul>
</nav>
</div>
<div class="main">
<div class="hero">
<div class="cat1">
<h6 class="c1title">Terry's Taco Joint</h6>
<p class="c1para">Pretty Good Tacos!</p>
</div>
<div class="cat">
<div class="cat2">
<p class="c2title">1.99$<br><span class="small">
Tacos</span></p>
</div>
<div class="cat3">
<p class="c3title">3.99$
<br><span class="small">Kombucha</span></p>
</div>
</div>
</div>
</div>
Image what was trying to align:
You are setting display: grid to [aria-expanded="true"] ~ ul. Remove it and it will work fine.
*{
box-sizing: border-box;
margin: 0;
padding: 0;
overflow: hidden;
font-family: 'Roboto', sans-serif;
}
.wrap{
width: 100%;
margin: 0 auto;
}
[aria-controls="menu-list"] {
display: none;
}
.menu ul{
list-style: none;
display: flex;
flex-flow: column no-wrap;
justify-content: space-between;
width: 90%;
margin: 20px auto;
}
.menu ul li{
flex-grow: 1;
flex-basis: 1px;
padding: 10px;
}
.menu ul li a{
display: block;
text-align: center;
text-decoration: none;
font-size: 20px;
font-weight: 700;
background: #ffc600;
padding: 10px;
color: black;
}
.main{
width: 100%;
}
.cat1{
margin-right: 20px;
flex: 6;
background: url(https://jolly-kalam-23776e.netlify.com/restaurantwebsite/images/taco.jpg);
height: 400px;
z-index: -1;
}
.c1title{
z-index: 1;
color:black;
background: #ffc600;
position: absolute;
top: 130px;
left: 130px;
font-size: 30px;
padding: 5px;
font-weight: 600;
}
.c1para{
z-index: 1;
color:black;
background: #ffc600;
position: absolute;
top: 250px;
left: 130px;
font-size: 16px;
padding: 5px;
font-weight: 600;
}
.cat{
flex: 2;
display: flex;
flex-direction: column;
margin-right: 20px;
}
.cat2{
flex: 1;
background: #ffc600;
margin-bottom: 25px;
display: flex;
}
.c2title{
font-size: 30px;
font-weight: 600;
text-align: center;
margin: auto;
}
.small{
display: block;
font-size: 16px;
font-weight: 600;
}
.cat3{
flex:1;
background: #ffc600;
display: flex;
}
.c3title{
font-size: 30px;
font-weight: 600;
text-align: center;
margin: auto;
}
#media (min-width: 900px){
.hero{
width: 90%;
display: flex;
margin: 0 auto;
}
}
#media (max-width: 1000px) {
.menu {
perspective: 800px;
}
[aria-controls="menu-list"] {
display: block;
margin-bottom: 10px;
}
.menu ul {
max-height: 0;
overflow: hidden;
transform: rotateX(90deg);
transition: all 0.5s;
}
[aria-expanded="true"] ~ ul {
max-height: 500px;
transform: rotateX(0);
}
[aria-expanded="false"] .close {
display: none;
}
[aria-expanded="true"] .close {
display: inline-block;
}
[aria-expanded="true"] .open {
display: none;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
<title>Restaurant Wesbite</title>
</head>
<body>
<div class="wrap">
<nav class="menu">
<button aria-expanded="false" aria-controls="menu-list">
<span class="open">☰</span>
<span class="close">×</span>
Menu
</button>
<ul id="menu-list">
<li>Tacos</li>
<li>Beers</li>
<li>Wines</li>
<li>Deserts</li>
<li>Reservations</li>
</ul>
</nav>
</div>
<div class="main">
<div class="hero">
<div class="cat1">
<h6 class="c1title">Terry's Taco Joint</h6>
<p class="c1para">Pretty Good Tacos!</p>
</div>
<div class="cat">
<div class="cat2">
<p class="c2title">1.99$<br><span class="small">
Tacos</span></p>
</div>
<div class="cat3">
<p class="c3title">3.99$
<br><span class="small">Kombucha</span></p>
</div>
</div>
</div>
</div>
<script>
const navButton = document.querySelector('button[aria-expanded]');
function toggleNav({ target }) {
const expanded = target.getAttribute('aria-expanded') === 'true' || false;
navButton.setAttribute('aria-expanded', !expanded);
}
navButton.addEventListener('click', toggleNav);
</script>
</body>
</html>
I have added this tiny code snippet to achieve what your desired image conveyed. Basically CSS flexbox works in direct parent-children relationship and flex assigned to parent only works for direct children and not children of children elements.
.menu #menu-list{display: flex;}
const navButton = document.querySelector('button[aria-expanded]');
function toggleNav({
target
}) {
const expanded = target.getAttribute('aria-expanded') === 'true' || false;
navButton.setAttribute('aria-expanded', !expanded);
}
navButton.addEventListener('click', toggleNav);
* {
box-sizing: border-box;
margin: 0;
padding: 0;
overflow: hidden;
font-family: 'Roboto', sans-serif;
}
.wrap {
width: 100%;
margin: 0 auto;
}
[aria-controls="menu-list"] {
display: none;
}
.menu ul {
list-style: none;
display: flex;
justify-content: space-between;
width: 90%;
margin: 20px auto;
}
.menu ul li {
flex-grow: 1;
flex-basis: 1px;
padding: 10px;
}
.menu ul li a {
display: block;
text-align: center;
text-decoration: none;
font-size: 20px;
font-weight: 700;
background: #ffc600;
padding: 10px;
color: black;
}
.menu #menu-list{
display: flex;}
.main {
width: 100%;
}
.cat1 {
margin-right: 20px;
flex: 6;
background: url(https://jolly-kalam-23776e.netlify.com/restaurantwebsite/images/taco.jpg);
height: 400px;
z-index: -1;
}
.c1title {
z-index: 1;
color: black;
background: #ffc600;
position: absolute;
top: 130px;
left: 130px;
font-size: 30px;
padding: 5px;
font-weight: 600;
}
.c1para {
z-index: 1;
color: black;
background: #ffc600;
position: absolute;
top: 250px;
left: 130px;
font-size: 16px;
padding: 5px;
font-weight: 600;
}
.cat {
flex: 2;
display: flex;
flex-direction: column;
margin-right: 20px;
}
.cat2 {
flex: 1;
background: #ffc600;
margin-bottom: 25px;
display: flex;
}
.c2title {
font-size: 30px;
font-weight: 600;
text-align: center;
margin: auto;
}
.small {
display: block;
font-size: 16px;
font-weight: 600;
}
.cat3 {
flex: 1;
background: #ffc600;
display: flex;
}
.c3title {
font-size: 30px;
font-weight: 600;
text-align: center;
margin: auto;
}
#media (min-width: 900px) {
.hero {
width: 90%;
display: flex;
margin: 0 auto;
}
}
#media (max-width: 1000px) {
.menu {
perspective: 800px;
}
[aria-controls="menu-list"] {
display: block;
margin-bottom: 10px;
}
.menu ul {
max-height: 0;
overflow: hidden;
transform: rotateX(90deg);
transition: all 0.5s;
}
[aria-expanded="true"]~ul {
display: grid;
max-height: 500px;
transform: rotateX(0);
}
[aria-expanded="false"] .close {
display: none;
}
[aria-expanded="true"] .close {
display: inline-block;
}
[aria-expanded="true"] .open {
display: none;
}
}
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
<div class="wrap">
<nav class="menu">
<button aria-expanded="false" aria-controls="menu-list">
<span class="open">☰</span>
<span class="close">×</span>
Menu
</button>
<ul id="menu-list">
<li>Tacos</li>
<li>Beers</li>
<li>Wines</li>
<li>Deserts</li>
<li>Reservations</li>
</ul>
</nav>
</div>
<div class="main">
<div class="hero">
<div class="cat1">
<h6 class="c1title">Terry's Taco Joint</h6>
<p class="c1para">Pretty Good Tacos!</p>
</div>
<div class="cat">
<div class="cat2">
<p class="c2title">1.99$<br><span class="small">
Tacos</span></p>
</div>
<div class="cat3">
<p class="c3title">3.99$
<br><span class="small">Kombucha</span></p>
</div>
</div>
</div>
</div>
I have a navigation bar which is OK, but just underneath that there is a 1px line that I cannot get rid of, it should be flush with the address underneath. This is the code that I have can anyone suggest anything?
There is also some of the html which was so hard formatting on here anyhow they want me to add more text. So it is the address underneath the naviation
address.space {
width: 100%;
background: #FF9900;
font-family: 'Monserrat', sans-serif;
text-align: center;
display: inline-block;
font-size: 1em;
margin-bottom: 20px;
}
/*menu*/
.nav {
background-color: #3333FF;
width: 100%;
height: 40px;
line-height: 40px;
}
.menu {
font-family: Monserrat, sans-serif;
font-size: 20px;
color: white;
list-style-type: none;
padding: 0;
position: relative;
z-index: 1;
}
.menu a {
text-decoration: none;
color: #fff;
line-height: 40px;
height: 40px;
display: block;
}
.menu ul li {
text-align: center;
display: inline-block;
padding: 0 20px 0 20px;
width: 13.5%;
height: 40px;
}
.menu li:visited,
.menu li:active,
.active,
.menu li:hover {
background: #0000EE;
color: #fff;
}
label {
margin: 0 14px 0 0;
font-size: 20px;
display: none;
}
#toggle {
display: none;
}
#media only screen and (max-width: 500px) {
html,
body,
#main,
#firstside,
.firstsidewider,
#second,
.wide {
width: 100%;
font-size: 1em;
}
h1 span {
display: none;
}
label {
cursor: pointer;
display: block;
color: #fff;
}
.menu {
text-align: center;
width: 100%;
display: none;
}
.menu li a {
border-bottom: 1px solid #F4F4F4;
display: block;
background: #3333FF;
margin: -20px;
padding: 0;
}
.active,
.menu li:hover {
color: #fff;
background: 0;
}
#toggle:checked+.menu {
display: block;
}
<header id="banner">
<div class="nav">
<label for="toggle">☰</label><input id="toggle" type="checkbox">
<div class="menu">
<ul>
<li>Home</li>
<li>News</li>
<li>Contacts
</li>
<li>Members
</li>
<li>Policies
</li>
<li>Links</li>
<li class="active">
Volunteer/li>
</ul>
</div>
</div>
<address class="space">
Meeting Address: YMCA -The Lecture Room 29 Rush Green
Road
4.00pm - 6.00pm</address>
<section id="leftheader">
<h1>Hubb <span>support group</span></h1>
I'm trying to create a small website and want to place an image (logo, square, svg) in the navbar. I want the logo to fit the navbar but it simply just won't scale no matter what I try.
I've tried floating a div with the image to the left and the navbar to the right but it still won't scale. It's really frustrating.
Here's an image of the problem:
Here's my code (sorry it's messy):
#import url('https://fonts.googleapis.com/css?family=Montserrat');
.heading {
display: inline-block;
font-family: "Montserrat";
font-weight: lighter;
text-align: left;
margin-left: 20vw;
line-height: 30vw;
}
body {
width: 100%;
margin: auto;
font-family: 'Montserrat', sans-serif;
background-color: white;
}
.container {
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: center;
margin-top: 30px;
flex-flow: row wrap;
margin-top: -10vw;
}
img {
margin: 9px;
transition: filter 0.2s;
filter: brightness(100%);
display: inline-block;
min-height: 100px;
height: 50vh;
}
img:hover {
filter: brightness(80%);
}
.responsive:hover {}
header {
position: relative;
height: 50vh;
background-image: linear-gradient(rgb(50, 50, 50), rgb(30, 30, 30));
margin-top: -20px;
transform: skewY(-5deg);
transform-origin: top left;
}
.fullwidth {
width: 100%;
}
.headertitle {
margin-top: -36vh;
margin-left: 12vw;
position: absolute;
font-size: calc(13px + 2.5vw);
color: white;
font-family: 'Montserrat';
font-weight: lighter;
}
/* navbar */
nav {
background: rgb(52, 52, 52);
position: relative;
z-index: 1;
height: calc(18px + 6vh);
box-shadow: 0 3px 3px -1px rgba(0, 0, 0, 0.065);
overflow: auto;
width: 100vw;
}
nav ul {
margin: 0;
padding: 0;
text-align: left;
margin-left: 1.2vw;
}
nav ul li {
display: inline-block;
list-style: none;
font-size: 1.2em;
padding: 1vh;
}
.navul a {
text-decoration: none;
color: white;
line-height: 5.5vh;
height: 5.5vh;
font-size: calc(15px + 0.25vh + 0.15vw);
}
.navuul a:visited,
a:link,
a:active {
text-decoration: none;
color: white;
font-weight: 200;
line-height: 5.5vh;
height: 5.5vh;
}
.navuul a:hover {
text-decoration: none;
color: grey;
font-weight: 200;
line-height: 5.5vh;
height: 5.5vh;
}
.submit {
float: right;
margin-right: 1.5vw;
}
.submit a {
color: white;
border-radius: 5px;
}
.navimg img {
max-width: 100%;
max-height: 20%;
}
.navimgdiv {
height: 1.5vh;
}
/* navbar end */
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="pgallerystyles.css">
<title> Photo Gallery </title>
<link rel="shortcut icon" href="logo.ico">
</head>
<body>
<div class="fullwidth">
</div>
<nav>
<ul class="navul">
<li>
<div class="navimgdiv"><img class="navimg" src="logo.svg"></div>Lumastock</li>
<li>Photos</li>
<li>Featured</li>
<li>Contact</li>
<li>Pricing</li>
<li>Assesment Requirements</li>
<li class="submit">Submit a photo</li>
</ul>
</nav>
<header>
</header>
<h1 class="headertitle">Image Gallery</h1>
Thanks!
Simply use the logo outside of the list. I have added max-width for logo image. Optionally padding and margin you can customize based on your requirement. I hope this solution will be helpful.
.heading {
display: inline-block;
font-family: "Montserrat";
font-weight: lighter;
text-align: left;
margin-left: 20vw;
line-height: 30vw;
}
body {
width: 100%;
margin: auto;
font-family: 'Montserrat', sans-serif;
background-color: white;
}
.container {
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: center;
margin-top: 30px;
flex-flow: row wrap;
margin-top: -10vw;
}
img {
/* margin: 9px;
transition: filter 0.2s;
filter: brightness(100%);
display: inline-block;
min-height: 100px;
height: 50vh; */
max-width: 100%;
}
img:hover {
filter: brightness(80%);
}
.responsive:hover {}
header {
position: relative;
height: 50vh;
background-image: linear-gradient(rgb(50, 50, 50), rgb(30, 30, 30));
margin-top: -20px;
transform: skewY(-5deg);
transform-origin: top left;
}
.fullwidth {
width: 100%;
}
.headertitle {
margin-top: -36vh;
margin-left: 12vw;
position: absolute;
font-size: calc(13px + 2.5vw);
color: white;
font-family: 'Montserrat';
font-weight: lighter;
}
/* navbar */
nav {
background: rgb(52, 52, 52);
position: relative;
z-index: 1;
height: calc(40px + 6vh);
box-shadow: 0 3px 3px -1px rgba(0, 0, 0, 0.065);
overflow: auto;
width: 100vw;
display: flex;
}
nav ul {
margin: 0;
padding: 0;
text-align: left;
margin-left: 1.2vw;
}
nav ul li {
display: inline-block;
list-style: none;
font-size: 1.2em;
padding: 1vh;
}
.navul a {
text-decoration: none;
color: white;
line-height: 5.5vh;
height: 5.5vh;
font-size: calc(15px + 0.25vh + 0.15vw);
}
.navuul a:visited,
a:link,
a:active {
text-decoration: none;
color: white;
font-weight: 200;
line-height: 5.5vh;
height: 5.5vh;
}
.navuul a:hover {
text-decoration: none;
color: grey;
font-weight: 200;
line-height: 5.5vh;
height: 5.5vh;
}
.submit {
float: right;
margin-right: 1.5vw;
}
.submit a {
color: white;
border-radius: 5px;
}
.navimgdiv img {
max-width: 50px;
}
.navimgdiv {
padding: 5px 0;
}
<div class="fullwidth"></div>
<nav>
<a class="navimgdiv"><img src="https://cdn.worldvectorlogo.com/logos/react.svg"></a>
<ul class="navul">
<li>Lumastock</li>
<li>Photos</li>
<li>Featured</li>
<li>Contact</li>
<li>Pricing</li>
<li>Assesment Requirements</li>
<li class="submit">Submit a photo</li>
</ul>
</nav>
<header></header>
<h1 class="headertitle">Image Gallery</h1>