I am fairly new to HTMl and CSS. I had my footer stuck to the bottom of the page no problem and then something changed and I cannot figure it out. When I go to a page without a lot of content the footer sits in the middle of the page. On pages with content, it works as it should. I have read countless other posts with the same issue and nothing seems to work. Using "position:fixed" makes the footer stuck to the bottom of the "viewport" not the page itself. Thus when I switch to another page with scrollable content, the footer shows itself behind the page content. I've tried adding "overflow:hidden", "bottom:0;", "left:0" and "right:0" to .main-footer and that doesn't fix it. I don't know what I'm missing. I have already spent a few hours looking up answers and trying to solve this issue.
*, *::before, *::after {
box-sizing: border-box;
font-family: 'Abel', sans-serif;
color: #777;
}
body {
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
height: 100vh;
}
/* Styles for navigation menus */
nav ul {
margin: 0;
}
nav li{
display: inline-block;
}
nav a {
display: inline-flex;
padding: .5em;
margin-top: 5px;
margin-bottom: 5px;
color: white;
text-decoration: none;
transition: 350ms;
}
nav a:hover {
background-color: rgba(215, 200, 200, .3);
border-radius: 2px;
}
/*Style for MAIN navigation menu*/
.main-nav {
text-align: center;
font-size: 1.1em;
font-weight: lighter;
border-bottom: 1px solid rgba(215, 200, 200, .3);
}
.main-nav li {
padding: 0 5%;
}
.main-header {
background-image: url('headerfooterimages/headerpicture.jpg');
background-size: cover;
background-color: rgba(0, 0, 0, 0.5);
background-blend-mode: multiply;
padding-bottom: 25px;
border-bottom: 1px solid black;
}
/* Style for Page Title/Logo */
.titleLogo {
text-align: center;
margin: auto;
font-size: 4em;
font-family: 'Bebas Neue';
color: white;
}
.titleLogo-large {
font-size: 6em;
}
/*Styles for sections of content on page*/
.content-section {
margin: 1em;
padding: 2em;
}
.content-container {
max-width: 900px;
margin: 0 auto;
padding: 0 1.5em;
}
.section-header {
font-family: Impact;
font-weight: normal;
color: rgb(34, 34, 34);
}
/*Styling the footer for each page*/
.main-footer {
background-color: rgb(45, 45, 45);
padding: 5px;
position: relative;
bottom: 0;
width: 100vw;
height: 75px;
border-top: 1px solid black;
margin: auto;
}
.footer-text {
font-size: 25px;
color: rgba(128, 128, 128);
display: inline-flex;
}
.footer-text:hover {
text-shadow: 0px 0px 40px rgba(255, 255, 255, 0.75);
cursor: crosshair;
color:rgb(188, 188, 188);
}
.main-footer-container {
display: flex;
align-items: center;
}
.main-footer-container ul {
flex-grow: 1;
text-align: end;
}
/*Styling the social media links in the footer*/
.footer-nav li {
list-style: none;
display: inline-flex;
transition: 350ms;
}
.footer-nav img {
border-radius: 5px;
width: 30px;
height: 30px;
}
.footer-nav li:hover {
background-color: rgba(215, 200, 200, .3);
border-radius: 5px;
padding-left: 3px;
padding-right: 3px;
padding-top: 3px;
}
/*Styling buttons across the whole site*/
.btn {
background-color: #349aff;
border: none;
border-radius: 1em;
color: white;
padding: 8px 16px;
vertical-align: middle;
text-align: center;
text-decoration: none;
font-size: 8px;
font-weight: bold;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
}
.btn:hover {
background-color: #2090ff;
cursor: pointer;
box-shadow: none;
}
/*Styling the cart menu option in the main navigation*/
.cart-container{
display: inline-flex;
margin: auto;
}
.cart-icon {
float: left;
clear: left;
height: 25px;
}
.cart-text {
display:inline-block;
color: white;
padding: 2px;
margin-top: 1px;
}
.cart-text:hover {
text-decoration: underline;
}
/*Styling shop items*/
.shop-item {
display: block;
margin: 50px;
}
.shop-item-image {
display: block;
margin: 10px;
height: 200px;
}
.shop-item-title {
display: block;
text-align: center;
width: 100%;
font-weight: bold;
font-size: 1.1em;
color: #333;
margin-bottom: 5px;
}
.shop-item-details {
display: flex;
align-items: center;
}
.shop-item-price {
display: block;
text-align: center;
color: #333;
width: 50%;
}
.shop-item-button {
display: block;
}
.shop-items {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
/*Styling the image carousel*/
.carousel {
width: 600px;
height: 400px;
position: relative;
display: flex;
}
.carousel > ul {
margin: 0px;
padding: 0px;
list-style: none;
}
.carousel-container {
margin: auto;
align-items: center;
}
/*Styling the buttons on the carousel*/
.carousel-button {
position: absolute;
padding: 0 .25rem;
z-index: 2;
background: none;
background-color: rgba(0, 0, 0, .1);
border: none;
border-radius: .25rem;
font-size: 2.5rem;
top: 50%;
transform: translateY(-120%);
color: rgba(255, 255, 255, .5);
cursor: pointer;
}
.carousel-button:hover, .carousel-button:focus {
color: white;
background-color: rgba(0, 0, 0, .2);
}
.carousel-button:focus {
outline: 1px solid black;
}
.carousel-button.prev {
left: 1rem;
}
.carousel-button.next {
right: 12rem;
}
/*Styling and formatting the next image effect for the image carousel*/
.slide {
position: absolute;
inset: 0;
opacity: 0;
object-fit: fill;
transition: 400ms opacity ease-in-out;
transition-delay: 200ms;
}
.slide > img {
display: inline-block;
width: 70%;
height: 80%;
border-radius: 10px;
object-fit: cover;
box-shadow: 0px 0px 30px rgba(0, 0, 0, 0.5);
}
.slide[data-active] {
opacity: 1;
z-index: 1;
transition-delay: 0ms;
}
<!DOCTYPE html>
<html lang = "enUS">
<head>
<title>Modern Style</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Abel&family=Bebas+Neue" rel="stylesheet">
<link rel="favicon" href="favicon.ico">
<link rel="stylesheet" href="stylesheet.css">
<script src="script.js" defer></script>
</head>
<body>
<header class="main-header">
<nav class="nav main-nav">
<ul>
<li>HOME</li>
<li>ABOUT</li>
<li>STORE</li>
<li class="cart-container"><a href="cart.html"><img class="cart-icon" src="headerfooterimages/cart.png" alt="A shopping cart icon">
<div class="cart-text">Shopping Cart</div></a></li>
</ul>
</nav>
<h1 class="titleLogo titleLogo-large">Modern Style Website</h1>
</header>
<section class="content-section content-container">
<h2 class="section-header">ABOUT</h2>
<p>
This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text.
This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text.
This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text.
This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text.
This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text.
This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text. This is placeholder text.
</p>
</section>
</body>
<footer class="main-footer">
<div class="main-footer-container">
<h2 class="footer-text">Modern Style Website</h2>
<ul class="nav footer-nav">
<li><img src="headerfooterimages/Facebook-Logo.png"></li>
<li><img src="headerfooterimages/Instagram-Logo.png"></li>
<li><img src="headerfooterimages/Twitter-Logo.png"></li>
</ul>
</div>
</footer>
</html>
Seeing as you have declared the body to be 100vh, you can utilize this empty space with margin-top: auto.
On main-footer, remove margin: auto and replace it with margin-top: auto. This way, it will convert the remaining space on the body element into a margin-top-value for the main-footer element.
On another note,
make sure to include the <footer>-element BEFORE your closing </body>-tag, the footer is supposed to be inside the <body>-element.
Also, in your CSS reset, I would consider adding margin: 0; to avoid white bars on your site.
Codepen (because the code snippet is so long): https://codepen.io/sigurdmazanti/pen/ZErJzEK
.main-footer {
background-color: rgb(45, 45, 45);
padding: 5px;
position: relative;
bottom: 0;
width: 100vw;
height: 75px;
border-top: 1px solid black;
/*margin: auto;*/
margin-top: auto;
}
just use this css code:
i have added multiple values to body and remove margin from footer
*, *::before, *::after {
box-sizing: border-box;
font-family: 'Abel', sans-serif;
color: #777;
}
body {
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
min-height: 100vh;
flex-wrap: nowrap;
align-content: space-between;
justify-content: space-between;
align-items: stretch;
}
/* Styles for navigation menus */
nav ul {
margin: 0;
}
nav li{
display: inline-block;
}
nav a {
display: inline-flex;
padding: .5em;
margin-top: 5px;
margin-bottom: 5px;
color: white;
text-decoration: none;
transition: 350ms;
}
nav a:hover {
background-color: rgba(215, 200, 200, .3);
border-radius: 2px;
}
/*Style for MAIN navigation menu*/
.main-nav {
text-align: center;
font-size: 1.1em;
font-weight: lighter;
border-bottom: 1px solid rgba(215, 200, 200, .3);
}
.main-nav li {
padding: 0 5%;
}
.main-header {
background-image: url('headerfooterimages/headerpicture.jpg');
background-size: cover;
background-color: rgba(0, 0, 0, 0.5);
background-blend-mode: multiply;
padding-bottom: 25px;
border-bottom: 1px solid black;
}
/* Style for Page Title/Logo */
.titleLogo {
text-align: center;
margin: auto;
font-size: 4em;
font-family: 'Bebas Neue';
color: white;
}
.titleLogo-large {
font-size: 6em;
}
/*Styles for sections of content on page*/
.content-section {
margin: 1em;
padding: 2em;
}
.content-container {
max-width: 900px;
margin: 0 auto;
padding: 0 1.5em;
}
.section-header {
font-family: Impact;
font-weight: normal;
color: rgb(34, 34, 34);
}
/*Styling the footer for each page*/
.main-footer {
background-color: rgb(45, 45, 45);
padding: 5px;
position: relative;
bottom: 0;
width: 100vw;
height: 75px;
border-top: 1px solid black;
}
.footer-text {
font-size: 25px;
color: rgba(128, 128, 128);
display: inline-flex;
}
.footer-text:hover {
text-shadow: 0px 0px 40px rgba(255, 255, 255, 0.75);
cursor: crosshair;
color:rgb(188, 188, 188);
}
.main-footer-container {
display: flex;
align-items: center;
}
.main-footer-container ul {
flex-grow: 1;
text-align: end;
}
/*Styling the social media links in the footer*/
.footer-nav li {
list-style: none;
display: inline-flex;
transition: 350ms;
}
.footer-nav img {
border-radius: 5px;
width: 30px;
height: 30px;
}
.footer-nav li:hover {
background-color: rgba(215, 200, 200, .3);
border-radius: 5px;
padding-left: 3px;
padding-right: 3px;
padding-top: 3px;
}
/*Styling buttons across the whole site*/
.btn {
background-color: #349aff;
border: none;
border-radius: 1em;
color: white;
padding: 8px 16px;
vertical-align: middle;
text-align: center;
text-decoration: none;
font-size: 8px;
font-weight: bold;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
}
.btn:hover {
background-color: #2090ff;
cursor: pointer;
box-shadow: none;
}
/*Styling the cart menu option in the main navigation*/
.cart-container{
display: inline-flex;
margin: auto;
}
.cart-icon {
float: left;
clear: left;
height: 25px;
}
.cart-text {
display:inline-block;
color: white;
padding: 2px;
margin-top: 1px;
}
.cart-text:hover {
text-decoration: underline;
}
/*Styling shop items*/
.shop-item {
display: block;
margin: 50px;
}
.shop-item-image {
display: block;
margin: 10px;
height: 200px;
}
.shop-item-title {
display: block;
text-align: center;
width: 100%;
font-weight: bold;
font-size: 1.1em;
color: #333;
margin-bottom: 5px;
}
.shop-item-details {
display: flex;
align-items: center;
}
.shop-item-price {
display: block;
text-align: center;
color: #333;
width: 50%;
}
.shop-item-button {
display: block;
}
.shop-items {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
/*Styling the image carousel*/
.carousel {
width: 600px;
height: 400px;
position: relative;
display: flex;
}
.carousel > ul {
margin: 0px;
padding: 0px;
list-style: none;
}
.carousel-container {
margin: auto;
align-items: center;
}
/*Styling the buttons on the carousel*/
.carousel-button {
position: absolute;
padding: 0 .25rem;
z-index: 2;
background: none;
background-color: rgba(0, 0, 0, .1);
border: none;
border-radius: .25rem;
font-size: 2.5rem;
top: 50%;
transform: translateY(-120%);
color: rgba(255, 255, 255, .5);
cursor: pointer;
}
.carousel-button:hover, .carousel-button:focus {
color: white;
background-color: rgba(0, 0, 0, .2);
}
.carousel-button:focus {
outline: 1px solid black;
}
.carousel-button.prev {
left: 1rem;
}
.carousel-button.next {
right: 12rem;
}
/*Styling and formatting the next image effect for the image carousel*/
.slide {
position: absolute;
inset: 0;
opacity: 0;
object-fit: fill;
transition: 400ms opacity ease-in-out;
transition-delay: 200ms;
}
.slide > img {
display: inline-block;
width: 70%;
height: 80%;
border-radius: 10px;
object-fit: cover;
box-shadow: 0px 0px 30px rgba(0, 0, 0, 0.5);
}
.slide[data-active] {
opacity: 1;
z-index: 1;
transition-delay: 0ms;
}
Use this CSS. It will also top align your content-section. I fixed horizontal scroll as well. Just make sure to keep your website content inside of body tags. Your footer was outside of the body tag.
*, *::before, *::after {
box-sizing: border-box;
font-family: 'Abel', sans-serif;
color: #777;
}
body {
margin: 0;
padding: 0;
min-height: 100vh;
display: flex;
flex-direction: column;
}
/* Styles for navigation menus */
nav ul {
margin: 0;
}
nav li{
display: inline-block;
}
nav a {
display: inline-flex;
padding: .5em;
margin-top: 5px;
margin-bottom: 5px;
color: white;
text-decoration: none;
transition: 350ms;
}
nav a:hover {
background-color: rgba(215, 200, 200, .3);
border-radius: 2px;
}
/*Style for MAIN navigation menu*/
.main-nav {
text-align: center;
font-size: 1.1em;
font-weight: lighter;
border-bottom: 1px solid rgba(215, 200, 200, .3);
}
.main-nav li {
padding: 0 5%;
}
.main-header {
background-image: url('headerfooterimages/headerpicture.jpg');
background-size: cover;
background-color: rgba(0, 0, 0, 0.5);
background-blend-mode: multiply;
padding-bottom: 25px;
border-bottom: 1px solid black;
}
/* Style for Page Title/Logo */
.titleLogo {
text-align: center;
margin: auto;
font-size: 4em;
font-family: 'Bebas Neue';
color: white;
}
.titleLogo-large {
font-size: 6em;
}
/*Styles for sections of content on page*/
.content-section {
margin: 1em;
padding: 2em;
width: 100%;
box-sizing: border-box;
position: relative;
flex-grow: 1;
}
.content-container {
max-width: 900px;
margin: 0 auto;
padding: 0 1.5em;
box-sizing: border-box;
}
.section-header {
font-family: Impact;
font-weight: normal;
color: rgb(34, 34, 34);
}
/*Styling the footer for each page*/
.main-footer {
background-color: rgb(45, 45, 45);
padding: 5px;
position: relative;
bottom: 0;
width: 100%;
height: 75px;
border-top: 1px solid black;
margin: auto;
}
.footer-text {
font-size: 25px;
color: rgba(128, 128, 128);
display: inline-flex;
}
.footer-text:hover {
text-shadow: 0px 0px 40px rgba(255, 255, 255, 0.75);
cursor: crosshair;
color:rgb(188, 188, 188);
}
.main-footer-container {
display: flex;
align-items: center;
}
.main-footer-container ul {
flex-grow: 1;
text-align: end;
}
/*Styling the social media links in the footer*/
.footer-nav li {
list-style: none;
display: inline-flex;
transition: 350ms;
}
.footer-nav img {
border-radius: 5px;
width: 30px;
height: 30px;
}
.footer-nav li:hover {
background-color: rgba(215, 200, 200, .3);
border-radius: 5px;
padding-left: 3px;
padding-right: 3px;
padding-top: 3px;
}
/*Styling buttons across the whole site*/
.btn {
background-color: #349aff;
border: none;
border-radius: 1em;
color: white;
padding: 8px 16px;
vertical-align: middle;
text-align: center;
text-decoration: none;
font-size: 8px;
font-weight: bold;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
}
.btn:hover {
background-color: #2090ff;
cursor: pointer;
box-shadow: none;
}
/*Styling the cart menu option in the main navigation*/
.cart-container{
display: inline-flex;
margin: auto;
}
.cart-icon {
float: left;
clear: left;
height: 25px;
}
.cart-text {
display:inline-block;
color: white;
padding: 2px;
margin-top: 1px;
}
.cart-text:hover {
text-decoration: underline;
}
/*Styling shop items*/
.shop-item {
display: block;
margin: 50px;
}
.shop-item-image {
display: block;
margin: 10px;
height: 200px;
}
.shop-item-title {
display: block;
text-align: center;
width: 100%;
font-weight: bold;
font-size: 1.1em;
color: #333;
margin-bottom: 5px;
}
.shop-item-details {
display: flex;
align-items: center;
}
.shop-item-price {
display: block;
text-align: center;
color: #333;
width: 50%;
}
.shop-item-button {
display: block;
}
.shop-items {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
/*Styling the image carousel*/
.carousel {
width: 600px;
height: 400px;
position: relative;
display: flex;
}
.carousel > ul {
margin: 0px;
padding: 0px;
list-style: none;
}
.carousel-container {
margin: auto;
align-items: center;
}
/*Styling the buttons on the carousel*/
.carousel-button {
position: absolute;
padding: 0 .25rem;
z-index: 2;
background: none;
background-color: rgba(0, 0, 0, .1);
border: none;
border-radius: .25rem;
font-size: 2.5rem;
top: 50%;
transform: translateY(-120%);
color: rgba(255, 255, 255, .5);
cursor: pointer;
}
.carousel-button:hover, .carousel-button:focus {
color: white;
background-color: rgba(0, 0, 0, .2);
}
.carousel-button:focus {
outline: 1px solid black;
}
.carousel-button.prev {
left: 1rem;
}
.carousel-button.next {
right: 12rem;
}
/*Styling and formatting the next image effect for the image carousel*/
.slide {
position: absolute;
inset: 0;
opacity: 0;
object-fit: fill;
transition: 400ms opacity ease-in-out;
transition-delay: 200ms;
}
.slide > img {
display: inline-block;
width: 70%;
height: 80%;
border-radius: 10px;
object-fit: cover;
box-shadow: 0px 0px 30px rgba(0, 0, 0, 0.5);
}
.slide[data-active] {
opacity: 1;
z-index: 1;
transition-delay: 0ms;
}
I'm looking to re-create this header but I want an image behind it instead of just a sold color, I want to use the black fade around but I can't find a way to get an image behind it.
background:#1a1a2e;
border-left:1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-nav {
position: absolute;
top: 0;
width: 250px;
list-style: none;
margin: 0;
padding: 0;
}
.sidebar-nav li.sidebar-nav-item a {
display: block;
text-decoration: none;
color: #fff;
padding: 15px;
}
.sidebar-nav li a:hover {
text-decoration: none;
color: #fff;
background: rgba(255, 255, 255, 0.2);
}
.sidebar-nav li a:active,
.sidebar-nav li a:focus {
text-decoration: none;
}
.sidebar-nav>.sidebar-brand {
font-size: 1.2rem;
background: rgba(52, 58, 64, 0.1);
height: 80px;
line-height: 50px;
padding-top: 15px;
padding-bottom: 15px;
padding-left: 15px;
}
.sidebar-nav>.sidebar-brand a:hover {
color: #fff;
background: none;
}
#sidebar-wrapper.active {
right: 250px;
width: 250px;
transition: all .4s ease 0;
}
.masthead {
min-height: 30rem;
position: relative;
display: table;
width: 100%;
height: auto;
padding-top: 8rem;
padding-bottom: 8rem;
background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0 rgba(255, 255, 255, 0.1) 100%), url(https://www.nme.com/wp-content/uploads/2019/10/Black-Widow-Avengers.jpg);
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
box-shadow: inset 120px 100px 250px #000, inset -120px -100px 250px #000;
}
.masthead h1 {
text-transform: uppercase;
font-size: 4rem;
color: #fff;
margin: 0;
padding: 0;
}
.masthead .mb-5 em {
color: #fff;
text-transform: uppercase;
}
.btn-xl {
text-transform: uppercase;
background-color: #d35d6e;
border: none;
color: #fff;
padding: 1.25rem 2.5rem;
}
.btn-xl:hover {
background-color: #fd3a69;
color: #000;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: 700;
}
.Container {
margin: 2% 2% 0 3%;
}
.Movies img {
margin-right: 1%;
margin-bottom: 10%;
width: 100%;
border-radius: 10px;
cursor: pointer;
box-shadow: -4px 4px 5px 0 #000;
transition: .8s;
}
.Movies img:hover {
transform: translateY(-10px);
box-shadow: 0 19px 38px rgba(0, 0, 0, 0.3), 0 15px 12px rgba(0, 0, 0, 0.22);
}
.Container h2 {
margin-bottom: 2%;
color: #f3e6e3;
}
#footer {
background-color: #020314;
color: #fff;
text-align: center;
padding: 2% 15%;
}
.social-icon {
cursor: pointer;
margin: 20px 10px;
}
.social-icon:hover {
color: #5F9EA0;
}
.footername {
color: #FF7F50;
}
.footername:hover {
text-decoration: none;
color: #DC143C;
}
.scroll-to-top {
position: fixed;
right: 15px;
bottom: 15px;
width: 50px;
height: 50px;
text-align: center;
color: #fff;
background: rgba(52, 58, 64, 0.5);
line-height: 45px;
display: none;
}
.scroll-to-top:focus,
.scroll-to-top:hover {
color: #F5F5F5;
}
.scroll-to-top i {
font-weight: 800;
}
.menu-toggle:focus,
.menu-toggle:hover,
.sidebar-nav>.sidebar-brand a {
color: #fff;
}
.menu-toggle:hover,
.scroll-to-top:hover {
background: #343a40;
}
#media min-width 992px {
.masthead {
height: 100vh;
}
.masthead h1 {
font-size: 5.5rem;
}
}
<header class="masthead d-flex">
<div class="container text-center my-auto">
<h1 class="mb-1">Welcome</h1>
<h3 class="mb-5"><em>Join our discord Community</em></h3><a class="btn btn-primary btn-xl js-scroll-trigger" href="https://discord.gg/YmtGhGQPSu">Join Now</a>
</div>
<div class="overlay"></div>
</header>
try this
header {
background-image: url("")
}
So, I got a navigation bar with dropdown menus. Whenever I move my cursor where the drop-down menu is hidden, it opens, and I need to disable that without disabling the drop-down menu as a whole. Any tips on how to do that?
If you want to go ahead and look at the latest version of my website can be found below.
Here's the link: https://p1ayerone.github.io/
And here's the CSS code:
#import url('https://fonts.googleapis.com/css2?family=Roboto:wght#300&display=swap');
:root {
--background: rgba(54, 57, 63, .85);
}
*,
*::before,
*::after {
margin: 0px;
padding: 0px;
box-sizing: inherit;
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
background: url(../../img/bg/bg.png) fixed center;
background-attachment: fixed;
background-position: center;
font-family: 'Roboto', sans-serif;
font-weight: 400;
box-sizing: border-box;
color: silver;
}
.content {
height: 200vh;
background-size: cover;
display: grid;
place-items: center;
}
/* navigation styles start here */
header {
z-index: 999;
width: 100%;
right: 0%;
top: 0%;
position: fixed;
}
.logo {
margin: 0;
color: silver;
list-style: none;
}
.img-logo {
margin-right: 15px;
padding-top: 8px;
margin-bottom: -10px;
}
.nav-toggle {
display: none;
}
.nav-toggle-label {
position: absolute;
top: 0;
left: 0;
margin-left: 1em;
height: 100%;
display: flex;
align-items: left;
margin-top: 3.5%;
}
.nav-toggle-label span,
.nav-toggle-label span::before,
.nav-toggle-label span::after {
display: block;
background: white;
height: 2px;
width: 2em;
border-radius: 2px;
position: relative;
}
.nav-toggle-label span::before,
.nav-toggle-label span::after {
content: '';
position: absolute;
}
.nav-toggle-label span::before {
bottom: 7px;
}
.nav-toggle-label span::after {
top: 7px;
}
.nav {
text-transform: uppercase;
font-size: 1.2rem;
background: var(--background);
padding-bottom: 1.7%;
}
.nav::after {
content: "";
display: table;
clear: both;
}
.nav-main {
float: right;
list-style: none;
margin-bottom: -21px;
padding-bottom: -15px;
}
.nav-main-item {
display: inline-block;
width: 12rem;
position: relative;
}
li {
list-style: none;
}
.nav-main a {
text-align: center;
padding: 1rem;
color: #eee;
text-decoration: none;
display: block;
}
.nav-main-item a:hover {
background-color: gray;
}
.nav-main-item:hover > * {
opacity: 1;
margin: 0;
}
.navi-main-item {
opacity: 0;
position: absolute;
width: 100%;
top: 100%;
z-index: -1;
background: var(--background);
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.8);
}
.more-main-item {
opacity: 0;
position: absolute;
width: 100%;
top: 100%;
z-index: -1;
background: var(--background);
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.8);
}
.nav-toggle:checked ~ nav {
transform: scale(1,1);
}
.nav-toggle:checked ~ nav a {
opacity: 1;
transition: opacity 250ms ease-in-out 250ms;
}
.destiny-intro-p {
padding-left: 100px;
font-size: 1.3rem;
}
.destiny-intro-h1 {
font-size: 3rem;
}
.body-block {
background-color: black;
color: white;
padding-bottom: 6%;
}
#media screen and (min-width: 800px) {
.nav-toggle-label {
display: none;
}
header {
z-index: 999;
width: 100%;
right: 0%;
top: 0%;
position: fixed;
}
.logo {
margin: 0;
color: silver;
list-style: none;
padding-top: 15;
}
.nav {
text-transform: uppercase;
font-size: 1.2rem;
background: var(--background);
}
.nav::after {
content: "";
display: table;
clear: both;
}
.nav-main {
float: right;
list-style: none;
}
.nav-main-item {
display: inline-block;
width: 10rem;
position: relative;
}
.nav-main a {
text-align: center;
padding: 1rem;
color: white;
text-decoration: none;
display: block;
}
.nav-main-item a:hover {
background-color: silver;
}
.nav-main-item:hover > * {
opacity: 1;
margin: 0;
}
.navi-main-item {
opacity: 0;
position: absolute;
width: 100%;
top: 100%;
z-index: -1;
background: var(--background);
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.8);
}
.Discord {
float: right;
}
.gif-Destiny {
width: 200px;
float: right;
color: silver;
}
.Zachary {
color: black;
text-decoration: none;
}
.introduction {
color: black;
}
.footer {
background-color: #1F2E4B;
color: white;
text-align: center;
font-size: 20px;
float: center;
margin-top: 100%;
}
.CbZD{
color: #00FFFF;
font-size: 30px;
}
}
.Discord {
float: right;
}
.img-Destiny {
padding-top: 0px;
width: 300px;
float: right;
color: black;
}
.Zachary {
color: black;
text-decoration: none;
}
.introduction {
color: black;
}
.footer {
background-color: #1F2E4B;
color: white;
text-align: center;
font-size: 20px;
float: center;
}
.CbZD{
color: #00FFFF;
font-size: 30px;
}
/* Videos */
.tse {
color: #07FC1B;
text-align: center;
}
/* Characters */
.img-TBG {
background-color: white;
color: black;
float: left;
width: 300px;
height: 500px;
}
/* Applications */
.silver-box {
background-color: silver;
color: black;
height: 1400px;
width: 640px;
}
/* About Me */
.abtme {
width: 50%;
margin: 0 auto;
}
/* Links */
.contact-me {
color: silver;
}
.gmail-footer {
color: silver;
}
.twitter-footer {
color: silver;
}
/* Contact */
.contact-title {
margin-top: 100px;
color: white;
text-transform: uppercase;
transition: all 4s ease-in-out;
}
.contact-title h1 {
font-size: 32px;
line-height: -10px;
}
.contact-title h2 {
font-size: 16px;
}
form {
margin-top: 50px;
transition: all 4s ease-in-out;
}
.form-control {
width: 600px;
background: var(--background);
border: none;
outline: none;
border-bottom: 1px solid gray;
color: white;
font-size: 18px;
margin-bottom: 16px;
}
input {
height: 45px;
}
form .submit {
background: #ff5722;
border-color: transparent;
color: #fff;
font-size: 20px;
font-weight: bold;
letter-spacing: 2px;
height: 50px;
margin-top: 20px;
}
form .submit:hover {
background-color: #f44336;
cursor: pointer;
}
Instead of using opacity:0 and opacity:1 to display the dropdown, you can use display:none and display:inline-block. When using opacity, it doesn't remove the element from the page, which is why the dropdown would appear when hovering in that area.
Can read more about this here https://magnusbenoni.com/difference-between-display-visibility-opacity/
.nav-main-item:hover > .navi-main-item {
display: inline-block;
margin: 0;
}
.navi-main-item {
display: none;
position: absolute;
width: 100%;
top: 100%;
z-index: -1;
background: var(--background);
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.8);
}
I need help making my navigation bar mobile friendly.
I tried following a few tutorials, but none of them worked.
Here's the web site's link (for the HTML) and here's the link to the CSS code.
I've tried using the #media tag, but it doesn't seem to apply to any of the content inside of the #media tag.
Here's the Media query for the CSS code:
```#media screen and (min-width: 800px) {
.nav-toggle-label {
display: none;
}
header {
z-index: 999;
width: 100%;
right: 0%;
top: 0%;
position: fixed;
}
.logo {
margin: 0;
color: silver;
list-style: none;
padding-top: 15;
}
.nav {
text-transform: uppercase;
font-size: 1.2rem;
background: var(--background);
}
.nav::after {
content: "";
display: table;
clear: both;
}
.nav-main {
float: right;
list-style: none;
}
.nav-main-item {
display: inline-block;
width: 10rem;
position: relative;
}
.nav-main a {
text-align: center;
padding: 1rem;
color: white;
text-decoration: none;
display: block;
}
.nav-main-item a:hover {
background-color: silver;
}
.nav-main-item:hover > .navi-main-item {
display: inline-block;
margin: 0;
}
.navi-main-item {
display: none;
position: absolute;
width: 100%;
top: 100%;
z-index: -1;
background: var(--background);
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.8);
}
.Discord {
padding-left: 72%;
margin-bottom: 80px;
}
.gif-Destiny {
width: 200px;
float: right;
color: white;
text-shadow: 2px 2px black;
}
.Zachary {
color: white;
text-decoration: none;
text-shadow: 2px 2px black;
}
.introduction {
color: white;
text-shadow: 2px 2px black;
}
.footer {
background-color: #1F2E4B;
color: white;
text-align: center;
font-size: 20px;
float: center;
margin-top: 12.5%;
}
.CbZD{
color: #00FFFF;
font-size: 30px;
}
}```
Have you tried Boostrap. It will give you a Headstart.
visit https://getbootstrap.com/docs/4.0/components/navbar/
With character: http://jsfiddle.net/nuu6g/
For some reason, I cannot click on my text on my navigation menu. This is most likely due to the (missing) image on the left, which I will refer to as the "character." However, when I remove the character, I can indeed click on the text again.
Without character: http://jsfiddle.net/aN5s5/
body {
background:grey;
}
.topContainer {
width: 1000px;
height: 125px;
margin: 0 auto;
padding-bottom: 20px;
}
#logo {
float: left;
padding: 10px 10px;
}
/* Navigation */
#navigation {
background: #107AEB;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#107AEB), to(#106FEB));
background: -webkit-linear-gradient(top, #107AEB, #106FEB);
background: -moz-linear-gradient(top, #107AEB, #106FEB);
background: -ms-linear-gradient(top, #107AEB, #106FEB);
background: -o-linear-gradient(top, #107AEB, #106FEB);
border: 2px solid rgba(16, 86, 235, 0.9);
border-radius: 15px;
float: right;
width: 455px;
height: 55px;
margin-top: 22px;
z-index: 1;
}
#navigation ul {
display: inline-block;
position: absolute;
list-style-type: none;
}
#navigation li {
display: inline-block;
}
#navigation a {
color: #FFF;
font-family: SEGOEUIL, Arial, sans-serif;
text-shadow: 0 1px 0 #000;
text-align: center;
padding: 5px 10px;
font-size: 17px;
}
#navigation a:hover {
background: rgba(16, 86, 235, 0.9);
border-radius: 5px;
}
#navigation a:active {
text-decoration: none;
}
#navigation a:link {
text-decoration: none;
}
.character {
z-index: 2;
padding: 0 275px;
float: left;
position: absolute;
width: 187px;
height: 174px;
}
/* Wrapper */
#wrapper {
background: #FFF;
/*rgba(255, 255, 255, 0.85);*/
border-top-left-radius: 25px;
border-top-right-radius: 25px;
width: 1000px;
height: 1200px;
position: relative;
z-index: 3;
overflow: hidden;
margin: 0 auto;
}
#photoContent {
background: #ffcc00;
border: 1px solid #b62100;
border-radius: 8px;
width: 781px;
height: 231px;
margin-top: 12px;
display: block;
margin-left: auto;
margin-right: auto;
}
.displayPhoto {
width: 771px;
height: 221px;
border: 0;
border-radius: 8px;
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 3px;
border: 1px solid #b62100;
}
#leftContent {
padding-top: 15px;
width: 500px;
height: 140px;
float: left;
padding-left: 45px;
}
.title {
font-family: Arial, sans-serif;
color: #3abfee;
font-size: 20px;
}
.desc {
color: #575757;
font-size: 15px;
font-family: Arial, sans-serif;
}
#rightContent {
padding-top: 15px;
width: 300px;
height: 140px;
float: right;
padding-right: 25px;
}
#flashContent {
padding-left: 25px;
width: 700px;
height: 500px;
}
hr {
width: 750px;
height: 1px;
background: #CCC;
border: none;
margin-top: 10px;
}
/* Bottom Wrapper */
#bwCont {
width: 1000px;
height: 500px;
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 10px;
}
.galleryCont {
display: block;
margin-left: auto;
margin-right: auto;
width: 650px;
height: 150px;
}
.galleryImgCont {
width: 175px;
height: 175px;
float: left;
}
.galleryTitle {
font-family:'Exo 2', sans-serif;
font-size: 17px;
color: #333;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
padding-top: 145px;
}
.galleryDesc {
font-family:'Exo 2', sans-serif;
font-size: 15px;
color: #333;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}
#galleryImg {
width: 175px;
height: 125px;
border: 5px solid #F5F5F5;
box-shadow: 0 0 7px;
border-radius: 5px;
float: left;
}
.readMore {
width: 175px;
height: 50px;
background: #000;
border: 0;
border-radius: 5px;
padding: 10px 10px;
color: #FFF;
font-family:'SEGOEUIL', sans-serif;
font-size: 17px;
}
.readMore:hover {
background: #202020;
}
Please help me, thanks! Also, just an extra question; is there any way I can keep the read more buttons inline, instead of like a staircase? Sorry, but thank you!
For your links to be "clickable", either adjust the padding/width of #character or use the following CSS so #navigation comes up top of #character
#navigation {
z-index: 3;
position: relative;
}
DEMO
For "Read More" to be aligned, you're going to need to have the same number of lines in the title and the description, or you can set a minimum height (or even just the height) of those by adding the following CSS for eaxmple:
.galleryTitle {
min-height:40px;
}
.galleryDesc {
min-height:60px;
}
DEMO
Your nav items are displaying in a staircase because there is not enough room due to the width of your ul. adding width 100% will allow them to display inline the way you want.
#navigation ul {
width: 100%
}
the reason you can't click your text link is because of your character class overlaying your images with a higher z-index.