Why does my main context go over the header? - html

When I put in my header (i have already put in my context) it just puts the header underneath what the context is so you can't see the header.
I have already tried changing the padding and the other sizes but none work
https://jsfiddle.net/L30trdfn/1/This is the full code of my website
What should happen is that the description and avatar ECT should go under the navbar and fit

Change your CSS code Like this
.split {
width: 100%;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.col {
width:50%;
height:50%;
flex: 0 0 50%;
max-width: 50%;
padding-top: 50px;
overflow-x: hidden;
}
.black{background-color: #f5f5f5;}
.red{background-color: #f00;}
.centered {
text-align: center;
}
Corresponding html like this
<div class="split">
<div class="col black">
<div class="centered">
<img src="avatar1.png" alt="Avatar woman">
<h2>Fortnitewinner21</h2>
<p>Co-Owner of FSX/XP11 and is the Head Website devolper</p>
</div>
</div>
<div class="col red">
<div class="centered">
<img src="avatar2.png" alt="Avatar man">
<h2>MasterPilot</h2>
<p>Owner of FSX/XP11, He plays a big part in making the server run smoothley</p>
</div>
</div>
</div>
Change the img src according to your sources
{
font-family: Arial;
color: white;
}
* {
box-sizing: border-box;
}
body {
font-family: Arial;
padding: 10px;
background: #9099A2;
}
/* Header/Blog Title */
.header {
padding: 30px;
text-align: center;
color: white;
background: #6D7993;
}
.header h1 {
font-size: 50px;
}
/* Navbar container */
.navbar {
overflow: hidden;
background-color: #333;
font-family: Arial;
}
/* Links inside the navbar */
.navbar a {
float: left;
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* The dropdown container */
.dropdown {
float: left;
overflow: hidden;
}
/* Dropdown button */
.dropdown .dropbtn {
font-size: 16px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit; /* Important for vertical align on mobile phones */
margin: 0; /* Important for vertical align on mobile phones */
}
/* Add a red background color to navbar links on hover */
.navbar a:hover, .dropdown:hover .dropbtn {
background-color: indianred;
}
/* Dropdown content (hidden by default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
/* Add a grey background color to dropdown links on hover */
.dropdown-content a:hover {
background-color: #ddd;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Left column */
.leftcolumn {
float: left;
width: 75%;
}
/* Right column */
.rightcolumn {
float: left;
width: 25%;
background-color: #9099A2;
padding-left: 20px;
}
/* Fake image */
.fakeimg {
width: 100%;
}
/* Add a card effect for articles */
.card {
background-color: #D5D5D5;
padding: 20px;
margin-top: 20px;
box-shadow: 10px 10px 5px grey;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
.split {
width: 100%;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.col {
width:50%;
height:50%;
flex: 0 0 50%;
max-width: 50%;
padding-top: 50px;
overflow-x: hidden;
}
.black{background-color: #f5f5f5;}
.red{background-color: #f00;}
.centered {
text-align: center;
}
.centered img {
width: 150px;
border-radius: 50%;
}
<div class="header">
<h1>Welcome To FSX/XP11</h1>
<p>The Home of Flight Sim</p>
</div>
<div class="navbar">
Home
Gallery
<div class="dropdown">
<button class="dropbtn">Flight Planner
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
Flight Strips
Login
Register
</div>
</div>
</div>
<div class="split">
<div class="col black">
<div class="centered">
<img src="https://mail.google.com/mail/u/0?ui=2&ik=61315df9c6&attid=0.1&permmsgid=msg-f:1648390313577802256&th=16e04241b3ffea10&view=fimg&sz=s0-l75-ft&attbid=ANGjdJ8KWZCU9VW1k7NdYrm1ZoOE30R5M9Aoeokzr0KSjzE53wP1UvEZhJkACRl5RpKmGQs8W9TlWHfQME7CgcCB3TKlJ8lpdJYRU7dwfDfGHHHJvD455hCYQa4OAos&disp=emb&realattid=ii_k26gkdq90" alt="Avatar woman">
<h2>Fortnitewinner21</h2>
<p>Co-Owner of FSX/XP11 and is the Head Website devolper</p>
</div>
</div>
<div class="col red">
<div class="centered">
<img src="img_avatar.png" alt="Avatar man">
<h2>MasterPilot</h2>
<p>Owner of FSX/XP11, He plays a big part in making the server run smoothley</p>
</div>
</div>
</div>

Use the following CSS : \
you had given fixed position in .split and also used absolute position in .centered. I hope you got your answer
.split {
height: 50%;
width: 50%;
overflow-x: hidden;
padding-top: 50px;
}
.centered {
text-align: center;
}

Related

Navbar hover effect no longer works when I insert a image

I have a navbar inside a header tag. the header tag is flex. the navbar too. in the navbar i have three a tags with the display value inline-block; and a padding in the height and width. So far so good. When i hover the links the hover effect is shown over the whole height.
The problem: If I add an image to the first link, I can't make the image higher than 10 px because the padding affects the entire navbar height. What I do not want.
Question: How can I add the image to the link without it affecting the height of the navbar?
My code
body {
margin: 0;
padding: 0;
}
header {
display:flex;
justify-content: space-between;
align-items: center;
background: green;
position: fixed;
top: 0;
overflow: hidden;
width:100%;
}
.logo {
background: yellow;
display: flex;
align-items: center;
}
.navbar {
background-color: #333;
display: flex;
align-items: center;
}
.navbar a:not(:first-child) {
display: inline-block;
}
.navbar a {
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 12px;
}
.navbar a:hover {
background: #ddd;
color: black;
}
.flex {
gap:10px;
display: flex;
align-items: center;
font-size: 12px;
}
.main {
  margin-top: 180px;
color: color;
height:50vh;
background: black;
}
<div>
<header>
<div class="logo">
<img src="https://via.placeholder.com/40">Logo
</div>
<nav class="navbar">
<a href="#home">
<div class="flex">
<div>
<img src="https://via.placeholder.com/30">
</div>
<div>10000</div>
</div>
</a>
News
Contact
</nav>
</header>
<main class="main">
text
</main>
</div>
expected
body {
margin: 0;
pading: 0;
}
header {
display:flex;
justify-content: space-between;
align-items: center;
background: green;
position: fixed;
top: 0;
overflow: hidden;
width:100%;
}
.logo {
background: yellow;
display: flex;
align-items: center;
}
.navbar {
background-color: #333;
display: flex;
align-items: center;
}
.navbar a:not(:first-child) {
display: inline-block;
}
.navbar a {
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 12px;
}
.navbar a:hover {
background: #ddd;
color: black;
}
.flex {
gap:10px;
display: flex;
align-items: center;
font-size: 12px;
}
.main {
  margin-top: 180px; /* Add a top margin to avoid content overlay */
color: color;
height:50vh;
background: black;
}
<div>
<header>
<div class="logo">
<img src="https://via.placeholder.com/40">Logo
</div>
<nav class="navbar">
<a href="#home">
10000
</a>
News
Contact
</nav>
</header>
<main class="main">
xca
</main>
</div>
Use flex behavior to align and stretch instead of additional markups
In the code snippet below, I removed the extra markup in the first a element that contains the img. Instead, I made all a tags display: inline-flex and removed vertical padding in the first one. Then, using the parent nav element's align-items property, I ensured each a tag has the same full height for consistent hover effect.
body {
margin: 0;
padding: 0;
}
header {
display:flex;
justify-content: space-between;
align-items: center;
background: green;
position: fixed;
top: 0;
overflow: hidden;
width:100%;
}
.logo {
background: yellow;
display: flex;
align-items: center;
}
.navbar {
background-color: #333;
display: flex;
align-items: stretch;
}
.navbar a {
display: inline-flex;
}
.navbar a {
color: #f2f2f2;
justify-content: center;
align-items: center;
padding: 14px 16px;
text-decoration: none;
font-size: 12px;
}
.navbar a:first-of-type {
padding-top:0;
padding-bottom:0;
}
.navbar a:hover {
background: #ddd;
color: black;
}
.flex {
gap:10px;
display: flex;
align-items: center;
font-size: 12px;
}
.main {
  margin-top: 180px;
color: color;
height:50vh;
background: black;
}
<div>
<header>
<div class="logo">
<img src="https://via.placeholder.com/40">Logo
</div>
<nav class="navbar">
<a href="#home">
<img src="https://via.placeholder.com/30">
10000
</a>
News
Contact
</nav>
</header>
<main class="main">
text
</main>
</div>

My current header is does not work on mobile. How can I make my header responsive?

So, right now my header doesn´t look good on mobile. - The words overlap. They should remain in the same order... I tried to use line-height, which did not really change anything. Maybe you have some suggestions on how I can fix this problem. I am thankful for every suggestion!
[enter
.header {
width: 100%;
height: 7vh;
padding: 0 5%;
color: white;
font-size: larger;
background-color: black;
z-index:100;
position: sticky;
top: 0;
display: flex;
justify-content: space-between;
overflow: hidden;
line-height: 10px;
}
nav {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 4px 0;
}
nav ul li {
display: inline-block;
list-style: none;
margin: 10px 30px;
}
nav ul li a {
text-decoration: none;
color: white;
}
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
.Menü {
color: white;
text-decoration: none;
margin-left: 40px;
}
<div class="header" >
<nav>
<div>
<Button class="ImageButton"> <input class="ImageButton" type="image" src="/Images/Camellion Logo Website.png"></Button>
</div>
<ul>
<a class="Menü" href="/Galerie/Galerie.html">Galerie</a>
<a class="Menü" href="#Leistungen">Leistungen</a>
<a class="Menü" href="#Kontakt">Kontakt & Standort <i class="fa-solid fa-location-dot"></i></a>
</ul>
</nav>
</div>
There is a thing in CSS called media queries. With media queries you can write for example CSS that only takes effect if screen is certain size.
For example
#media only screen and (min-width: 360px) and (max-width: 800px) {
.header {
height: 60px;
}
}
Will set header height to 60px if the device that the page is opened on has screen width more then 360px and less then 800px.
Here is your code with couple adjustments
* { padding: 0; margin: 0; box-sizing: border-box; }
.header {
width: 100%;
padding: 0 20px;
color: white;
background-color: black;
position: sticky;
z-index:100;
top: 0;
}
.navigation {
margin: auto;
max-width: 1200px;
height: 80px;
display: flex;
align-items: center;
justify-content: space-between;
}
.menu-icon { /* CSS to just to simulate Icon */
height: 40px;
width: 40px;
background-color: white;
border-radius: 10px;
}
.menu {
display: flex;
align-items: center;
gap: 40px;
}
.menu-item {
color: white;
text-decoration: none;
white-space: nowrap; /* Will not let words to break to next line */
font-size: 20px;
font-weight: 700;
}
#media(max-width: 600px) {
.header { padding: 0 10px; }
.navigation { height: 60px; }
.menu { gap: 20px;}
.menu-item { font-size: 14px; }
}
#media(max-width: 400px) {
.menu { gap: 10px;}
.menu-item { font-size: 12px; }
}
<header class="header" >
<nav class="navigation">
<div class="menu-icon" title="Menu icon / hamburger icon"></div>
<div class="menu">
<a class="menu-item" href="/Galerie/Galerie.html">Galerie</a>
<a class="menu-item" href="#Leistungen">Leistungen</a>
<a class="menu-item" href="#Kontakt">Kontakt & Standort <i class="fa-solid fa-location-dot"></i></a>
</div>
</nav>
</header>
You can adjust your css even further. It's very popular to have icons with menu elements and on mobile view they become a bottom navigation bar with big icons and tiny text.
#media (max-width:767px) {
* {
box-sizing: border-box;
}
nav {
flex-direction: column;
}
nav .Menu {
margin-inline: 9px
}
}
good luck

How to hide Font-Awesome icons using CSS

I cannot seem to successfully use display: none !important; nor visibility: hidden; to hide the menu bars and close icons on a desktop. I have tried applying the code to other objects on my website as well (like the hero button) but it also didn't work on that.
You will however see the below code is only applied to the class for the close icon fa fa-times
HTML code:
<!--homepage header -->
<section class="header">
<nav>
<a href="index.html"> <!--add logo-->
<img src="" alt=""><!--add links-->
</a>
<div class="nav-links">
<div class="close-icon">
<!--menu close icon-->
<i class="fas fa-times"></i>
</div>
<ul>
<li>HOME</li><!--add links-->
<li>ABOUT</li><!--add links-->
<li>SOFTWARE</li><!--add links-->
<li>BLOG</li><!--add links-->
<li>CONTACT</li><!--add links-->
</ul>
</div>
<div class="menu-bars">
<!--menu icon-->
<i class="fas fa-bars"></i>
</div>
</nav>
CSS Code
#import url("https://kit.fontawesome.com/d68c6a086c.js")
*{
margin: 0;
padding: 0;
font-family: 'Poppins', sans-serif;
}
.header{
min-height: 100vh;
width: 100%;
/* change image below */
background-image: linear-gradient(rgba(4,9,30,0.7),rgba(4,9,30,0.7)),url(images/ft-870l-500x500.jpg);
background-position: center;
background-size: cover;
position: relative;
}
nav {
display: flex;
padding: 2% 6%;
justify-content: space-between;
align-items: center;
}
/* nav bar comapny logo*/
nav img{
width: 150px;
}
.nav-links{
flex: 1;
text-align: right;
}
/* list style */
.nav-links ul li {
list-style: none;
display: inline-block;
padding: 8px 12px;
position: relative;
}
/* each link */
.nav-links ul li a{
color: #fff;
text-decoration: none;
font-size: 13px;
}
.nav-links ul li::after{
content: '';
width: 100%;
height: 2px;
background: #f44336;
display: block;
margin: auto;
transition: 0.5s;
}
.nav-links ul li:hover::after{
width: 100%;
}
/* Hide Menu Items for Desktop */
.close-icon {
display: none !important;
visibility: hidden;
}
#media (max-width: 700px) {
.text-box h1{
font-size: 20px;
}
.nav-links ul li {
display: block;
}
.nav-links{
position: absolute;
background: #f44336;
height: 100vh;
width: 200px;
top: 0;
right: 0;
text-align: left;
z-index: 2;
}
.close-icon {
display: block;
color: #fff;
margins: 10px;
font-size: 22px;
cursor: pointer;
}
}
```
Please try
nav {
display: none;
/*padding: 2% 6%;
justify-content: space-between;
align-items: center;*/
}
#media (max-width: 700px) {
nav {
display: flex;
padding: 2% 6%;
justify-content: space-between;
align-items: center;
}
}
In head section where you added CSS file add
src="folder/stye.css?v=1.1"
Change v=1.1 to 1.2 or 1.3.1 etc.. whenever you make changes in CSS file.

getting images and Divs to be the same size with flexbox

I know this is probably a basic question but so far I have not been able to resolve it via google:
I want to have a navbar with an Image (a logo) and 3 links on its right. I want them all to have the same height and to be on the same height, a little bit like this:
however all I manage is to make it look like this:
#nav-bar {
position: fixed;
top: 0px;
width: 100%;
background: #b7b7b7;
border: 1px #4c4c4c solid;
padding: 1em;
}
#flex {
display: flex;
justify-content: start;
flex-wrap: wrap;
align-content: center;
}
img {
margin-top: 20px;
height: auto;
width: 15%;
}
.nav-link {
border: 1px solid #4c4c4c;
padding: 0.5em;
background-color: #b7b7b7;
color: black;
text-decoration: none;
}
<nav id="nav-bar">
<div id="flex">
<div><img src="https://i.pinimg.com/originals/58/c8/82/58c88275c1a3389a7260baf05bf34e9a.jpg" alt="violin logo" id="header-img"></div>
Products
Demo
Newsletter
</div>
</nav>
Maybe something like this:
#nav-bar {
position: fixed;
top: 0px;
width: 100%;
background: #b7b7b7;
border: 1px #4c4c4c solid;
padding: 1em;
}
#flex{
display: flex;
justify-content: space-between;
flex-wrap: wrap;
align-content: center;
}
img {
height: 50px;
width: auto;
}
.nav-links {
padding-right: 50px;
}
.nav-links .nav-link {
border: 1px solid #4c4c4c;
background-color: #b7b7b7;
color: black;
height: 50px;
display: inline-block;
text-decoration: none;
}
<nav id="nav-bar">
<div id="flex">
<img src="https://i.pinimg.com/originals/58/c8/82/58c88275c1a3389a7260baf05bf34e9a.jpg" alt="violin logo" id="header-img">
<div class="nav-links">
Products
Demo
Newsletter
</div>
</div>
</nav>
Just wrap links into a div, then set justify-content to 'space-between' and set the same height of both image and div with links. Hope it will help
You almost did it, the only thing you needed was basically to size the <div> around the <img> appropriately, so the <img> could just fill it:
#nav-bar {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #b7b7b7;
border: 1px #4c4c4c solid;
padding: 1em;
box-sizing: border-box; /* to exclude paddings&borders from width instead of adding them */
}
#flex{
display: flex;
justify-content: start;
align-items: stretch;
}
/* sizing the div with the img */
#flex > div {
width: 15%;
flex: 1 0 auto;
}
/* making the img filling this div */
img{
display: block;
width: 100%;
}
.nav-link{
border: 1px solid #4c4c4c;
padding: 0.5em;
background-color: #b7b7b7;
color: black;
text-decoration: none;
/* making links fill all the space, except some gaps between them */
flex: 1 1 auto;
margin-left: .5em;
/* centering the text in the links and making it responsive */
display: flex;
justify-content: center;
align-items: center;
font-size: calc(10px + 2vw);
}
<nav id="nav-bar">
<div id="flex">
<div>
<img src="https://i.pinimg.com/originals/58/c8/82/58c88275c1a3389a7260baf05bf34e9a.jpg" alt="violin logo" id="header-img">
</div>
Products
Demo
Newsletter
</div>
</nav>

Use CSS to make <a> full height of container <div> in footer

I have a footer with my navigation list contained. On hover, I would like to change the background color of the entire height of the div. As it is right now, only the background around the text is changing color. I have tried adding top and bottom padding to the text, but that's not having the right effect I'm looking for. Is there a way to make the <a> 100% of the height of the containing footer div?
Code below:
footer {
width: 100%;
background: #222;
color: #fff;
margin: 0;
position:fixed;
left:0px;
bottom:0px;
}
.footer-navigation {
width: 60%;
display: flex;
align-items: center;
}
.footer-links-holder {
width: 25%;
position: relative;
float: left;
margin: 0;
}
.footer-links-holder:hover {
background-color: #444;
transition: 0.5s;
}
<div class="footer-navigation">
<a class="footer-links-holder" href=""><h3>About Me</h3></a>
<a class="footer-links-holder" href=""><h3>Photography</h3></a>
<a class="footer-links-holder" href=""><h3>Portfolio</h3></a>
<a class="footer-links-holder" href=""><h3>Back to Top</h3></a>
</div>
Can anyone help? I've searched around and can't seem to find a simple solution.
EDIT: Here's a jfiddle link
https://jsfiddle.net/adamdrover/qe2d318L/
You need to make your footer-links "display: block" and then it will accept the width and height values.
.footer-links {
display: block;
margin: 0;
padding: 0;
list-style: none;
}
https://jsfiddle.net/qe2d318L/1/
I removed flex rules from .footer-contact and .footer-navigation, set them in the a instead, the link has become full height:
.footer-contact a,
.footer-navigation a {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
body {
background: #348F50; /* fallback for old browsers */
background: -webkit-linear-gradient(to left, #348F50 , #56B4D3); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to left, #348F50 , #56B4D3); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
margin: 0;
}
.clearfix:before, .clearfix:after {
clear: both;
}
footer {
width: 100%;
background: #222;
color: #fff;
margin: 0;
position:fixed;
left:0px;
bottom:0px;
}
.centered {
max-width: 1200px;
margin: 0 auto;
display: flex;
justify-content: space-between;
}
.footer-logo {
width: 20%;
}
.logo {
padding: 30px 20px 10px 20px;
max-width: 100%;
}
.footer-contact {
width: 15%;
/*align-items: center;
justify-content: center;
display: flex;*/
}
h3 {
margin: 0;
text-align: center;
}
.footer-contact a,
.footer-navigation a {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
.footer-navigation {
width: 60%;
/*display: flex;
align-items: center;*/
}
.footer-links-holder {
display: block;
width: 25%;
position: relative;
float: left;
margin: 0;
}
.footer-links-holder:hover {
background-color: #444;
transition: 0.5s;
}
.bottom-bar {
position: relative;
text-align: center;
font-size: .8em;
text-transform: uppercase;
background: #000;
padding: 15px 0;
}
<footer>
<!-- include slogan, contact me form on web, contact button on mobile. Social media links on right. -->
<div class="centered clearfix">
<div class="footer-logo">
<img class="logo" src="images/laptop-logo.png">
<div class="social">
<a href="https://www.facebook.com/" class="facebook">
</a>
<a href="https://twitter.com/" class="twitter">
</a>
<a href="https://www.linkedin.com/" class="linkedin">
</a>
</div>
</div>
<div class="footer-contact">
<h3>Contact Me</h3>
</div>
<div class="footer-navigation">
<a class="footer-links-holder" href=""><h3>About Me</h3></a>
<a class="footer-links-holder" href=""><h3>Photography</h3></a>
<a class="footer-links-holder" href=""><h3>Portfolio</h3></a>
<a class="footer-links-holder" href=""><h3>Back to Top</h3></a>
</div>
</div>
<div class="bottom-bar">
All Rights Reserved © 2016 | Privacy Policy
</div>
</footer>