Logo as link to Home-page - html

When I set the logo as a link, my menu moves to the right. When I inspect the menu, I see that I get an extra menu link to the left of the menu that is not visible otherwise and which leads to index.html Does anyone know what is the reason for this?
#logo {
height: 64px;
position: absolute;
left: 20px;
}
#menu {
display: flex;
flex-direction: row;
justify-content: center;
}
nav {
width: 100%;
background-color: #000000;
height: 64px;
display: flex;
flex-direction: row;
justify-content: center;
}
nav a {
text-align: center;
font-size: 25px;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
width: 100px;
color: white;
text-decoration: none;
transition: .9s;
}
nav a:hover {
background-color: orange;
transition: .9s;
}
<nav>
<div>
<img id="logo" src="https://via.placeholder.com/400x400.jpg" alt="">
</div>
<div id="menu">
<a href=index.html>Home</a>
<a href=index.html>About</a>
<a href=index.html>Contact</a>
</div>
</nav>

Change the css nav ato nav #menu a- Hope it fix the style.
#logo {
height: 64px;
position: absolute;
left: 20px;
}
#menu {
display: flex;
flex-direction: row;
justify-content: center;
}
nav {
width: 100%;
background-color: #000000;
height: 64px;
display: flex;
flex-direction: row;
justify-content: center;
}
nav #menu a {
text-align: center;
font-size: 25px;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
width: 100px;
color: white;
text-decoration: none;
transition: .9s;
}
nav a:hover {
background-color: orange;
transition: .9s;
}
<nav>
<div>
<img id="logo" src="https://via.placeholder.com/400x400.jpg" alt="">
</div>
<div id="menu">
<a href=index.html>Home</a>
<a href=index.html>About</a>
<a href=index.html>Contact</a>
</div>
</nav>

Related

Correct way to write in pure CSS two effects with .active and :hover

I'm styling some links with the following CSS code, I named the links with the className 'nav-menu-link':
.form-header {
background-color: var(--background-color);
display: flex;
align-items: center;
justify-content: center;
transition: all .3s ease-out;
position: relative;
width: 100%;
height: 100px;
}
.form-logo {
display: flex;
align-items: center;
cursor: pointer;
}
.image-logo-container {
box-sizing: border-box;
display: flex;
width: initial;
height: initial;
background: none;
opacity: 1;
border: 0;
margin: 0;
padding: 0;
max-width: 100%;
}
.image-logo-container img {
width: 250px;
height: 52px;
}
.nav-container {
display: flex;
align-items: center;
justify-content: space-between;
height: 100%;
}
.nav-menu {
display: flex;
font-size: 18px;
width: 380px;
align-items: center;
justify-content: space-between;
justify-content: center;
height: 100%;
margin: unset;
}
.nav-menu-item {
display: flex;
height: 100px;
align-items: center;
margin-left: 50px;
}
.nav-menu-link {
display: flex;
height: 100%;
align-items: center;
color: rgba(255, 255, 255, 0.5);
border-bottom: 2px solid transparent;
}
.nav-menu-link.active {
font-weight: bold;
color: var(--white);
}
.nav-menu-link:hover {
color: var(--white);
border-bottom: 2px solid var(--explorer);
transition: all .2s ease-in-out;
}
#media (min-width: 998px) {}
#media (min-width: 768px) {}
<header class="form-header">
<div class="nav-container">
<a class="form-logo" id="navbar-link-form-logo" href="/">
<div class="image-logo-container">
<img src="https://placekitten.com/250/52" alt="" />
</div>
</a>
<nav class="container">
<ul class="row nav-menu">
<li class="nav-menu-item">
<a class="nav-menu-link active" href="/">Home</a>
</li>
<li class="nav-menu-item">
<a class="nav-menu-link" href="/form">Form</a>
</li>
<li class="nav-menu-item">
<a class="nav-menu-link" href="/about">About</a>
</li>
</ul>
</nav>
<ul>
</ul>
</div>
</header>
I did two effects, one is when the link is active with the '.active' class, and another is when I hover over the link with the 'hover'.
In pure CSS, the correct way to do these two effects is as I wrote in the code above?

Min-height not expanding

So, I'm making a web portfolio as my project and I managed to find a problem. When I use min-height in my "About me" section, the section doesn't seem to adjust its height according to the content. It might be because I use float in my navbar, but I'm not too sure. I would appreciate if someone can help me. Thanks in advance.
This is my HTML and CSS code:
/* global */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Montserrat", sans-serif;
scroll-behavior: smooth;
}
a {
text-decoration: none;
}
/* animations */
#keyframes bounce {
0% {
transform: translateY(0px);
}
50% {
transform: translateY(15px);
}
100% {
transform: translateY(0px);
}
}
#keyframes appear {
0% {
opacity: 0;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#keyframes popup {
0% {
transform: translateY(200px);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}
/* Navbar */
header {
width: 100%;
height: 64px;
text-align: center;
background-color: #1a374d;
display: flex;
justify-content: space-between;
padding: 0 80px;
font-weight: bold;
position: fixed;
z-index: 1;
}
header li {
list-style: none;
font-weight: bold;
}
header a {
color: #b1d0e0;
}
header .brandLong {
width: auto;
height: 64px;
float: left;
display: flex;
align-items: center;
justify-content: center;
color: #b1d0e0;
}
header .brandShort {
width: auto;
height: 64px;
float: left;
display: none;
align-items: center;
justify-content: center;
color: #b1d0e0;
}
header .menu {
width: 50%;
min-width: 350px;
height: 100%;
float: right;
}
header .menu ul {
width: 100%;
height: inherit;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
}
header .menu li {
height: inherit;
display: flex;
align-items: center;
justify-content: center;
}
header .menu ul a {
width: 25%;
height: inherit;
display: inline-block;
transition: 0.3s;
font-weight: 400;
}
header .menu ul a:hover {
background-color: #b1d0e0;
color: #1a374d;
transition: 0.3s;
font-weight: 400;
}
header #menuToggle {
display: none;
}
header .menu-icon {
display: none;
}
/* Home Section */
.home {
min-height: 100vh;
}
.home .container {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-content: center;
}
.home .container img {
height: 100%;
animation: popup 0.8s ease-in-out;
}
.home .container .text {
display: flex;
flex-direction: column;
width: 50%;
height: 100%;
justify-content: center;
animation: appear 1.6s;
}
.home .container .text h1 {
font-size: 72px;
font-weight: bold;
line-height: auto;
}
.home .container .text h1 span {
color: #1a374d;
}
.home .container .text p {
font-size: 24px;
margin-top: 20px;
letter-spacing: 2px;
line-height: 35px;
}
.home .container .arrow {
font-size: 24px;
animation: bounce 2s ease-in-out infinite, appear 1.6s;
position: absolute;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
top: 77%;
margin: 0 0 0 35%;
width: 50%;
font-weight: bold;
}
.home .container .arrow a {
color: #1a374d;
}
.home .container .arrow a i {
font-size: 48px;
margin-top: 5px;
}
/* About */
.about {
min-height: 100vh;
background-color: #406882;
color: white;
padding: 0 80px;
}
.about .container {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
justify-items: center;
align-items: center;
}
.about .container h1 {
font-size: 64px;
text-align: center;
margin: 150px 0 100px 0;
}
.about .container h2 {
font-size: 40px;
}
.about .container h3 {
font-weight: 400;
margin-bottom: 50px;
font-size: 24px;
}
.about .container .aboutContainer {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.about .container .aboutContainer .desc1 {
width: 25%;
text-align: justify;
padding: 30px;
display: flex;
flex-direction: column;
height: 100%;
justify-content: space-evenly;
}
.about .container .aboutContainer .desc1 .top {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.about .container .aboutContainer .desc1 .top p {
line-height: 28px;
margin-top: 12px;
font-size: 20px;
font-weight: normal;
}
.about .container .aboutContainer .desc1 .bottom {
display: flex;
flex-direction: column;
align-items: center;
}
.about .container .aboutContainer .desc2 {
width: 30%;
background-image: url(asset/me2.jpg);
background-position: center;
background-size: cover;
background-repeat: no-repeat;
height: 700px;
border-radius: 40px;
margin: 20px;
}
.about .container .aboutContainer .desc2 img {
height: 100%;
}
.about .container .aboutContainer .desc3 {
width: 25%;
padding-left: 50px;
}
.about .container .aboutContainer .desc3 h2 {
margin-bottom: 12px;
}
.about .container .aboutContainer .desc3 ul li {
font-size: 20px;
margin-bottom: 8px;
margin-left: 20px;
}
/* social media */
.socialMedia {
display: flex;
margin-top: 12px;
justify-content: space-evenly;
width: 80%;
}
.socialMedia .instagram {
background-color: white;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
color: #dd2a7b;
border-radius: 50%;
transition: 0.5s;
font-size: 24px;
}
.socialMedia .email {
background-color: white;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
color: #ea4335;
border-radius: 50%;
transition: 0.5s;
font-size: 24px;
}
.socialMedia .email:hover {
background-color: #ea4335;
color: white;
transition: 0.5s;
}
.socialMedia .instagram:hover {
background-color: #dd2a7b;
color: white;
transition: 0.5s;
}
.socialMedia .linkedin {
background-color: white;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
color: #0077b5;
border-radius: 50%;
transition: 0.5s;
font-size: 24px;
}
.socialMedia .linkedin:hover {
background-color: #0077b5;
color: white;
transition: 0.5s;
}
.socialMedia .spotify {
background-color: white;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
color: #1ed761;
border-radius: 50%;
transition: 0.5s;
font-size: 24px;
}
.socialMedia .spotify:hover {
background-color: #1ed761;
color: white;
transition: 0.5s;
}
.socialMedia .github {
background-color: white;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
color: #171515;
border-radius: 50%;
transition: 0.5s;
font-size: 24px;
}
.socialMedia .github:hover {
background-color: #171515;
color: white;
transition: 0.5s;
}
/* Education background */
.about .container .edu {
margin: 50px 0 100px 0;
}
.about .container .edu h2 {
margin-bottom: 24px;
}
.about .container .edu table {
font-size: 24px;
border-collapse: collapse;
}
.about .container .edu table td {
padding: 15px;
padding-right: 100px;
}
.about .container .edu table thead {
background-color: #6998ab;
font-weight: 600;
}
.about .container .edu table tbody {
background-color: #b1d0e0;
}
.about .container .edu table tbody tr:nth-child(2) {
background-color: #a0c4d6;
}
/* Media Query */
#media screen and (max-width: 1200px) {
.home .container img {
display: none;
}
.home .container .text {
text-align: center;
display: flex;
flex-direction: column;
width: 80%;
height: 100%;
justify-content: center;
animation: appear 1.6s;
}
.home .container .arrow {
width: 100%;
margin: 0;
}
}
#media screen and (max-width: 768px) {
/* NavBar */
header {
display: block;
padding: 0;
}
.brandLong {
display: none;
}
.brandShort {
display: flex;
margin-left: 80px;
}
.menu {
width: 100%;
height: auto;
}
.menu ul {
display: block;
max-height: 0;
overflow: hidden;
transition: max-height 0.3s;
}
.menu ul a {
text-align: left;
width: 100%;
height: 50px;
background-color: #1a374d;
}
.menu-icon {
width: 200px;
height: inherit;
display: block;
position: absolute;
top: 18px;
right: 0;
color: #b1d0e0;
}
#menuToggle:checked~ul {
max-height: 350px;
}
.menu-icon i {
font-size: 1.7em;
}
.home .container .text h1 {
font-size: 48px;
}
}
#media screen and (max-width: 480px) {
.brandShort {
display: flex;
margin-left: 40px;
}
.menu-icon {
width: 100px;
}
.home .container .text h1 {
font-size: 36px;
}
.home .container .arrow a {
display: none;
}
}
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" crossorigin="anonymous">
<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=Montserrat:ital,wght#0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="landingPage.css">
<title>Christopher's Portfolio</title>
</head>
<body>
<!-- Nav Bar -->
<header>
<a href="#homeSection">
<figure class="brandLong">Christopher Nathanael Tessy</figure>
</a>
<a href="#homeSection">
<figure class="brandShort">Christopher N. T.</figure>
</a>
<nav class="menu">
<input type="checkbox" id="menuToggle">
<label for="menuToggle" class="menu-icon"><i class="fa fa-bars"></i></label>
<ul>
<a href="#homeSection">
<li>Home</li>
</a>
<a href="#aboutSection">
<li>About Me</li>
</a>
<a href="#">
<li>Portfolio</li>
</a>
<a href="#">
<li>Contact</li>
</a>
</ul>
</nav>
</header>
<!-- Home Section -->
<section class="home" id="homeSection">
<div class="container">
<img src="asset/me1.png" alt="Christopher NT">
<div class="text">
<h1>
Hey there! I'm <span>Christopher Nathanael Tessy</span>
</h1>
<p>Welcome to my personal web portfolio where I will showcase my best of the best works</p>
</div>
<div class="arrow">
About me
<i class="fas fa-angle-double-down"></i>
</div>
</div>
</section>
<!-- About Me Section -->
<section class="about" id="aboutSection">
<div class="container">
<h1>About Me</h1>
<h2>Christopher Nathanael Tessy</h2>
<h3>Front-End Web Developer</h3>
<div class="aboutContainer">
<div class="desc1">
<div class="top">
<h2>Who am I?</h2>
<p>My name is Christopher Nathanael Tessy. I am a dedicated and hardworking computer science student with a strong passion in front-end web development equipped with strong designing abilities with proven successes in designing posters, banners,
backdrops, social media, and merchandise for multiple years. Committed to working as a collaborative and positive team member. Bilingual, communicative, and ready to join my next team.
</p>
</div>
<div class="bottom">
<h2>Social Media</h2>
<div class="socialMedia">
<a href="mailto:christopher.nathanael1217#gmail.com">
<div class="email">
<span class="far fa-envelope"></span>
</div>
</a>
<a href="https://www.instagram.com/christophertessy_/">
<div class="instagram">
<span class="fab fa-instagram"></span>
</div>
</a>
<a href="https://www.linkedin.com/in/christopher-nathanael-tessy-b30339220/">
<div class="linkedin">
<span class="fab fa-linkedin-in"></span>
</div>
</a>
<a href="https://open.spotify.com/user/21z7frm7cr3jctz2c6zv6nafa?si=bd8ea929cc274a96">
<div class="spotify">
<span class="fab fa-spotify"></span>
</div>
</a>
<a href="https://github.com/TessyJr">
<div class=" github">
<span class="fab fa-github"></span>
</div>
</a>
</div>
</div>
</div>
<div class="desc2">
</div>
<div class="desc3">
<h2>Software and Programming Languages</h2>
<p>
<ul>
<li>Photoshop</li>
<li>Visual Studio Code</li>
<li>Figma</li>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
<li>C++</li>
</ul>
</p>
</div>
</div>
<div class="edu">
<h2>Education Background</h2>
<table>
<thead>
<tr>
<td>Year</td>
<td>Level of Education</td>
<td>Description</td>
</tr>
</thead>
<tbody>
<tr>
<td>2009-2015</td>
<td>Primary School</td>
<td>Sekolah Bina Gita Gemilang</td>
</tr>
<tr>
<td>2015-2021</td>
<td>High School</td>
<td>Penabur Secondary Kelapa Gading</td>
</tr>
<tr>
<td>2021-2025</td>
<td>University</td>
<td>Bina Nusantara University</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
</body>
</html>
This is the problem I'm facing:
The background color doesn't cover the bottom area
Remove the height property
.about .container {
width: 100%;
display: flex;
flex-direction: column;
justify-items: center;
align-items: center;
}
min-height: 100vh to the body element should do the trick. Here, 100vh means that the initial body height will take 100% of the viewport height,
its better to use :
height : 100vh;

Logo image getting cut off when browsing mobile or making browser smaller - CSS/Flexbox Issue

I'm new to the world of HTML/CSS and currently working through an online course. I've been working on one of my projects for a few hours and am absolutely stumped with an issue with my navigation bar.
The logo and nav links display fine on a desktop browser; however, when you make the browser the minimum size or browse on a mobile, the logo image is cut off on the right-hand side.
Any help would be greatly appreciated.
#import url('https://fonts.googleapis.com/css?family=Roboto');
.top-bar {
display: flex;
background-color: #ECECEC;
flex-wrap: wrap;
position: fixed;
top: 0;
right: 0;
left: 0;
align-items: top;
}
.header-img {
display: flex;
flex: 1;
justify-content: center;
width: 100%;
max-width: 534px;
height: auto;
padding: 10px 20px 10px 20px;
margin-right: auto;
margin-left: auto;
}
.nav-bar {
display: flex;
flex: 2;
justify-content: center;
align-items: center;
font-size: 1.5em;
font-family: 'Roboto', serif;
padding: 5px 0px 5px 0px;
}
.nav-bar a{
color: black;
text-decoration: none;
border-right: 1px solid black;
padding: 0px 5px 0px 5px;
}
.nav-bar a:hover {
color: #808080;
}
.nav-bar a:last-of-type {
border: none;
}
#home {
flex-basis: 20%;
display: flex;
justify-content: center;
}
#features {
display: flex;
flex-basis: 20%;
justify-content: center;
}
#video {
display: flex;
flex-basis: 20%;
justify-content: center;
}
#pricing {
display: flex;
flex-basis: 20%;
justify-content: center;
}
body {
padding: 100px 0px 0px 0px;
}
<header id="header">
<title>Eltee's Electric Drums</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto">
<div class="top-bar">
<img src="https://i.imgur.com/KCS3KND.png" id="header-img" class="header-img"></img>
<nav class="nav-bar" id="nav-bar">
<a class="nav-link" href="#home" id="home">Home</a>
<a class="nav-link" href="#features" id="features">Features</a>
<a class="nav-link" href="#video" id="video">Video</a>
<a class="nav-link" href="#pricing" id="pricing">Pricing</a>
</nav>
</header>
You needed a media query to deal with mobile viewport. I've added to your script as .top-bar img. Also your markup was located in the incorrect spot. <style> tag lives inside <head> and following </head> you need body tag and inside body tag is where your markup lives. so it should go as follows <html><head><style>css lives here</style></head><body>markup lives here</body></html>
See snippet for working solution, though it will likely only show the mobile solution given the snippet editor dimensions, so ingest the markup and styling into your page and it should works as expected for both mobile and desktop.
<style>
#import url('https://fonts.googleapis.com/css?family=Roboto');
.top-bar {
display: flex;
background-color: #ECECEC;
flex-wrap: wrap;
position: fixed;
top: 0;
right: 0;
left: 0;
align-items: top;
}
#media only screen and (max-width: 500px) {
.top-bar img {
display: flex;
width: 100%;
box-sizing: border-box;
}
}
.header-img {
display: flex;
flex: 1;
justify-content: center;
width: 100%;
max-width: 534px;
height: auto;
padding: 10px 20px 10px 20px;
margin-right: auto;
margin-left: auto;
}
.nav-bar {
display: flex;
flex: 2;
justify-content: center;
align-items: center;
font-size: 1.5em;
font-family: 'Roboto', serif;
padding: 5px 0px 5px 0px;
}
.nav-bar a {
color: black;
text-decoration: none;
border-right: 1px solid black;
padding: 0px 5px 0px 5px;
}
.nav-bar a:hover {
color: #808080;
}
.nav-bar a:last-of-type {
border: none;
}
#home {
flex-basis: 20%;
display: flex;
justify-content: center;
}
#features {
display: flex;
flex-basis: 20%;
justify-content: center;
}
#video {
display: flex;
flex-basis: 20%;
justify-content: center;
}
#pricing {
display: flex;
flex-basis: 20%;
justify-content: center;
}
body {
padding: 100px 0px 0px 0px;
}
<html>
<body>
<header id="header">
<title>Eltee's Electric Drums</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto">
<div class="top-bar">
<img src="https://i.imgur.com/KCS3KND.png" id="header-img" class="header-img"/>
<nav class="nav-bar" id="nav-bar">
<a class="nav-link" href="#home" id="home">Home</a>
<a class="nav-link" href="#features" id="features">Features</a>
<a class="nav-link" href="#video" id="video">Video</a>
<a class="nav-link" href="#pricing" id="pricing">Pricing</a>
</nav>
</div>
</header>
</body>
</html>
You could put your logo inside a div that would shrink and grow as a flex item. And tell the logo to fit the div.
#import url('https://fonts.googleapis.com/css?family=Roboto');
.top-bar {
display: flex;
background-color: #ECECEC;
flex-wrap: wrap;
position: fixed;
top: 0;
right: 0;
left: 0;
align-items: top;
}
.header-img {
display: flex;
flex: 1;
justify-content: center;
width: 100%;
max-width: 534px;
height: auto;
padding: 10px 20px 10px 20px;
margin-right: auto;
margin-left: auto;
}
.header-img img{
width:100%;
height:auto;
}
.nav-bar {
display: flex;
flex: 2;
justify-content: center;
align-items: center;
font-size: 1.5em;
font-family: 'Roboto', serif;
padding: 5px 0px 5px 0px;
}
.nav-bar a{
color: black;
text-decoration: none;
border-right: 1px solid black;
padding: 0px 5px 0px 5px;
}
.nav-bar a:hover {
color: #808080;
}
.nav-bar a:last-of-type {
border: none;
}
#home {
flex-basis: 20%;
display: flex;
justify-content: center;
}
#features {
display: flex;
flex-basis: 20%;
justify-content: center;
}
#video {
display: flex;
flex-basis: 20%;
justify-content: center;
}
#pricing {
display: flex;
flex-basis: 20%;
justify-content: center;
}
body {
padding: 100px 0px 0px 0px;
}
<header id="header">
<title>Eltee's Electric Drums</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto">
<div class="top-bar">
<div class="header-img"> <img src="https://i.imgur.com/KCS3KND.png" id="header-img" ></img></div>
<nav class="nav-bar" id="nav-bar">
<a class="nav-link" href="#home" id="home">Home</a>
<a class="nav-link" href="#features" id="features">Features</a>
<a class="nav-link" href="#video" id="video">Video</a>
<a class="nav-link" href="#pricing" id="pricing">Pricing</a>
</nav>
</div>
</header>

Logo in navigation bar positioning

I know there are a lot of questions about this, I've tried some of them and I didn't have that much luck.
I have this structure:
HTML:
<header>
<div class="logo">
<a><img style="height: 50px;" src="https://user94.files.wordpress.com/2009/12/ubuntu-logo.png"></a>
</div>
<div class="header-content">
<nav>
About me
Education
Personal life
My work
Contact me
</nav>
</div>
</header>
CSS:
header {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction: column;
align-items: center;
align-items: center;
text-align: center;
min-height: 100vh;
width: 100%;
background: url(http://via.placeholder.com/1920x1080) no-repeat 10% 10% / cover;
}
.header-content {
margin-top: 2em;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction: column;;
justify-content: center;
align-items: center;
text-align: center;
}
.logo{
padding-right: 0;
}
nav {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: row;
flex-direction: row;
font-weight: 400;
color: rgb(49, 41, 61);
font-size: .8em;
margin-top: 2em;
margin-left: 30em;
}
I'm trying to move the logo to the left without affecting my navigation items to the right, I was so much in trouble getting the nav items to the right and over the image that I don't get how to make both of them positioned correctly.
How can I make it work?
https://codepen.io/anon/pen/zLMzpO
This CSS for header should do what you want:
header {
display: flex;
align-items: baseline;
justify-content: space-between;
min-height: 100vh;
background: url(http://via.placeholder.com/1920x1080) no-repeat 10% 10% / cover;
}
https://codepen.io/anon/pen/YjRQRV
(no column direction, justify-content: space-between; and align-items: baseline; are the essential changes to your version)
Here is my solution:
.logo{
padding-right: 0;
opacity: 1;
}
.logo img{
opacity: 0;
}
.logo::after{
content: "";
width: 50px;
height: 54px;
opacity: 0.99;
position: absolute;
top: 10px;
left: 10px;
background: url("https://user94.files.wordpress.com/2009/12/ubuntu-logo.png") no-repeat;
background-size: 100% 100%;
}
in navigation bar you should use flex-direction: row.
here is a useful link flexbox basic navigation - menu items and logo
body{
margin:0;
}
header {
display: flex;
align-items: baseline;
justify-content: space-between;
min-height: 100vh;
background: url(http://via.placeholder.com/1920x1080) no-repeat 10% 10% / cover;
}
.header-content {
margin-top: 2em;
}
header a,
header a:visited {
color: rgb(252, 252, 252);
text-decoration: none;
padding-bottom: 0.1em;
}
header a:hover {
color: #FA26BF;
}
.logo{
padding-right: 0;
}
.logo img{
vertical-align: bottom;
}
nav {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: row;
flex-direction: row;
font-weight: 400;
color: rgb(49, 41, 61);
font-size: .8em;
margin-top: 2em;
margin-left: 30em;
}
nav a {
margin: 1em;
}
nav a,
nav a:visited {
padding-bottom: 0.1em;
letter-spacing: 0.1em;
text-decoration: none;
color: rgb(252, 252, 252);
}
nav a:hover,
nav a:active {
color: #FA26BF;
}
<header>
<div class="logo">
<a><img style="height: 50px;" src="https://user94.files.wordpress.com/2009/12/ubuntu-logo.png"></a>
</div>
<div class="header-content">
<nav>
About me
Education
Personal life
My work
Contact me
</nav>
</div>
</header>

Display flex align to right

If I am using
display: flex;
align-items: center;
how to make horizontal align of ul to right?
.navigation {
display: flex;
align-items: center;
width: 100%;
height: 80px;
background: rgb(255, 255, 255);
}
ul {
list-style: none;
/*float:right;*/
}
li {
display: inline-block;
}
a {
padding: 10px;
width: 80px;
text-decoration: none;
display: block;
text-align: center;
}
<div class="navigation">
<ul>
<li><a>Contacts</a></li>
<li><a>About</a></li>
<li><a>FAQ</a></li>
<li><a>Other</a></li>
</ul>
</div>
You can do this with justify-content: flex-end on .navigation
.navigation {
display: flex;
align-items: center;
justify-content: flex-end;
width: 100%;
height: 80px;
background: rgb(255, 255, 255);
}
ul {
list-style: none;
display: flex;
padding: 0;
}
a {
padding: 10px 25px;
width: 80px;
text-decoration: none;
text-align: center;
}
<div class="navigation">
<ul>
<li><a>Contacts</a></li>
<li><a>About</a></li>
<li><a>FAQ</a></li>
<li><a>Other</a></li>
</ul>
</div>
Add flex-direction: row-reverse; to .navigation
.navigation {
display: flex;
align-items: center;
width: 100%;
height: 80px;
background: rgb(255,255,255);
flex-direction: row-reverse;/* Here is what you are looking for*/
}
ul {
list-style:none;
border:1px solid black;
}
li {
display:inline-block;
}
a {
padding: 10px;
width: 80px;
text-decoration: none;
display: block;
text-align: center;
}
<div class="navigation">
<ul>
<li><a>Contacts</a></li>
<li><a>About</a></li>
<li><a>FAQ</a></li>
<li><a>Other</a></li>
</ul>
</div>