I am trying to use a checkbox to make my font awesome icon trigger the menu icon to open and close the menu (which is how I want it to be design wise) when the screen is in mobile view.
Thanks in advance for any help.
/*** General ***/
* {
font-family: 'Noto Serif SC', serif;
margin: 0;
padding: 0;
}
.bluepic {
padding-top: 10px;
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
max-width: 400px;
height: auto;
}
.contents1 {
margin-top: 5vh;
margin-bottom: 10vh;
}
a {
text-decoration: none;
color: black;
margin: none;
padding: none;
}
/*** Header ***/
.header {
margin-top: 20px;
margin-bottom: 20px;
}
.logo {
text-align: center;
font-size: 30px;
}
/*** Navigation ***/
.fa-bars {
display: none;
}
.nav-links {
width: 100%;
float: left;
position: sticky;
align-items: center;
justify-content: center;
padding: 0;
background-color: #f7f7f7;
border-bottom: 1px solid rgb(228, 224, 224);
display: flex;
}
.nav-links li {
list-style: none;
text-align: center;
font-size: 18px;
float: left;
padding: 14px 16px;
}
.nav-links li a {
text-decoration: none;
text-align: center;
float: left;
}
/*** Footer ***/
.footer {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
text-align: center;
}
.footer2 {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
text-align: center;
}
/*** Media Queries ***/
#media only screen and (max-width: 800px) {
.bluepic {
padding-top: 10px;
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
max-width: 375px;
height: auto;
}
}
#media only screen and (max-width: 700px) {
.bluepic {
padding-top: 10px;
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
max-width: 350px;
height: auto;
}
}
#media only screen and (max-width: 600px) {
.fa-bars {
font-size: 20px;
display: block;
float: right;
margin-top: 10px;
margin-right: 40px;
cursor: pointer;
}
.logo {
text-align: left;
font-size: 25px;
}
.nav-toggle {
display: none;
}
.nav-links,
ul {
position: fixed;
width: 100%;
height: 100vh;
text-align: center;
background-color: #f7f7f7;
border-bottom: 1px solid rgb(107, 76, 76);
top: 80px;
left: 0;
flex-direction: column;
display: none;
}
.nav-toggle:checked+.nav-links,
ul {
display: flex;
}
.nav-links li {
display: block;
}
.contents1 {
margin-top: 5vh;
}
}
<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=Noto+Serif+SC:wght#200&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<div class="header">
<div>
<div class="logo">
<h4>The Blue Lion <i class="fas fa-bars" id="nav-toggle"></i></h4>
<input type="checkbox" id="nav-toggle" class="nav-toggle">
</div>
</div>
<label for="nav-toggle" class="nav-toggle-label">
<span></span>
</label>
</div>
<div class="navbar">
<div class="nav-links" id="myTopnav">
<ul>
<li a href="#">Food</li>
<li a href="#">Drink</li>
<li a href="#">Covid-19</li>
<li a href="#">News</li>
<li a href="#">Join the Team</li>
</ul>
</div>
</div>
<div class="contents1">
<img src="https://mcdn.wallpapersafari.com/medium/84/3/pQuUz4.jpg" class="bluepic" alt="Blue">
</div>
<div class="footer">
<div class="info">
Leave us a review:
<i class="fab fa-tripadvisor"></i>
</div>
<div class="socialiconsf">
<i class="fab fa-facebook-f"></i>
<i class="fab fa-twitter"></i>
<i class="fab fa-instagram"></i>
</div>
</div>
<div class="footer2">
<p>
© The Blue Lion 2021
</p>
</div>
Do this:
* {
font-family: 'Noto Serif SC', serif;
margin: 0;
padding: 0;
}
.bluepic {
padding-top: 10px;
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
max-width: 400px;
height: auto;
}
.contents1 {
margin-top: 5vh;
margin-bottom: 10vh;
}
a {
text-decoration: none;
color: black;
margin: none;
padding: none;
}
/*** Header ***/
.header {
margin-top: 20px;
margin-bottom: 20px;
}
.logo {
text-align: center;
font-size: 30px;
}
/*** Navigation ***/
.fa-bars {
display: none;
}
.nav-links {
width: 100%;
float: left;
position: sticky;
align-items: center;
justify-content: center;
padding: 0;
background-color: #f7f7f7;
border-bottom: 1px solid rgb(228, 224, 224);
display: flex;
}
.nav-links li {
list-style: none;
text-align: center;
font-size: 18px;
float: left;
padding: 14px 16px;
}
.nav-links li a {
text-decoration: none;
text-align: center;
float: left;
}
/*** Footer ***/
.footer {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
text-align: center;
}
.footer2 {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
text-align: center;
}
/*** Media Queries ***/
#media only screen and (max-width: 800px) {
.bluepic {
padding-top: 10px;
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
max-width: 375px;
height: auto;
}
}
#media only screen and (max-width: 700px) {
.bluepic {
padding-top: 10px;
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
max-width: 350px;
height: auto;
}
}
#media only screen and (max-width: 600px) {
.fa-bars {
font-size: 20px;
display: block;
float: right;
margin-top: 10px;
margin-right: 40px;
cursor: pointer;
}
.logo {
text-align: left;
font-size: 25px;
}
.nav-toggle {
display: none;
}
.nav-links,
ul {
width: 100%;
height: 100vh;
text-align: center;
background-color: #f7f7f7;
border-bottom: 1px solid rgb(107, 76, 76);
top: 80px;
left: 0;
flex-direction: column;
display: none;
}
.nav-toggle:checked+.nav-links,
ul {
display: flex;
}
.nav-links li {
display: block;
}
.contents1 {
margin-top: 5vh;
}
}
#media (max-width:600px){
.hamburger-menu{
position: relative;
}
.checkbox:checked~ .nav-links{
display: block;
}
}
<div class="header">
<div>
<div class="logo">
<h4>The Blue Lion
</div>
</h4>
</div>
<label for="nav-toggle" class="nav-toggle-label">
<span></span>
</label>
</div>
</div>
<div class="navbar">
<input type="checkbox" id="check" class="checkbox" hidden>
<label for="check" class="fas fa-bars"></label>
<div class="nav-links" id="myTopnav">
<ul>
<li a href="#">Food</li>
<li a href="#">Drink</li>
<li a href="#">Covid-19</li>
<li a href="#">News</li>
<li a href="#">Join the Team</li>
</ul>
</div>
</div>
<div class="contents1">
<img src="bluepic1.jpg" class="bluepic" alt="Blue">
</div>
<div class="footer">
<div class="info">
Leave us a review:
<i class="fab fa-tripadvisor"></i>
</div>
<div class="socialiconsf">
<i class="fab fa-facebook-f"></i>
<i class="fab fa-twitter"></i>
<i class="fab fa-instagram"></i>
</div>
</div>
<div class="footer2">
<p>
© The Blue Lion 2021
</p>
</div>
CSS modification:
The font-awesome library overrides your CSS. That is why your menu-icon (.fa-bars) wouldn't hide when not in mobile mode.
I made following corrections to your CSS:
Changing .fa-bars to .fas.fa-bars
Adding !important in mobile mode
(to show always when media break-point (... and (max-width: 600px))
/*** Navigation ***/
.fas.fa-bars {
display: none;
}
#media only screen and (max-width: 600px) {
.fas.fa-bars {
font-size: 20px;
display: block !important;
float: right;
margin-top: 10px;
margin-right: 40px;
cursor: pointer;
}
}
Click event handler on checkBox:
Also, if you want functionality to your checkbox, then you would have to add an event-handler in JS and add the onClick=function() in your HTML (and correct the issue of the multiple assigned id as mentioned in comments: I replaced id="nav-toggle" with id="nav-toggle-bars" for the <i class="fas fa-bars" element).
Following complete code for you to Run code snippet and comment if this is your desired outcome (please advise).
Expand to "full-page" and change your browser width to see effect
below media break-point (... and (max-width: 600px))
const menuToggle = document.getElementById("nav-toggle-bars");
let menuCheckBox;
function showHideNavToggle(event) {
menuCheckBox = event.target;
if (menuCheckBox.checked) {
menuToggle.style.display = "block";
} else {
menuToggle.style.display = "none";
}
}
/*** General ***/
* {
font-family: 'Noto Serif SC', serif;
margin: 0;
padding: 0;
}
.bluepic {
padding-top: 10px;
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
max-width: 400px;
height: auto;
}
.contents1 {
margin-top: 5vh;
margin-bottom: 10vh;
}
a {
text-decoration: none;
color: black;
margin: none;
padding: none;
}
/*** Header ***/
.header {
margin-top: 20px;
margin-bottom: 20px;
}
.logo {
text-align: center;
font-size: 30px;
}
/*** Navigation ***/
.fas.fa-bars {
display: none;
}
.nav-links {
width: 100%;
float: left;
position: sticky;
align-items: center;
justify-content: center;
padding: 0;
background-color: #f7f7f7;
border-bottom: 1px solid rgb(228, 224, 224);
display: flex;
}
.nav-links li {
list-style: none;
text-align: center;
font-size: 18px;
float: left;
padding: 14px 16px;
}
.nav-links li a {
text-decoration: none;
text-align: center;
float: left;
}
/*** Footer ***/
.footer {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
text-align: center;
}
.footer2 {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
text-align: center;
}
/*** Media Queries ***/
#media only screen and (max-width: 800px) {
.bluepic {
padding-top: 10px;
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
max-width: 375px;
height: auto;
}
}
#media only screen and (max-width: 700px) {
.bluepic {
padding-top: 10px;
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
max-width: 350px;
height: auto;
}
}
#media only screen and (max-width: 600px) {
.fas.fa-bars {
font-size: 20px;
display: block !important;
float: right;
margin-top: 10px;
margin-right: 40px;
cursor: pointer;
}
.logo {
text-align: left;
font-size: 25px;
}
.nav-toggle {
display: none;
}
.nav-links,
ul {
position: fixed;
width: 100%;
height: 100vh;
text-align: center;
background-color: #f7f7f7;
border-bottom: 1px solid rgb(107, 76, 76);
top: 80px;
left: 0;
flex-direction: column;
display: none;
}
.nav-toggle:checked+.nav-links,
ul {
display: flex;
}
.nav-links li {
display: block;
}
.contents1 {
margin-top: 5vh;
}
}
<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=Noto+Serif+SC:wght#200&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<div class="header">
<div>
<div class="logo">
<h4>The Blue Lion <i class="fas fa-bars" id="nav-toggle-bars"></i></h4>
<input type="checkbox" onclick="showHideNavToggle(event)" id="nav-toggle" class="nav-toggle">
</div>
</div>
<label for="nav-toggle" class="nav-toggle-label">
<span></span>
</label>
</div>
<div class="navbar">
<div class="nav-links" id="myTopnav">
<ul>
<li a href="#">Food</li>
<li a href="#">Drink</li>
<li a href="#">Covid-19</li>
<li a href="#">News</li>
<li a href="#">Join the Team</li>
</ul>
</div>
</div>
<div class="contents1">
<img src="https://mcdn.wallpapersafari.com/medium/84/3/pQuUz4.jpg" class="bluepic" alt="Blue">
</div>
<div class="footer">
<div class="info">
Leave us a review:
<i class="fab fa-tripadvisor"></i>
</div>
<div class="socialiconsf">
<i class="fab fa-facebook-f"></i>
<i class="fab fa-twitter"></i>
<i class="fab fa-instagram"></i>
</div>
</div>
<div class="footer2">
<p>
© The Blue Lion 2021
</p>
</div>
Note:
I also corrected 2 html closing tags (one </div> eliminated and </h4> closing tag corrected and replaced img source with a link to a generic blue background)
See this response in codepen.
https://codepen.io/threefingers/pen/PojZMpx
Add in your ::before element icon, the code icons in your states.
.mydiv{
background-color: blue;
height: 50px;
width: 50px;
}
input + .mydiv::before{
content: 'code icon 1';
}
input:checked + .mydiv::before{
content: 'code icon 2';
}
<input type="checkbox" value="Car"> I have a car
<div class="mydiv"></div>
Related
I am currently trying to make a website. However, the problem that I am getting is that when I minimize the browser, Yes, it is being responsive, but the text is going over the other components on the website and I am unsure how to work around this issue as I am quite stumped at this error.
Image for more clarification:
Web error
HTML Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- font awesome cdn link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="stylesheet" href="https://unpkg.com/swiper#7/swiper-bundle.min.css" />
<link rel="stylesheet" href="jason.css">
</head>
<body>
<nav>
<div class="logo">Revolutionary Fitness</div>
<ul>
<div class="items">
<li>Home</li>
<li>Classes</li>
<li>Products</li>
<li>Login</li>
<li>Feedback</li>
</div>
</ul>
</nav>
<div class="background">
<div class="overlay">
<h3>Classes</h3>
<p>Insert Something Here...</p>
</div>
</div>
<div class="main">
<h1>Classes, coaches and community</h1>
<div class="main text">
<p>At Virgin Active, we do health and fitness differently. We have expertly crafted exercise experiences
that are the perfect blend of intelligent programming and feel-good movement. We've got everything from
Yoga to HIIT, so you can move your body any
way you want.
</p>
</div>
</div>
<section class="no.1" id="no.1">
<div class="section">
<img src="Yoga.jpg" alt="Yoga">
<div class="ClassText">
<h1>Yoga</h1>
<p>
Choose from Classes with dynamism,energy and athleticism, to an authentic and peaceful experience.
<br><br>
Classes include: Align,Flow and Calm SkyPark Yoga
<br><br>
Sign Up<span> to book this class</span>
</p>
</div>
</div>
</section>
<footer class="footer">
<div class="social">
<i class="fab fa-facebook-f"></i>
<i class="fab fa-whatsapp"></i>
<i class="fab fa-twitter"></i>
<i class="fab fa-instagram"></i>
</div>
<ul class="list">
<li>About Us</li>
<li>Contact Us</li>
<li>FAQs</li>
</ul>
<p class="copyright">
<small>©2022 Revolutionary Fitness</small>
</p>
</footer>
</body>
</html>
Css:
#import url("https://fonts.googleapis.com/css2?family=Nunito:wght#200;300;400;600&display=swap");
* {
font-family: 'Nunito', sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
}
nav {
background: #1b1b1b;
}
nav:after {
content: '';
clear: both;
display: table;
}
nav .logo {
float: left;
color: white;
font-size: 27px;
line-height: 70px;
padding-left: 60px;
}
nav ul {
display: flex;
justify-content: center;
align-items: center;
list-style: none;
float: right;
margin-right: 40px;
}
nav ul li {
display: inline-block;
background: #1b1b1b;
margin: 0 5px;
}
nav ul li a {
color: white;
text-decoration: none;
line-height: 70px;
font-size: 18px;
padding: 8px 15px;
}
nav ul li a:hover {
color: cyan;
}
nav ul ul li a:hover {
color: cyan;
box-shadow: none;
}
nav ul ul {
position: absolute;
top: 90px;
opacity: 0;
visibility: hidden;
transition: top .3s;
}
.background {
background-color: #212529;
width: 100%;
height: 200px;
position: relative;
/* USE FLEXBOX */
display: flex;
align-items: center;
justify-content: flex-start;
/* ADD SOME PADDING FOR BETTER UI */
padding-inline: 16px; /* LEFT and Right */
}
.overlay {
height: 100%;
color: white;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
position: relative;
}
.overlay h3 {
margin-bottom: 20px;
color: crimson;
font-size: 20px;
}
.overlay p {
font-size: 35px;
}
.main h1 {
display: flex;
text-align: center;
justify-content: center;
margin-top: 20px;
font-size: 50px;
}
.text {
width: 50%;
height: 50px;
padding-top: 20px;
white-space: initial;
margin: 0 auto;
word-wrap: break-word;
}
body {
margin: 0;
font-family: sans-serif;
}
.section {
background-color: #F5F5F5;
display: flex;
justify-content: space-between;
padding: 40px;
width: 80%;
margin-top: 50px;
float: left;
}
.section img {
height: 250px;
}
.section h1 {
margin-left: 100px;
color: black;
}
.section p {
margin-left: 100px;
width: 55%;
height: 50px;
white-space: initial;
margin-left: 100px;
margin-top: 20px;
word-wrap: break-word;
}
.footer {
background-color: #000;
padding: 40px;
clear: both;
}
.footer .social {
text-align: center;
padding-bottom: 25px;
color: #4b4c4d;
}
.footer .social a {
display: inline-block;
height: 40px;
width: 40px;
background: #424242;
margin: 0 10px 10px 0;
text-align: center;
line-height: 40px;
border-radius: 50%;
color: #ffffff;
transition: all 0.5s ease;
}
.footer .social a:hover {
color: #24262b;
background-color: #ffffff;
}
.footer ul {
margin-top: 0;
padding: 0;
list-style: none;
font-size: 18px;
line-height: 1.6;
margin-bottom: 0;
text-align: center;
}
.footer ul li a {
color: #fff;
text-decoration: none;
}
.footer ul li {
display: inline-block;
padding: 0 15px;
}
.footer .copyright {
margin-top: 15px;
text-align: center;
font-size: 20px;
color: #fff;
}
you can use css media query create responsive web page.
#media only screen and (min-width: 768px) {
.overlay h3 {
font-size: 16px;
}
.overlay p {
font-size: 25px;
}
}
#media only screen and (min-width: 1200px) {
.overlay h3 {
font-size: 22px;
}
.overlay p {
font-size: 40px;
}
}
Another way that is not recommended using viewport width and height
.overlay p {
font-size: 1.5vw;
}
Still learning code. I am building a contact page and wanted to include my header bar at the top of the page, but when I added the code for this my header bar appears to the left of my page all wacky. I know this is most likely a CSS error, but I can't seem to pinpoint why my header bar wouldn't display at the top of my page. Anyone willing to take a look? Here's my code.
<!DOCTYPE html>
<!-- Created By CodingLab - www.codinglabweb.com -->
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<!-- <title> Responsive Contact Us Form | CodingLab </title>
<link rel="stylesheet" href="style.css">
<!-- Fontawesome CDN Link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css"/>
<link href="css/stylesheet2.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<header>
<section class="header">
<div class="header_content">
<div class="logo_container">
<a href="index.html">
<img alt="ArtUcii logo" class="logo" src="images/Artucii_logo.png">
</a>
</div>
<ul class="navigation">
<li>Home</li>
<li>Portfolio</li>
<li>About ME
<li>Contact</li>
</ul>
</div>
</section>
</header>
<div class="container">
<div class="content">
<div class="left-side">
<div class="address details">
<i class="fas fa-map-marker-alt"></i>
<div class="topic">Address</div>
<div class="text-one">Los Angles, CA</div>
<div class="text-two">Austin,TX</div>
</div>
<div class="phone details">
<i class="fas fa-phone-alt"></i>
<div class="topic">Phone</div>
<div class="text-one">(512) xxx-xxxx</div>
<div class="text-two">+</div>
</div>
<div class="email details">
<i class="fas fa-envelope"></i>
<div class="topic">Email</div>
<div class="text-one">artuciidesign#gmail.com</div>
<div class="text-two">alexandria.brown3#snhu.com</div>
</div>
</div>
<div class="right-side">
<div class="topic-text">Send me a message!</div>
<br>
<p>Any questions or ideas, just fill out the form below and I'll be happy to help.</p>
<form action="#">
<div class="input-box">
<input type="text" placeholder="Enter your name">
</div>
<div class="input-box">
<input type="text" placeholder="Enter your email">
</div>
<div class="input-box message-box">
</div>
<div class="button">
<input type="button" value="Send Now" >
</div>
</form>
</div>
</div>
</div>
</body>
</html>
/* About ME */
/* Google Font CDN Link */
/* Header */
.header {
width: 100%;
height: 50px;
display: block;
background-color: #61d1e2; /* For browsers that do not support gradients */
background-image: linear-gradient(#e7bddc, #61d1e2);
}
.header_content {
width: 100%;
height: 100%;
display: block;
margin: 0 auto;
background-color: #61d1e2; /* For browsers that do not support gradients */
background-image: linear-gradient(#e7bddc, #61d1e2);
}
.logo_container {
height: 100%;
display: table;
float: left;
border: none;
}
.logo {
max-height: 50px;
display: table-cell;
vertical-align: middle;
}
/* Navigation */
.navigation {
float: right;
height: 100%;
margin: 0;
}
.navigation li {
float: left;
height: 100%;
display: table-cell;
padding: 15px 20px;
position: relative;
box-sizing: border-box;
text-decoration: none;
}
a:hover {
color: #bc0456 !important;
}
.navigation li a {
display: inline-block;
vertical-align: middle;
height: 100%;
color:#067393;
font-family: Kapelka New;
text-decoration: none !important;
}
.sub_menu1 {
display: none;
}
.navigation li:hover .sub_menu1 {
display: block;
position: absolute;
background: black;
top: 100%;
}
.navigation li:hover .sub_menu1 ul {
display: inline-block;
margin: 0%;
padding: 0%;
text-align: center;
}
.navigation li:hover .sub_menu1 ul li {
padding: 5px;
}
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#200;300;400;500;600;700&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins" , sans-serif;
}
body{
min-height: 100vh;
width: 100%;
background: #f99a61;
display: flex;
align-items: center;
justify-content: center;
}
.container{
width: 85%;
background: #fff;
border-radius: 6px;
padding: 20px 60px 30px 40px;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}
.container .content{
display: flex;
align-items: center;
justify-content: space-between;
}
.container .content .left-side{
width: 25%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 15px;
position: relative;
}
.content .left-side::before{
content: '';
position: absolute;
height: 70%;
width: 2px;
right: -15px;
top: 50%;
transform: translateY(-50%);
background: #afafb6;
}
.content .left-side .details{
margin: 14px;
text-align: center;
}
.content .left-side .details i{
font-size: 30px;
color: #067393;
margin-bottom: 10px;
}
.content .left-side .details .topic{
font-size: 18px;
font-weight: 500;
}
.content .left-side .details .text-one,
.content .left-side .details .text-two{
font-size: 14px;
color: #afafb6;
}
.container .content .right-side{
width: 75%;
margin-left: 75px;
}
.content .right-side .topic-text{
font-size: 23px;
font-weight: 600;
color: #bc0456;
}
.right-side .input-box{
height: 50px;
width: 100%;
margin: 12px 0;
}
.right-side .input-box input,
.right-side .input-box textarea{
height: 100%;
width: 100%;
border: none;
outline: none;
font-size: 16px;
background: #F0F1F8;
border-radius: 6px;
padding: 0 15px;
resize: none;
}
.right-side .message-box{
min-height: 110px;
}
.right-side .input-box textarea{
padding-top: 6px;
}
.right-side .button{
display: inline-block;
margin-top: 12px;
}
.right-side .button input[type="button"]{
color: #fff;
font-size: 18px;
outline: none;
border: none;
padding: 8px 16px;
border-radius: 6px;
background: #067393;
cursor: pointer;
transition: all 0.3s ease;
}
.button input[type="button"]:hover{
background: #bc0456;
}
#media (max-width: 950px) {
.container{
width: 90%;
padding: 30px 40px 40px 35px ;
}
.container .content .right-side{
width: 75%;
margin-left: 55px;
}
}
#media (max-width: 820px) {
.container{
margin: 40px 0;
height: 100%;
}
.container .content{
flex-direction: column-reverse;
}
.container .content .left-side{
width: 100%;
flex-direction: row;
margin-top: 40px;
justify-content: center;
flex-wrap: wrap;
}
.container .content .left-side::before{
display: none;
}
.container .content .right-side{
width: 100%;
margin-left: 0;
}
}
Your <header> (as opposed to <head>) has to be inside the <body> tag (which contains everything that is visible on the page)!
As a start, IMO, <body> should not be styled as flex, at least not when using <header> which brings its own defaults which were being overridden.
Moving the flex styles from body to .container will fix your immediate request, but probably introduce other styling concerns.
.header {
width: 100%;
height: 50px;
display: block;
background-color: #61d1e2;
/* For browsers that do not support gradients */
background-image: linear-gradient(#e7bddc, #61d1e2);
}
.header_content {
width: 100%;
height: 100%;
display: block;
margin: 0 auto;
background-color: #61d1e2;
/* For browsers that do not support gradients */
background-image: linear-gradient(#e7bddc, #61d1e2);
}
.logo_container {
height: 100%;
display: table;
float: left;
border: none;
}
.logo {
max-height: 50px;
display: table-cell;
vertical-align: middle;
}
/* Navigation */
.navigation {
float: right;
height: 100%;
margin: 0;
}
.navigation li {
float: left;
height: 100%;
display: table-cell;
padding: 15px 20px;
position: relative;
box-sizing: border-box;
text-decoration: none;
}
a:hover {
color: #bc0456 !important;
}
.navigation li a {
display: inline-block;
vertical-align: middle;
height: 100%;
color: #067393;
font-family: Kapelka New;
text-decoration: none !important;
}
.sub_menu1 {
display: none;
}
.navigation li:hover .sub_menu1 {
display: block;
position: absolute;
background: black;
top: 100%;
}
.navigation li:hover .sub_menu1 ul {
display: inline-block;
margin: 0%;
padding: 0%;
text-align: center;
}
.navigation li:hover .sub_menu1 ul li {
padding: 5px;
}
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#200;300;400;500;600;700&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}
body {
min-height: 100vh;
width: 100%;
background: #f99a61;
}
.container {
display: flex;
align-items: center;
justify-content: center;
width: 85%;
background: #fff;
border-radius: 6px;
padding: 20px 60px 30px 40px;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}
.container .content {
display: flex;
align-items: center;
justify-content: space-between;
}
.container .content .left-side {
width: 25%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 15px;
position: relative;
}
.content .left-side::before {
content: '';
position: absolute;
height: 70%;
width: 2px;
right: -15px;
top: 50%;
transform: translateY(-50%);
background: #afafb6;
}
.content .left-side .details {
margin: 14px;
text-align: center;
}
.content .left-side .details i {
font-size: 30px;
color: #067393;
margin-bottom: 10px;
}
.content .left-side .details .topic {
font-size: 18px;
font-weight: 500;
}
.content .left-side .details .text-one,
.content .left-side .details .text-two {
font-size: 14px;
color: #afafb6;
}
.container .content .right-side {
width: 75%;
margin-left: 75px;
}
.content .right-side .topic-text {
font-size: 23px;
font-weight: 600;
color: #bc0456;
}
.right-side .input-box {
height: 50px;
width: 100%;
margin: 12px 0;
}
.right-side .input-box input,
.right-side .input-box textarea {
height: 100%;
width: 100%;
border: none;
outline: none;
font-size: 16px;
background: #F0F1F8;
border-radius: 6px;
padding: 0 15px;
resize: none;
}
.right-side .message-box {
min-height: 110px;
}
.right-side .input-box textarea {
padding-top: 6px;
}
.right-side .button {
display: inline-block;
margin-top: 12px;
}
.right-side .button input[type="button"] {
color: #fff;
font-size: 18px;
outline: none;
border: none;
padding: 8px 16px;
border-radius: 6px;
background: #067393;
cursor: pointer;
transition: all 0.3s ease;
}
.button input[type="button"]:hover {
background: #bc0456;
}
#media (max-width: 950px) {
.container {
width: 90%;
padding: 30px 40px 40px 35px;
}
.container .content .right-side {
width: 75%;
margin-left: 55px;
}
}
#media (max-width: 820px) {
.container {
margin: 40px 0;
height: 100%;
}
.container .content {
flex-direction: column-reverse;
}
.container .content .left-side {
width: 100%;
flex-direction: row;
margin-top: 40px;
justify-content: center;
flex-wrap: wrap;
}
.container .content .left-side::before {
display: none;
}
.container .content .right-side {
width: 100%;
margin-left: 0;
}
}
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" />
</head>
<body>
<header>
<section class="header">
<div class="header_content">
<div class="logo_container">
<a href="index.html">
<img alt="ArtUcii logo" class="logo" src="images/Artucii_logo.png">
</a>
</div>
<ul class="navigation">
<li>Home</li>
<li>Portfolio</li>
<li>About ME
<li>Contact</li>
</ul>
</div>
</section>
</header>
<div class="container">
<div class="content">
<div class="left-side">
<div class="address details">
<i class="fas fa-map-marker-alt"></i>
<div class="topic">Address</div>
<div class="text-one">Los Angles, CA</div>
<div class="text-two">Austin,TX</div>
</div>
<div class="phone details">
<i class="fas fa-phone-alt"></i>
<div class="topic">Phone</div>
<div class="text-one">(512) xxx-xxxx</div>
<div class="text-two">+</div>
</div>
<div class="email details">
<i class="fas fa-envelope"></i>
<div class="topic">Email</div>
<div class="text-one">artuciidesign#gmail.com</div>
<div class="text-two">alexandria.brown3#snhu.com</div>
</div>
</div>
<div class="right-side">
<div class="topic-text">Send me a message!</div>
<br>
<p>Any questions or ideas, just fill out the form below and I'll be happy to help.</p>
<form action="#">
<div class="input-box">
<input type="text" placeholder="Enter your name">
</div>
<div class="input-box">
<input type="text" placeholder="Enter your email">
</div>
<div class="input-box message-box">
</div>
<div class="button">
<input type="button" value="Send Now">
</div>
</form>
</div>
</div>
</div>
</body>
</html>
The problem occurs from the body. You assign to flex. I removed it and create a new div which wrappend the container. If you want reduce the width in the navbar you have to wrapped to another div and center it.
/* About ME */
/* Google Font CDN Link */
/* Header */
.header {
width: 100%;
height: 50px;
display: block;
background-color: #61d1e2; /* For browsers that do not support gradients */
background-image: linear-gradient(#e7bddc, #61d1e2);
}
.header_content {
width: 100%;
height: 100%;
display: block;
margin: 0 auto;
background-color: #61d1e2; /* For browsers that do not support gradients */
background-image: linear-gradient(#e7bddc, #61d1e2);
}
.logo_container {
height: 100%;
display: table;
float: left;
border: none;
}
.logo {
max-height: 50px;
display: table-cell;
vertical-align: middle;
}
/* Navigation */
.navigation {
float: right;
height: 100%;
margin: 0;
}
.navigation li {
float: left;
height: 100%;
display: table-cell;
padding: 15px 20px;
position: relative;
box-sizing: border-box;
text-decoration: none;
}
a:hover {
color: #bc0456 !important;
}
.navigation li a {
display: inline-block;
vertical-align: middle;
height: 100%;
color:#067393;
font-family: Kapelka New;
text-decoration: none !important;
}
.sub_menu1 {
display: none;
}
.navigation li:hover .sub_menu1 {
display: block;
position: absolute;
background: black;
top: 100%;
}
.navigation li:hover .sub_menu1 ul {
display: inline-block;
margin: 0%;
padding: 0%;
text-align: center;
}
.navigation li:hover .sub_menu1 ul li {
padding: 5px;
}
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#200;300;400;500;600;700&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins" , sans-serif;
}
body{
min-height: 100vh;
width: 100%;
background: #f99a61;
}
.wrapper {
display: flex;
align-items: center;
justify-content: center;
}
.container{
width: 85%;
background: #fff;
border-radius: 6px;
padding: 20px 60px 30px 40px;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}
.container .content{
display: flex;
align-items: center;
justify-content: space-between;
}
.container .content .left-side{
width: 25%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 15px;
position: relative;
}
.content .left-side::before{
content: '';
position: absolute;
height: 70%;
width: 2px;
right: -15px;
top: 50%;
transform: translateY(-50%);
background: #afafb6;
}
.content .left-side .details{
margin: 14px;
text-align: center;
}
.content .left-side .details i{
font-size: 30px;
color: #067393;
margin-bottom: 10px;
}
.content .left-side .details .topic{
font-size: 18px;
font-weight: 500;
}
.content .left-side .details .text-one,
.content .left-side .details .text-two{
font-size: 14px;
color: #afafb6;
}
.container .content .right-side{
width: 75%;
margin-left: 75px;
}
.content .right-side .topic-text{
font-size: 23px;
font-weight: 600;
color: #bc0456;
}
.right-side .input-box{
height: 50px;
width: 100%;
margin: 12px 0;
}
.right-side .input-box input,
.right-side .input-box textarea{
height: 100%;
width: 100%;
border: none;
outline: none;
font-size: 16px;
background: #F0F1F8;
border-radius: 6px;
padding: 0 15px;
resize: none;
}
.right-side .message-box{
min-height: 110px;
}
.right-side .input-box textarea{
padding-top: 6px;
}
.right-side .button{
display: inline-block;
margin-top: 12px;
}
.right-side .button input[type="button"]{
color: #fff;
font-size: 18px;
outline: none;
border: none;
padding: 8px 16px;
border-radius: 6px;
background: #067393;
cursor: pointer;
transition: all 0.3s ease;
}
.button input[type="button"]:hover{
background: #bc0456;
}
#media (max-width: 950px) {
.container{
width: 90%;
padding: 30px 40px 40px 35px ;
}
.container .content .right-side{
width: 75%;
margin-left: 55px;
}
}
#media (max-width: 820px) {
.container{
margin: 40px 0;
height: 100%;
}
.container .content{
flex-direction: column-reverse;
}
.container .content .left-side{
width: 100%;
flex-direction: row;
margin-top: 40px;
justify-content: center;
flex-wrap: wrap;
}
.container .content .left-side::before{
display: none;
}
.container .content .right-side{
width: 100%;
margin-left: 0;
}
}
<!DOCTYPE html>
<!-- Created By CodingLab - www.codinglabweb.com -->
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<!-- <title> Responsive Contact Us Form | CodingLab </title>
<link rel="stylesheet" href="style.css">
<!-- Fontawesome CDN Link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css"/>
<link href="css/stylesheet2.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<header class="header">
<div class="header_content">
<div class="logo_container">
<a href="index.html">
<img alt="ArtUcii logo" class="logo" src="images/Artucii_logo.png">
</a>
</div>
<ul class="navigation">
<li>Home</li>
<li>Portfolio</li>
<li>About ME
<li>Contact</li>
</ul>
</div>
</header>
<div class="wrapper">
<div class="container">
<div class="content">
<div class="left-side">
<div class="address details">
<i class="fas fa-map-marker-alt"></i>
<div class="topic">Address</div>
<div class="text-one">Los Angles, CA</div>
<div class="text-two">Austin,TX</div>
</div>
<div class="phone details">
<i class="fas fa-phone-alt"></i>
<div class="topic">Phone</div>
<div class="text-one">(512) xxx-xxxx</div>
<div class="text-two">+</div>
</div>
<div class="email details">
<i class="fas fa-envelope"></i>
<div class="topic">Email</div>
<div class="text-one">artuciidesign#gmail.com</div>
<div class="text-two">alexandria.brown3#snhu.com</div>
</div>
</div>
<div class="right-side">
<div class="topic-text">Send me a message!</div>
<br>
<p>Any questions or ideas, just fill out the form below and I'll be happy to help.</p>
<form action="#">
<div class="input-box">
<input type="text" placeholder="Enter your name">
</div>
<div class="input-box">
<input type="text" placeholder="Enter your email">
</div>
<div class="input-box message-box">
</div>
<div class="button">
<input type="button" value="Send Now" >
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
I'm trying to do a basic nav-bar. This nav bar contains a "search" button.
My goal is to make a hover in the search button that makes appear an input (and moves the button to the left) for the user to search anything he wants.
The thing is: I need to make the search button move to the left when I hover the input too, and I'm not figuring it out.
And as you see with that code, the item bugs.
Here's the code:
/*----------NAV BAR----------*/
body {
margin: 0;
font-family: 'Poppins', sans-serif;
font-weight: 300;
}
.nav-backgc {
height: 140px;
position: fixed;
width: 100%;
transition: 0.4s;
z-index: 9;
backdrop-filter: blur(1rem);
background-color: #DAA520;
}
.container-nav {
width: 80%;
margin-left: 10%;
position: fixed;
z-index: inherit 9;
}
.logonav {
max-width: 65px;
padding: 10px 0px 2px 0px;
position: relative;
float: left;
margin-top: -5px;
display: none;
}
.logo {
max-width: 65px;
padding: 10px 0px 2px 0px;
}
nav {
width: 100%;
padding-bottom: 2px;
}
.navbar ul {
padding: 0;
list-style: none;
}
.navbar li {
display: inline-block;
margin: 0px 25px;
position: relative;
}
.navcarrito span {
display: none;
}
.navbar a {
text-decoration: none;
color: #fff;
}
.navbar a {
color: #fff;
}
.barra {
margin-top: 27px;
}
hr {
opacity: 20%
}
.navcarrito.login-carrito {
display: none;
font-size: 18px;
}
.navcarrito {
display: flex;
float: right;
position: fixed;
right: 20%;
margin-top: -35px;
transition: 0.3s;
}
.navlogin {
float: right;
display: flex;
position: fixed;
right: 1.5%;
margin-top: -35px;
transition: 0.3s;
}
.navlogin {
float: right;
position: fixed;
right: 1.5%;
margin-top: -35px;
transition: 0.3s;
}
.nav-arriba {
padding-top: 50px;
width: 100%;
}
.nav-arriba a {
text-decoration: none;
}
.nav-arriba ul {
padding: 0;
list-style: none;
}
.nav-arriba li {
display: inline-block;
margin: 0px 25px;
position: relative;
}
.search {
transition: 0.3s;
}
.search:hover {
margin-right: 100px;
}
.searchBuscador {
display: none;
position: absolute;
}
input:focus:hover {
margin-right: 100px;
}
.search:hover~.searchBuscador {
display: inline-block;
}
/* ==========================================================================
DROPDOWN MENU
========================================================================== */
.dropdownMenu {
position: absolute;
display: none;
width: 500px;
background-color: #fff;
border-radius: 7px;
justify-content: space-evenly;
flex-wrap: wrap;
box-shadow: 2px 2px rgba(163, 163, 163, 0.295);
}
.dropdownBoton:hover>.dropdownMenu {
display: flex;
}
.dropdownMenu a {
display: flex;
flex-direction: column;
width: 35%;
color: black;
border-radius: 5px;
margin-block-start: 0.5em;
height: 100px;
}
.dropdownMenu a h3 {
margin-block-start: 16px;
margin-block-end: -9.5px;
}
/* ==========================================================================
RESOLUCION 1200-1600
========================================================================== */
#media (min-width: 1024px) and (max-width: 1600px) {
.navlogin li a {
display: none;
}
.navcarrito span {
display: inline-block;
}
.navcarrito {
right: 6%;
}
}
#media (min-width: 1200px) and (max-width: 1300px) {
.navcarrito li {
margin: 0px 15px;
}
}
/*****RESOLUCION 1024*****/
#media (min-width:1024px) {}
/*****RESOLUCION 768*****/
#media (min-width:768px) {}
/*****RESOLUCION 480*****/
#media (min-width:480px) {}
/*****RESOLUCION 320*****/
#media (min-width:320px) {}
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<link href="/stylesheets/nav.css" rel="stylesheet">
<script src="https://kit.fontawesome.com/8431526c8f.js" crossorigin="anonymous"></script>
<header>
<div id="navbar" class="nav-backgc">
<div class="container-nav">
<div class="navbar">
<center>
<img src="/images/logo2.png" alt="BierClub" class="logo">
<ul id="navcarrito" class="navcarrito">
<li class="search"><i class="fas fa-search"></i></li>
<li><i class="fas fa-shopping-cart"></i></li>
<div class="searchBuscador">
<input type="text"></input>
</div>
<span>
<li class="login-carrito"><i class="fas fa-sign-in-alt"></i></li>
</span>
</ul><strong>
<ul id="navlogin" class="navlogin">
<li><i class="fas fa-sign-in-alt"></i> Iniciar sesion</li>
</ul>
</strong>
<hr><img src="/images/logo2.png" alt="BierClub" class="logonav" id="logonav">
<nav>
<ul class="barra"><strong>
<li class="dropdownBoton">Productos
<div class="dropdownMenu">
<a href="#">
<h3>Lupuladas</h3>
<h6>Lorem ipsum dolor sit amet consectetur.</h6>
</a>
<a href="#">
<h3>No lupuladas</h3>
<h6>Lorem ipsum dolor sit amet consectetur.</h6>
</a>
</div>
</li>
<li>Promociones</li>
<li>Suscribete</li>
<li>Envio</li>
<li>¿Quienes Somos?</li>
</ul></strong>
</nav>
</center>
</div>
</div>
</div>
</header>
Answer:
Onclick javascript statement added...
function search(){
document.getElementById("search-bar").style = "display:block;";
document.getElementById("search-bar").focus() ;
}
/*----------NAV BAR----------*/
body{
margin: 0;
font-family: 'Poppins', sans-serif;
font-weight: 300;
}
.nav-backgc{
height:140px;
position: fixed;
width: 100%;
transition: 0.4s;
z-index: 9;
backdrop-filter: blur(1rem);
background-color: #DAA520;
}
.container-nav{
width : 80%;
margin-left:10%;
position:fixed;
z-index:inherit 9;
}
.logonav{
max-width: 65px;
padding: 10px 0px 2px 0px;
position: relative;
float:left;
margin-top: -5px;
display:none;
}
.logo{
max-width: 65px;
padding: 10px 0px 2px 0px;
}
nav{
width: 100%;
padding-bottom: 2px;
}
.navbar ul{
padding: 0;
list-style: none;
}
.navbar li{
display: inline-block;
margin: 0px 25px;
position: relative;
}
.navcarrito span{
display: none;
}
.navbar a{
text-decoration: none;
color: #fff;
}
.navbar a{
color: #fff;
}
.barra{
margin-top: 27px;
}
hr{
opacity:20%
}
.navcarrito.login-carrito{
display: none;
font-size: 18px;
}
.navcarrito{
display: flex;
float:right;
position: fixed;
right: 20%;
margin-top: -35px;
transition: 0.3s;
}
.navlogin{
float:right;
display:flex;
position:fixed;
right: 1.5%;
margin-top: -35px;
transition: 0.3s;
}
.navlogin{
float:right;
position:fixed;
right: 1.5%;
margin-top: -35px;
transition: 0.3s;
}
.nav-arriba{
padding-top: 50px;
width: 100%;
}
.nav-arriba a{
text-decoration: none;
}
.nav-arriba ul{
padding: 0;
list-style: none;
}
.nav-arriba li{
display: inline-block;
margin: 0px 25px;
position: relative;
}
.search{
transition: 0.3s;
}
.search:hover{
/* margin-right: 100px; */
}
.searchBuscador1{
display:block;
position:absolute;
}
#search-bar{
display:none;
}
input:focus:hover{
/* margin-right: 100px;*/
}
.search:focus .searchBuscador{
/* display: inline-block;*/
display:block;
}
/* ==========================================================================
DROPDOWN MENU
========================================================================== */
.dropdownMenu{
position: absolute;
display: none;
width: 500px;
background-color: #fff;
border-radius: 7px;
justify-content: space-evenly;
flex-wrap: wrap;
box-shadow: 2px 2px rgba(163, 163, 163, 0.295);
}
.dropdownBoton:hover > .dropdownMenu{
display:flex;
}
.dropdownMenu a{
display: flex;
flex-direction: column;
width: 35%;
color: black;
border-radius: 5px;
margin-block-start: 0.5em;
height: 100px;
}
.dropdownMenu a h3{
margin-block-start: 16px;
margin-block-end: -9.5px;
}
/* ==========================================================================
RESOLUCION 1200-1600
========================================================================== */
#media (min-width: 1024px) and (max-width: 1600px) {
.navlogin li a{
display:none;
}
.navcarrito span{
display: inline-block;
}
.navcarrito{
right: 6%;
}
}
#media (min-width: 1200px) and (max-width: 1300px) {
.navcarrito li{
margin: 0px 15px;
}
}
/*****RESOLUCION 1024*****/
#media (min-width:1024px) {
}
/*****RESOLUCION 768*****/
#media (min-width:768px) {
}
/*****RESOLUCION 480*****/
#media (min-width:480px) {
}
/*****RESOLUCION 320*****/
#media (min-width:320px) {
}
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>navbar</title>
<link rel="icon" href="/images/faviconLogo.ico"/>
<script type="text/javascript" src="/js/speak.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<link href="/stylesheets/nav.css" rel="stylesheet">
<script src="https://kit.fontawesome.com/8431526c8f.js" crossorigin="anonymous"></script>
</head>
<style>
/**Style Sheet - CSS **/
</style>
<body>
<header>
<div id="navbar" class="nav-backgc">
<div class ="container-nav">
<div class ="navbar">
<center>
<img src="/images/logo2.png" alt="BierClub" class="logo">
<ul id ="navcarrito" class="navcarrito">
<li class="search"><a href="#"><i class="fas fa-search" onclick="search()" ></i><!/a></li>
<div class="searchBuscador">
<input type="text" onblur="this.style='display:none;'"
id="search-bar"></input>
</div>
<li><i class="fas fa-shopping-cart"></i></li>
<span><li class="login-carrito"><i class="fas fa-sign-in-alt"></i></li></span>
</ul><strong>
<ul id ="navlogin" class="navlogin">
<li><i class="fas fa-sign-in-alt"></i> Iniciar sesion</li>
</ul></strong>
<hr><img src="/images/logo2.png" alt="BierClub" class="logonav" id="logonav">
<nav>
<ul class="barra"><strong>
<li class="dropdownBoton">Productos
<div class="dropdownMenu">
<a href="#">
<h3>Lupuladas</h3>
<h6>Lorem ipsum dolor sit amet consectetur.</h6>
</a>
<a href="#">
<h3>No lupuladas</h3>
<h6>Lorem ipsum dolor sit amet consectetur.</h6>
</a>
</div>
</li>
<li>Promociones</li>
<li>Suscribete</li>
<li>Envio</li>
<li>¿Quienes Somos?</li>
</ul></strong>
</nav>
</center>
</div>
</div>
</div>
</header>
<script>
/** Javascript **/
</script>
</body>
</html>
Hover Effect..
/*----------NAV BAR----------*/
body{
margin: 0;
font-family: 'Poppins', sans-serif;
font-weight: 300;
}
.nav-backgc{
height:140px;
position: fixed;
width: 100%;
transition: 0.4s;
z-index: 9;
backdrop-filter: blur(1rem);
background-color: #DAA520;
}
.container-nav{
width : 80%;
margin-left:10%;
position:fixed;
z-index:inherit 9;
}
.logonav{
max-width: 65px;
padding: 10px 0px 2px 0px;
position: relative;
float:left;
margin-top: -5px;
display:none;
}
.logo{
max-width: 65px;
padding: 10px 0px 2px 0px;
}
nav{
width: 100%;
padding-bottom: 2px;
}
.navbar ul{
padding: 0;
list-style: none;
}
.navbar li{
display: inline-block;
margin: 0px 25px;
position: relative;
}
.navcarrito span{
display: none;
}
.navbar a{
text-decoration: none;
color: #fff;
}
.navbar a{
color: #fff;
}
.barra{
margin-top: 27px;
}
hr{
opacity:20%
}
.navcarrito.login-carrito{
display: none;
font-size: 18px;
}
.navcarrito{
display: flex;
float:right;
position: fixed;
right: 20%;
margin-top: -35px;
transition: 0.3s;
}
.navlogin{
float:right;
display:flex;
position:fixed;
right: 1.5%;
margin-top: -35px;
transition: 0.3s;
}
.navlogin{
float:right;
position:fixed;
right: 1.5%;
margin-top: -35px;
transition: 0.3s;
}
.nav-arriba{
padding-top: 50px;
width: 100%;
}
.nav-arriba a{
text-decoration: none;
}
.nav-arriba ul{
padding: 0;
list-style: none;
}
.nav-arriba li{
display: inline-block;
margin: 0px 25px;
position: relative;
}
.search{
transition: 0.3s;
}
.search:hover{
/* margin-right: 100px; */
}
.searchBuscador{
display:none;/*
position:absolute;*/
}
input:focus{
/* margin-right: 100px;*/
display:block;
}
.search:hover ~ .searchBuscador{
/* display: inline-block;*/
display:block;
}
/* ==========================================================================
DROPDOWN MENU
========================================================================== */
.dropdownMenu{
position: absolute;
display: none;
width: 500px;
background-color: #fff;
border-radius: 7px;
justify-content: space-evenly;
flex-wrap: wrap;
box-shadow: 2px 2px rgba(163, 163, 163, 0.295);
}
.dropdownBoton:hover > .dropdownMenu{
display:flex;
}
.dropdownMenu a{
display: flex;
flex-direction: column;
width: 35%;
color: black;
border-radius: 5px;
margin-block-start: 0.5em;
height: 100px;
}
.dropdownMenu a h3{
margin-block-start: 16px;
margin-block-end: -9.5px;
}
/* ==========================================================================
RESOLUCION 1200-1600
========================================================================== */
#media (min-width: 1024px) and (max-width: 1600px) {
.navlogin li a{
display:none;
}
.navcarrito span{
display: inline-block;
}
.navcarrito{
right: 6%;
}
}
#media (min-width: 1200px) and (max-width: 1300px) {
.navcarrito li{
margin: 0px 15px;
}
}
/*****RESOLUCION 1024*****/
#media (min-width:1024px) {
}
/*****RESOLUCION 768*****/
#media (min-width:768px) {
}
/*****RESOLUCION 480*****/
#media (min-width:480px) {
}
/*****RESOLUCION 320*****/
#media (min-width:320px) {
}
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>navbar</title>
<link rel="icon" href="/images/faviconLogo.ico"/>
<script type="text/javascript" src="/js/speak.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<link href="/stylesheets/nav.css" rel="stylesheet">
<script src="https://kit.fontawesome.com/8431526c8f.js" crossorigin="anonymous"></script>
</head>
<body>
<header>
<div id="navbar" class="nav-backgc">
<div class ="container-nav">
<div class ="navbar">
<center>
<img src="/images/logo2.png" alt="BierClub" class="logo">
<ul id ="navcarrito" class="navcarrito">
<li class="search"><i class="fas fa-search" ></i></li>
<div class="searchBuscador">
<input type="txt" >
</div>
<li><i class="fas fa-shopping-cart"></i></li>
<span><li class="login-carrito"><i class="fas fa-sign-in-alt"></i></li></span>
</ul><strong>
<ul id ="navlogin" class="navlogin">
<li><i class="fas fa-sign-in-alt"></i> Iniciar sesion</li>
</ul></strong>
<hr><img src="/images/logo2.png" alt="BierClub" class="logonav" id="logonav">
<nav>
<ul class="barra"><strong>
<li class="dropdownBoton">Productos
<div class="dropdownMenu">
<a href="#">
<h3>Lupuladas</h3>
<h6>Lorem ipsum dolor sit amet consectetur.</h6>
</a>
<a href="#">
<h3>No lupuladas</h3>
<h6>Lorem ipsum dolor sit amet consectetur.</h6>
</a>
</div>
</li>
<li>Promociones</li>
<li>Suscribete</li>
<li>Envio</li>
<li>¿Quienes Somos?</li>
</ul></strong>
</nav>
</center>
</div>
</div>
</div>
</header>
</body>
</html>
I'm creating footer for my website. I encounter problems that seem to be banal, maybe not. Inside the 'footer' element is a list of 'ul', inside them 'li' with links to social media. The Chrome browser does not display these elements, similarly to Opera and Mozilla. Where is the problem? I am running out of ideas.
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
body {
font-family: 'Lato', 'Josefin Sans', sans-serif;
font-size: 0;
}
.navbar {
font-size: 18px;
width: 100%;
position: fixed;
background-color: rgba(0, 0, 0, 0.8);
border: 1px solid rgba(0, 0, 0, 0.2);
padding-bottom: 10px;
}
.main-nav {
list-style-type: none;
}
.nav-links,
.logo {
text-decoration: none;
color: rgba(255, 255, 255, 0.7);
vertical-align: middle;
}
.main-nav li {
text-align: center;
margin: 15px auto;
}
.logo {
display: inline-block;
font-size: 22px;
margin-top: 10px;
margin-left: 20px;
}
.navbar-toggle {
position: absolute;
top: 10px;
right: 20px;
cursor: pointer;
color: rgba(255, 255, 255, 0.8);
font-size: 24px;
}
.main-nav {
list-style-type: none;
display: none;
}
.active {
display: block;
}
.background-image img {
height: 100%;
width: 100%;
}
.container {
display: flex;
height: 250px;
}
.column-left {
width: 33.333%;
background: #f2f2f2;
border: 1px solid #e6e6e6;
}
.column-center {
width: 33.333%;
background: #f2f2f2;
border: 1px solid #e6e6e6;
}
.column-right {
width: 33.333%;
background: #f2f2f2;
border: 1px solid #e6e6e6;
}
.container .column-left {
text-align: center;
padding-top: 20px;
font-size: 20px;
}
h2 {
font-size: 23px;
padding: 15px;
}
p {
font-size: 20px;
padding: 15px;
}
.container .column-center {
text-align: center;
padding-top: 20px;
font-size: 20px;
}
.container .column-right {
text-align: center;
padding-top: 20px;
font-size: 20px;
}
#media screen and (min-width: 600px) {
.navbar {
display: flex;
justify-content: space-between;
padding-bottom: 0;
height: 70px;
align-items: center;
}
.main-nav {
display: flex;
margin-right: 30px;
flex-direction: row;
justify-content: flex-end;
}
.main-nav li {
margin: 0;
}
.nav-links {
margin-left: 40px;
}
.logo {
margin-top: 0;
}
.navbar-toggle {
display: none;
}
.logo:hover,
.nav-links:hover {
color: rgba(255, 255, 255, 1);
}
}
#media screen and (max-width: 599px) {
h2.title {
font-size: 15px;
}
p {
font-size: 13px;
}
}
<link href="https://fonts.googleapis.com/css?family=Lato&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/8a84b6b9df.js"></script>
<div>
<nav class="navbar">
<span class="navbar-toggle" id="js-navbar-toggle">
<i class="fas fa-bars"></i>
</span>
<img src="img/developer.png" alt="Sebastian Falba" width="50">
<ul class="main-nav" id="js-menu">
<li>
Home
</li>
<li>
About me
</li>
<li>
Projects
</li>
<li>
Contact
</li>
</ul>
</nav>
</div>
<div class="background-image">
<img src="img/responsive.jpg" alt="web development">
</div>
<div class="container">
<div class="column-left"><i class="fas fa-keyboard fa-3x"></i>
<h2 class="title">Modern design</h2>
<p class="description">Fantastic Clean Website Designs</p>
</div>
<div class="column-center"><i class="far fa-window-maximize fa-3x"></i>
<h2 class="title">Responsive</h2>
<p class="description">Make your website mobile-friendly</p>
</div>
<div class="column-right"><i class="fas fa-laptop-code fa-3x"></i>
<h2 class="title">Quality code</h2>
<p class="description">Coding best practices are a set of my rules</p>
</div>
</div>
<footer>
<ul>
<li>Footer</li>
</ul>
</footer>
You set the font-size to 0 so the text has no height.
Since the text has no height, the <a> has no height, so the <li> has no height, so the <ul> has no height, to the <footer> has no height, so you can't see it.
I'm currently adding all media queries to a site and I'm stuck with some of the header elements that refuse to float properly when I resize below 480px to mobile-wide. I want my Logo to stretch across the page and all the other elements to float on top of each other. At the moment the phone/email are side by side and social media icons are stuck on the left and won't display inline across the page. I've tried all variants of display rules but they won't budge.
body {
font-family: "Merriweather Sans", sans-serif;
font-size: 16px;
line-height: 1.5;
color: #333333;
}
body {
margin: 0 auto 0 auto;
}
.container {
margin: auto;
max-width: 100%;
padding-left: 10px;
padding-right: 10px;
}
header {
background: #ffffff;
height: 100px;
top: 0;
z-index: 10;
}
.left-header {
background: white;
width: 50%;
float: left;
height: 100px;
}
.right-header {
background: white;
width: 50%;
float: right;
height: 50px;
}
.right-header-top {
background: white;
float: right;
width: 100%;
height: 100%;
margin-right: 100px;
}
.right-header-bottom {
background: white;
float: left;
width: 100%;
height: 100%;
}
#logo {
margin-left: 60px;
margin-top: 50px;
}
nav {
float: left;
font-weight: 400;
}
nav a {
color: #000000;
text-decoration: none;
display: inline-block;
margin-top: 15px;
margin-right: 25px;
font-size: 12px;
}
div#contact {
float: right;
margin-right: 20px;
}
div#contact img {
display: inline-block;
border: 10px;
margin: 20px;
width: 30px;
height: 30px;
}
div#contact p {
display: inline-block;
margin-top: 25px;
font-size: 10px;
}
.right-header-bottom i {
height: 10px;
width: 10px;
border: 15px;
float: left;
margin-top: 15px;
margin-right: 10px;
margin-left: 10px;
}
a {
color: #000000;
text-decoration: none;
}
a:hover {
color: #000000;
}
#media screen and (max-width: 1000px) {
div.container {
float: none;
margin: 0 20px 0 20px;
}
div.column {
float: none;
}
}
#media screen and (max-width: 480px) {
header {
float: none;
height: auto;
}
nav {
float: none;
text-align: center;
padding-bottom: 10px;
padding-top: 10px;
}
nav a {
display: block;
}
.right-header {
height: auto;
width: auto;
}
.right-header-top {
float: none;
}
.right-header-bottom {
float: none;
}
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<header>
<div class="left-header">
<img src="http://localhost:8888/wp-content/uploads/2017/07/Logo.png" alt="logo" id="logo" style="width:250px;height:30px;">
</div>
<div class="right-header">
<div class="right-header-top">
<div id="contact">
<img src="http://localhost:8888/wp-content/uploads/2017/07/phone.png">
<p>0113 220 5265</p>
<img src="http://localhost:8888/wp-content/uploads/2017/07/email.png">
<p>hello#featuremedia.co.uk</p>
</div>
</div>
<div class="right-header-bottom">
<nav>
HOME
PORTFOLIO
PRODUCTS
ABOUT
CONTACT
BLOG
</nav>
<i class="fa fa-facebook" aria-hidden="true"></i>
<i class="fa fa-twitter" aria-hidden="true"></i>
<i class="fa fa-instagram" aria-hidden="true"></i>
<i class="fa fa-youtube-play" aria-hidden="true"></i>
<i class="fa fa-linkedin" aria-hidden="true"></i>
</div>
</div>
</header>
Here's how it looks -
You've got a lot of floats to kill.
A few things to display block and some text to align enter.
body {
font-family: "Merriweather Sans", sans-serif;
font-size: 16px;
line-height: 1.5;
color: #333333;
}
body {
margin: 0 auto 0 auto;
}
.container {
margin: auto;
max-width: 100%;
padding-left: 10px;
padding-right: 10px;
}
header {
background: #ffffff;
height: 100px;
top: 0;
z-index: 10;
}
.left-header { background:white; width:50%; float:left; height: 100px; }
.right-header { background:white; width:50%; float:right; height: 50px; }
.right-header-top { background: white; float: right; width: 100%; height: 100%; margin-right: 100px; }
.right-header-bottom { background: white; float: left; width: 100%; height: 100%; }
#logo {
margin-left: 60px;
margin-top: 50px;
}
nav {
float: left;
font-weight: 400;
}
nav a {
color: #000000;
text-decoration: none;
display: inline-block;
margin-top: 15px;
margin-right: 25px;
font-size: 12px;
}
div#contact {
float: right;
margin-right: 20px;
}
div#contact img {
display: inline-block;
border: 10px;
margin: 20px;
width: 30px;
height: 30px;
}
div#contact p {
display: inline-block;
margin-top: 25px;
font-size: 10px;
}
.right-header-bottom i {
height: 10px;
width: 10px;
border: 15px;
float: left;
margin-top: 15px;
margin-right: 10px;
margin-left: 10px;
}
a {
color: #000000;
text-decoration: none;
}
a:hover {
color: #000000;
}
#media screen and (max-width: 1000px) {
div.container {
float: none;
margin: 0 20px 0 20px;
}
div.column {
float: none;
}
}
#media screen and (max-width: 480px) {
header {
float: none;
height: auto;
}
nav {
float: none;
text-align: center;
padding-bottom: 10px;
padding-top: 10px;
}
nav a {
display: block;
}
.right-header {
height: auto;
width: auto;
}
.right-header-top {
float: none;
}
.right-header-bottom {
float: none;
}
}
/* Added Styles */
.left-header {
display: block;
float: none;
width: 100%;
height: auto;
}
img#logo {
min-width: 100%;
margin: auto;
height: auto !important;
}
.right-header {
display: block;
float: none;
width: 100%;
height: auto;
}
div[class*="header"] {
display: block;
float: none;
width: 100%;
height: auto;
text-align: center;
}
div#contact {
float: none;
display: block;
width: 100%;
margin: auto;
text-align: center;
}
header {
height: auto;
}
body {
max-width: 500px;
border: 1px dashed #ccc;
min-height: 400px;
}
nav {
float: none;
width: 100%;
text-align: center;
}
.right-header-bottom i {
float: none;
}
/* Centered Nav, Email & Phone */
h1 {
text-align: center;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ddd;
margin-bottom: 0px;
margin-top: 100px;
}
h1 {
text-align: center;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ddd;
margin-bottom: 0px;
margin-top: 100px;
}
div#contact
> div img {
margin: auto;
}
div#contact
> div p {
margin: auto 10px;
line-height: 3em;
vertical-align: top;
}
div#contact
> div:first-of-type {
margin-bottom: 10px;
}
nav.block a {
display: block;
margin: 10px auto;
}
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<header>
<div class="left-header">
<img src="https://placehold.it/500x100" alt="logo" id="logo" style="width:250px;height:30px;">
</div>
<div class="right-header">
<div class="right-header-top">
<div id="contact">
<img src="https://placehold.it/50x50">
<p>0113 220 5265</p>
<img src="https://placehold.it/50x50">
<p>hello#featuremedia.co.uk</p>
</div>
</div>
<div class="right-header-bottom">
<nav>
HOME
PORTFOLIO
PRODUCTS
ABOUT
CONTACT
BLOG
</nav>
<i class="fa fa-facebook" aria-hidden="true"></i>
<i class="fa fa-twitter" aria-hidden="true"></i>
<i class="fa fa-instagram" aria-hidden="true"></i>
<i class="fa fa-youtube-play" aria-hidden="true"></i>
<i class="fa fa-linkedin" aria-hidden="true"></i>
</div>
</div>
</header>
</body>
<h1>Center Nav, Email & Phone</h1>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<header>
<div class="left-header">
<img src="https://placehold.it/500x100" alt="logo" id="logo">
</div>
<div class="right-header">
<div class="right-header-top">
<div id="contact">
<div>
<img src="https://placehold.it/50x50">
<p>0113 220 5265</p>
</div>
<div>
<img src="https://placehold.it/50x50">
<p>hello#featuremedia.co.uk</p>
</div>
</div>
</div>
<div class="right-header-bottom">
<nav class="block">
HOME
PORTFOLIO
PRODUCTS
ABOUT
CONTACT
BLOG
</nav>
<i class="fa fa-facebook" aria-hidden="true"></i>
<i class="fa fa-twitter" aria-hidden="true"></i>
<i class="fa fa-instagram" aria-hidden="true"></i>
<i class="fa fa-youtube-play" aria-hidden="true"></i>
<i class="fa fa-linkedin" aria-hidden="true"></i>
</div>
</div>
</header>
</body>
get rid of float: right on div#contact and change display: inline-block to display: block on nav a
-OR-
Use this CSS for your nav:
nav {
display: flex;
flex-direction: column;
}
nav a {
align-self: center;
}
And you still have to kill the float on the header.
Here is a useful fiddle I keep in my bookmarks for flexbox reference. It shows everything flexbox can do and makes it relatively easy to understand:
https://codepen.io/enxaneta/full/adLPwv