I have an issue with a flexbox not filling up all the way to my navbar, I cannot for the life of me figure it out and a negative margin does absolutely nothing
Here's a screenshot
.hero {
background-image: url("https://unsplash.it/1500?random");
background-size: cover;
background-position: center;
width: 100%;
height: 100%;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
margin-top: -10px;
}
.hero>.center-content {
width: 400px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
margin: auto;
}
.hero>.center-content h1,
.center-content h3 {
color: white;
line-height: 1;
}
.hero>.center-content h1 {
text-transform: uppercase;
font-size: 3em;
margin-bottom: 0;
text-align: center;
}
.hero>.center-content h3 {
margin-bottom: 40px;
font-size: 1.5em;
font-weight: normal;
}
.center-content>.button {
text-transform: uppercase;
color: white;
padding: 20px;
border: 1px solid white;
text-decoration: none;
}
.center-content>.button:hover {
background-color: rgba(255, 255, 255, 0.3);
border-color: rgba(255, 255, 255, 0.7);
color: #006594;
}
<div class="container" id="heroImage">
<div class="hero">
<div class="center-content">
<h1>Lazris</h1>
<h3>Revive Your Web Presence</h3>
Some Action Here
</div>
</div>
</div>
Remove the margin top on your active menu
.nav > .active {
/** margin-top: 10px; Remove **/
}
Related
I'm currently following TOP (The Odin Project) curriculum and working on my landing page project, so I'm trying to make it as responsive as possible.
How can I put the header's image below the sign up button once I minimize the page?
I've tried to use flex-wrap: wrap; but it'll not work because it wraps when the page is maximized.
.about {
display: flex;
justify-content: flex-start;
padding-bottom: 5%;
flex-wrap: wrap;
}
My code
html, body {
margin: 0;
padding: 0;
font-family: Verdana, Geneva, Tahoma, sans-serif;
box-sizing: border-box;
}
/* blue container, first container */
.dark-blue {
background-color: #1f2937;
display: flex;
flex: 1 1 0;
padding-left: 10%;
padding-right: 10%;
}
.header {
display: flex;
justify-content: space-around;
align-items: center;
padding-bottom: 5%;
}
.logo {
color: #F9FAF8;
font-size: 24px;
font-weight: bolder;
display: flex;
flex: 1 1 auto;
}
.links {
font-size: 18px;
display: flex;
flex-shrink: 1;
gap: 1rem;
flex-wrap: wrap;
}
.link-text {
font-size: 18px;
color: #e5e7eb;
}
a {
text-decoration: none;
}
ul {
list-style-type: none;
}
.about {
display: flex;
justify-content: flex-start;
padding-bottom: 5%;
}
.main-text {
color: #F9FAF8;
font-size: 48px;
font-weight: bolder;
width: 95%;
display: flex;
flex: 1 1 auto;
padding-bottom: 1rem;
}
.secondary-text {
padding-bottom: .5rem;
font-size: 18px;
max-width: 80%;
color: #e5e7eb;
display: flex;
flex: 1 1 auto;
justify-content: start;
padding-bottom: 1rem;
}
.about-text {
padding-bottom: 5%;
display: flex;
flex-direction: column;
}
.button-one {
background-color: #1DB954;
color: #F9FAF8;
font-weight: bold;
border-radius: 10px;
width: 92px;
height: 20px;
padding: 8px;
text-align: center;
}
.button-one:hover {
color: #F9FAF8;
font-weight: bold;
background-color: #126e32;
border-radius: 10px;
box-shadow: 0 5px 8px 0 rgba(224, 224, 224, 0.020), 0 7px 10px 0 rgba(238, 238, 238, 0.025);
width: 92px;
height: 20px;
padding: 8px;
text-align: center;
}
.button-text {
color: #F9FAF8;
}
.button-text:hover {
color: #F9FAF8;
}
.header-image {
width: 45%;
height: 18%;
border-radius: 2px;
display: flex;
flex-shrink: 0;
}
/* second container, information */
.information-header-text {
font-size: 36px;
color: #1f2937;
font-weight: bolder;
text-align: center;
display: flex;
justify-content: center;
padding-top: 5rem;
padding-bottom: 2rem;
flex: 1 1 auto;
}
.image img {
width: 17rem;
height: 17rem;
border: none;
border-radius: 2px;
display: flex;
}
.image img:hover {
width: 17rem;
height: 17rem;
border: none;
border-radius: 2px;
box-shadow: 0 5px 12px 0px rgba(8, 8, 8, 0.199);
}
.subtext {
color: #1f2937;
width: 17rem;
text-align: center;
padding-top: .5rem;
padding-bottom: 1rem;
}
.image-subtext {
display: flex;
justify-content: center;
align-content: center;
gap: 1%;
flex-wrap: wrap;
padding-bottom: 8rem;
}
/* third container, quote container */
.quote {
background-color: #e5e7eb;
display: flex;
flex-wrap: wrap;
flex: 1 1 auto;
padding-left: 25%;
padding-right: 20%;
padding-bottom: 10%;
padding-top: 10%;
}
.quote-text {
font-size: 36px;
color: #1f2937;
font-style: italic;
font-weight: 100;
width: 100%;
padding-bottom: 0;
}
.author {
font-size: 24px;
color: #1f2937;
font-weight: 900;
width: 90%;
display: flex;
flex-shrink: 1;
padding-left: 70%;
}
/* fourth container, box action */
.action {
background-color:#F9FAF8;
height: 30rem;
display: flex;
justify-content: center;
align-items: center;
flex: 1 1 auto;
}
.box-action {
background-color: #1DB954;
border-radius: 2px;
box-shadow: 0 5px 8px 0px rgba(8, 8, 8, 0.145);
display: flex;
justify-content: space-between;
align-items: center;
flex: 0 1 auto;
flex-wrap: wrap;
width: 50%;
padding: 5%;
padding-left: 10%;
padding-right: 10%;
gap: 2rem;
}
.action-title {
font-size: 32px;
color: #F9FAF8;
font-weight: bolder;
display: flex;
flex-shrink: 1;
}
.action-subtext {
color: #e5e7eb;
font-size: 18px;
font-weight: lighter;
display: flex;
flex-shrink: 1;
}
.button-two {
background-color: #1DB954;
color: #F9FAF8;
font-weight: bold;
border-radius: 10px;
border: 2px solid #F9FAF8;
width: 90px;
height: 20px;
padding: 5px;
text-align: center;
}
.button-two:hover {
color: #1DB954;
font-weight: bold;
background-color: #F9FAF8;
border-radius: 10px;
width: 90px;
height: 20px;
padding: 5px;
text-align: center;
}
.button-text-two {
color: #F9FAF8;
}
.button-text-two:hover {
color: #1DB954;
}
/* Footer */
footer {
color: #e5e7eb;
font-weight: lighter;
height: 5rem;
display: flex;
justify-content: center;
align-items: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Black and White</title>
<link rel="icon" href="images/blackandwhite.png">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="header dark-blue">
<div class="logo">black and white</div>
<ul class="links">
<li><a class="link-text" href="#">home</a></li>
<li><a class="link-text" href="#photos">photos</a></li>
<li><a class="link-text" href="#sign-up">sign up</a></li>
</div>
</div>
<div class="about dark-blue">
<div class="about-text">
<div class="main-text">Get beautiful black and white pictures</div>
<div class="secondary-text">The world is not black and white, there are lots of shades of grey.
There are good things and bad things in every era, and
it's kind of very blindfolded to say one era was wonderful,
as it was wonderful, but there were a lot of bad things as well.</div>
<div class="button-one">
<a class="button-text" href="#">Sign up</a>
</div>
</div>
<img class="header-image" src="./images/header-image.jpeg">
</div>
<section id ="photos"></section>
<div class="information">
<div class="information-header-text">Check some black and white photos</div>
<div class="image-subtext">
<div class="one">
<a href="https://images.unsplash.com/reserve/yZfr4jmxQyuaE132MWZm_stagnes.jpg?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1026&q=80">
<div class="image"><img src="./images/rocks.jpeg" alt="Monochrome coastal rocks"></div>
</a>
<div class="subtext">Monochrome coastal rocks</div>
</div>
<div class="two">
<a href="https://images.unsplash.com/photo-1574402897005-74dbf3f19be6?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80">
<div class="image"><img src="./images/stairway.jpeg" alt="Stairway from metro station"></div>
</a>
<div class="subtext">Stairway from metro station</div>
</div>
<div class="three">
<a href="https://images.unsplash.com/photo-1603157259666-71adcb873119?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=870&q=80">
<div class="image"><img src="./images/cat.jpeg" alt="Cat eyes"></div>
</a>
<div class="subtext">Cat eyes</div>
</div>
<div class="four">
<a href="https://images.unsplash.com/photo-1452727333656-23ae1299777a?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=580&q=80">
<div class="image"><img src="./images/truck.jpeg" alt="Monochrome vintage truck"> </div>
</a>
<div class="subtext">Monochrome vintage truck</div>
</div>
</div>
<div class="quote">
<div class="quote-text">
Although humans see reality in colour, for me,
black and white has always been connected to the image's deeper truth,
to its most hidden meaning.
</div>
<div class="author">
- Peter Lindbergh
</div>
</div>
</div>
<section id ="sign-up"></section>
<div class="action">
<div class="box-action">
<div class="action-text">
<div class="action-title">More photos?</div>
<div class="action-subtext">Sign up for more beautiful black and white pictures!
</div>
</div>
<div class="button-two">
<a class="button-text-two" href="#">Sign up</a>
</div>
</div>
</div>
<footer class="dark-blue">
Copyright © The Odin Project 2023
</footer>
</body>
</html>
html, body {
margin: 0;
padding: 0;
font-family: Verdana, Geneva, Tahoma, sans-serif;
box-sizing: border-box;
}
/* blue container, first container */
.dark-blue {
background-color: #1f2937;
display: flex;
flex: 1 1 0;
padding-left: 10%;
padding-right: 10%;
}
.header {
display: flex;
justify-content: space-around;
align-items: center;
padding-bottom: 5%;
}
.logo {
color: #F9FAF8;
font-size: 24px;
font-weight: bolder;
display: flex;
flex: 1 1 auto;
}
.links {
font-size: 18px;
display: flex;
flex-shrink: 1;
gap: 1rem;
flex-wrap: wrap;
}
.link-text {
font-size: 18px;
color: #e5e7eb;
}
a {
text-decoration: none;
}
ul {
list-style-type: none;
}
.about {
display: flex;
justify-content: flex-start;
padding-bottom: 5%;
}
.main-text {
color: #F9FAF8;
font-size: 48px;
font-weight: bolder;
width: 95%;
display: flex;
flex: 1 1 auto;
padding-bottom: 1rem;
}
.secondary-text {
padding-bottom: .5rem;
font-size: 18px;
max-width: 80%;
color: #e5e7eb;
display: flex;
flex: 1 1 auto;
justify-content: start;
padding-bottom: 1rem;
}
.about-text {
padding-bottom: 5%;
display: flex;
flex-direction: column;
}
.button-one {
background-color: #1DB954;
color: #F9FAF8;
font-weight: bold;
border-radius: 10px;
width: 92px;
height: 20px;
padding: 8px;
text-align: center;
}
.button-one:hover {
color: #F9FAF8;
font-weight: bold;
background-color: #126e32;
border-radius: 10px;
box-shadow: 0 5px 8px 0 rgba(224, 224, 224, 0.020), 0 7px 10px 0 rgba(238, 238, 238, 0.025);
width: 92px;
height: 20px;
padding: 8px;
text-align: center;
}
.button-text {
color: #F9FAF8;
}
.button-text:hover {
color: #F9FAF8;
}
.header-image {
width: 45%;
height: 18%;
border-radius: 2px;
display: flex;
flex-shrink: 0;
}
/* second container, information */
.information-header-text {
font-size: 36px;
color: #1f2937;
font-weight: bolder;
text-align: center;
display: flex;
justify-content: center;
padding-top: 5rem;
padding-bottom: 2rem;
flex: 1 1 auto;
}
.image img {
width: 17rem;
height: 17rem;
border: none;
border-radius: 2px;
display: flex;
}
.image img:hover {
width: 17rem;
height: 17rem;
border: none;
border-radius: 2px;
box-shadow: 0 5px 12px 0px rgba(8, 8, 8, 0.199);
}
.subtext {
color: #1f2937;
width: 17rem;
text-align: center;
padding-top: .5rem;
padding-bottom: 1rem;
}
.image-subtext {
display: flex;
justify-content: center;
align-content: center;
gap: 1%;
flex-wrap: wrap;
padding-bottom: 8rem;
}
.about {
display: flex;
justify-content: flex-start;
padding-bottom: 5%;
flex-wrap: wrap;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Black and White</title>
<link rel="icon" href="images/blackandwhite.png">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="header dark-blue">
<div class="logo">black and white</div>
<ul class="links">
<li><a class="link-text" href="#">home</a></li>
<li><a class="link-text" href="#photos">photos</a></li>
<li><a class="link-text" href="#sign-up">sign up</a></li>
</div>
</div>
<div class="about dark-blue">
<div class="about-text">
<div class="main-text">Get beautiful black and white pictures</div>
<div class="secondary-text">The world is not black and white, there are lots of shades of grey.
There are good things and bad things in every era, and
it's kind of very blindfolded to say one era was wonderful,
as it was wonderful, but there were a lot of bad things as well.</div>
<div class="button-one">
<a class="button-text" href="#">Sign up</a>
</div>
</div>
<img class="header-image" src="./images/header-image.jpeg">
</div>
</body>
</html>
You could add a media query that switches the flex direction between row and column when the viewport crosses a particular width threshold.
Might look something like this:
.about {
display: flex;
flex-direction: row;
}
#media (max-width: 600px) {
.about {
flex-direction: column;
}
}
<div class="about">
<div class="about-text">
<div class="main-text">Get beautiful black and white pictures</div>
<div class="secondary-text">The world is not black and white, there are lots of shades of grey. There are good things and bad things in every era, and it's kind of very blindfolded to say one era was wonderful, as it was wonderful, but there were a lot of bad things as well.</div>
<div class="button-one">
<a class="button-text" href="#">Sign up</a>
</div>
</div>
<img src="//placekitten.com/300/300">
</div>
This is difficult to demonstrate on StackOverflow due to the snippet framing, but if you full-screen the snippet above and adjust your window size you'll see it snap to column orientation when your window is narrower than 600px.
You could also do this with a container query if you need to base it on a parent element width instead of the entire viewport.
If you mean that you want the image to move when you're reducing the size of the page (rather than minimizing it, i.e. hiding it completely), you could add some media queries to your CSS.
Try adding
#media screen and (max-width: 1200px) {
.about{
flex-direction: column;
}
(setting the px breakpoints for the size you want) and see if it works!
I'm trying out frontend mentor projects and I'm having trouble serving a picture of different viewport size(for desktop) and I don't know what's wrong, I used the picture element and declared at what width the picture should be served but it doesn't work.
The confusing aspect is that flexbox and grid display properties don't have much effect. The small mobile image doesn't get replaced with the desktop one.
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
\*::before,
\*::after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html,
body {
min-height: 100vh;
background-color: hsl(30, 38%, 92%);
}
main.background {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
min-height: 100vh;
background-color: hsl(30, 38%, 92%);
article.card-body {
display: flex;
background-color: #fff;
flex-direction: column;
max-width: 346px;
border-radius: 10px;
section.card-details {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
padding: 25px;
picture.image-container {
width: 346px;
height: 243px;
border-radius: 10px;
}
header.title {
color: hsl(228, 12%, 48%);
font-family: 'Montserrat', sans-serif;
font-size: 13px;
font-weight: bold;
letter-spacing: 5px;
margin-bottom: 13px;
margin-left: -5px;
margin-top: -3px;
transform: scale(0.9);
}
h1.title-detail {
color: hsl(212, 21%, 14%);
font-family: 'Fraunces', serif;
font-size: 34px;
line-height: 1;
font-weight: 700;
margin-bottom: 17px;
}
}
}
}
p.section-detail {
font-family: 'Montserrat', sans-serif;
color: hsl(228, 12%, 48%);
font-size: 13px;
line-height: 1.6;
margin-bottom: 29px;
}
h2.price {
display: flex;
flex-direction: row;
font-family: 'Fraunces', sans-serif;
color: hsl(158, 36%, 37%);
font-size: 32px;
font-weight: 900;
margin-bottom: 20px;
}
h2.price::after {
content: '$169.99';
display: flex;
flex-direction: row;
align-self: center;
color: hsl(228, 12%, 48%);
font-size: 11px;
font-family: 'Fraunces', sans-serif;
font-weight: 300;
padding-left: 23px;
text-decoration: line-through;
}
img.perfume-image {
object-fit: contain;
width: 346px;
height: 243px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
img.cart-icon {
margin-left: -15px;
}
button.add-to-cart {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
font-weight: 700;
font-family: 'Montserrat', sans-serif;
background-color: hsl(158, 36%, 37%);
color: #fff;
width: 298px;
height: 50px;
border: none;
border-radius: 5px;
}
button.add-to-cart:hover {
background-color: hsl(158, 36%, 13%);
cursor: pointer;
}
span.btn-text {
padding-left: 15px;
}
footer.challenge-userinfo {
display: flex;
align-self: flex-end;
div.attribution {
background-color: #fff;
text-align: center;
width: 100%;
font-size: 11px;
text-align: center;
}
div.attribution a {
color: hsl(228, 45%, 44%);
text-decoration: none;
}
}
#media (min-width: 800px) {
main {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
article.card-body {
display: flex;
flex-direction: row;
min-width: 616px;
}
picture-image-container {
display: flex;
flex-direction: row;
}
.card-details {
width: 308px;
}
}
<main class="background">
<img src="./images/image-product-mobile.jpg" alt="perfume"> PERFUME
<h1>Gabrielle Essence Eau De Parfum</h1>
<p>A floral, solar and voluptuous interpretation composed by Olivier Polge, Perfumer-Creator for the House of CHANEL.</p>
<h2>$149.99</h2>
<img src="./images/icon-cart.svg" alt="cart">Add to Cart Challenge by Frontend Mentor. Coded by David Bayode.
I tried using messing with the min and max-widths to see if it's the width misbehaving.
Found the solution, my nested scss styles had a high specificity that prevented media queries from being triggered.
Could you please check and advise why my scroll button doesn't work as expected?
It's my first project, so I believe there may be some mistakes, but have no idea why my scrolling "crashes".
I was expecting it to be only a pink one and have the smooth scroll option on the whole page, but it breaks into two lines. Unfortunately, I can't post the image, but basically, this "second" line is like the line in the standard browser and behind that line, I have my pink one.
{
font-family: 'Poppings', sans-serif;
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
outline: none;
border: none;
text-decoration: none;
text-transform: capitalize;
-webkit-transition: all .2s linear;
transition: all .2s linear;
}
html {
font-size: 62.5%;
overflow-x: hidden;
scroll-behavior: smooth;
scroll-padding-top: 9rem;
}
html::-webkit-scrollbar {
width: 0.5rem;
}
html::-webkit-scrollbar-thumb {
background: #d9296f;
}
body {
padding: 0;
margin: 0;
background: #08122f;
overflow-x: hidden;
}
section {
padding: 3rem 9%;
}
.heading{
text-align: center;
margin-bottom: 2rem;
}
.heading span{
color: #d9296f;
font-size: 2rem;
}
.heading h1{
font-size: 4rem;
color: #8f7fa2;
}
.btn {
margin-top: 1rem;
display: inline-block;
padding: 1rem 3rem;
font-size: 1.7rem;
color: #d9296f;
border: 0.2rem solid #d9296f;
border-radius: 5rem;
cursor: pointer;
background: none;
}
.btn:hover {
background: #d9296f;
color: #08122f;
}
/*---header---*/
.header{
position: fixed;
top:0;
left: 0;
right: 0;
z-index: 1100;
background: #08122f;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-boxpack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
padding: 1.5rem 9%;
box-shadow: 0 1px 6px 0 rgba(193, 193, 212, 0.28);
}
.header .navbar a{
font-size: 2rem;
color: #8f7fa2;
display: inline-block;
margin: 0 1rem;
}
.header .navbar a:hover{
color: #d9296f;
}
.logo{
font-size: 2.5rem;
color: #8f7fa2;
font-weight: bolder;
}
.logo span{
color: #d9296f;
}
#menu-btn{
font-size: 2.5rem;
color:#8f7fa2;
cursor: pointer;
display: none;
}
/*--home---*/
.home{
margin: auto;
margin-top: auto;
width: 80%;
display: -webkit-box;
display: -ms-webkit-box;
display: flex;
min-height: 80vh;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
padding-bottom: 5rem;
}
.home .content{
text-align: center;
}
.home .content span{
margin-top: 100px;
font-weight: bolder;
color: transparent;
-webkit-text-stroke: 0.1rem #8f7fa2;
font-size: 4vw;
display: block;
}
.home .content h3{
font-size: 6vw;
color: #8f7fa2;
}
.home .content p{
max-width: 60rem;
margin: 1rem auto;
font-size: 1.4rem;
color: #8f7fa2;
margin-top: 18px;
line-height: 2;
letter-spacing: 1px;
}
/*--about--*/
.about{
display: -webkit-box;
-display: -ms-flexbox;
display: flex;
-webkit-boxalign: center;
-ms-flex-align: center;
align-items: center;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
gap: 4rem;
margin-top: 5rem;
}
.about .img-container{
-webkit-box-flex: 1;
-ms-flex: 1 1 42rem;
flex: 1 1 42rem;
width: 50%;
}
.about .img-container img{
border-radius: 1rem;
width: 40%;
}
.about .content{
-webkit-box-flex: 1;
-ms-flex: 1 1 42rem;
flex: 1 1 42rem;
margin-bottom: 10rem;
}
.about .content span{
color: #d9296f;
font-size: 2rem;
}
.about .content h3{
color: #8f7fa2;
font-size: 4rem;
margin-top: .5rem;
}
.about .content p{
padding: 1rem 0;
font-size: 1.4rem;
color: #8f7fa2;
line-height: 2;
}
/*--Services--*/
.services .box-container{
display: -ms-grid;
display: grid;
-ms-grid-column: (minmax(25rem, 1fr)) [auto-fit];
grid-column: (minmax(25rem, 1fr)) [auto-fit];
grid-template-columns: repeat(auto-fit, minmax(32rem, 1fr));
gap: 1.5rem;
}
.services .box-container .box{
background: #08122f;
border-radius: 1rem;
padding: 1rem;
text-align: center;
box-shadow: #8f7fa2;
}
.services .box-container .box:hover{
transform: scale(1.05);
background: #8f7fa2;
}
.services .box-container .box i{
font-size: 4rem;
color: #d9296f;
margin-bottom: 3scrolrem;
}
.services .box-container .box h3{
font-size: 2rem;
color: #d9296f;[enter image description here][1]
}
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>
I'm a fairly new web developer and I came across a problem (part of it may be a lack of understanding) but I'm having an awful time creating a sidebar with HTML or CSS. My website currently looks as follows:
There isn't much here, but my dilemma is simple: I'd like to create a sidebar. Maybe to put recent updates or other important things. Also, it'd be great to know if I'm going to go into a web development job eventually.
Here is the code:
* {
margin: 0;
padding: 0;
}
body {
background: url("https://s-media-cache-ak0.pinimg.com/originals/ca/5d/a4/ca5da4df54f6fc88531cbfff469043b0.jpg");
background-repeat: no-repeat;
}
.navbar {
width: 100%;
margin-top: 150px;
}
.navbar ul {
text-align: center;
border-top: solid 2px black;
border-left: solid 2px black;
border-right: solid 2px black;
margin-left: 400px;
margin-right: 400px;
background: #444444;
padding-top: 10px;
padding-bottom: 10px;
}
.navbar ul li {
display: inline-block;
}
.navbar ul li a {
text-decoration: none;
color: black;
font-size: 30px;
padding-left: 20px;
padding-right: 20px;
color: white;
transition: 0.3s;
padding-top: 10px;
padding-bottom: 10px;
}
.navbar ul li a:hover {
background: #8c8c8c;
}
.body {
background-color: rgba(158, 158, 158, 0.6);
margin-left: 400px;
margin-right: 400px;
border: solid 2px black;
border
}
.body p {
font-size: 20px;
padding-top: 5px;
padding-bottom: 5px;
margin-left: 20px;
margin-right: 20px;
line-height: 30px;
font-weight: 600;
}
<div class="navbar">
<ul>
<li>Home
</li>
<li>My Works
</li>
<li>Contact Me
</li>
</ul>
</div>
<div class="body">
<p>(paragraph related stuff)
</p>
</div>
I'm fairly new to Web Development (and programming entirely, really) but I've looked up multiple questions, tried many things, and nothing seemed to work. I decided to post here myself to see if I can get any solutions?
From what I understand, HTML has elements that go one under another. I've never figured out how to get elements to go side by side. This may also help when adding an image and then text beside it!
Thank you if you are able to help me :)
may be this simple sidebar can help :
http://codepen.io/Axeish/pen/GrEdMx
CSS
`
html {
height: 100%;
}
body {
height: 100%;
background-color: #e2e1e0;
overflow: hidden;
}
a, a:focus, a:active {
text-decoration: none;
-webkit-transition: all 300ms cubic-bezier(0.42, 0, 0.58, 1) 10ms;
transition: all 300ms cubic-bezier(0.42, 0, 0.58, 1) 10ms;
}
.card {
border-radius: 2px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
padding: 20px;
background-color: #fff;
margin-bottom: 30px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.center {
width: 400px;
height: 200px;
}
.container {
height: 100%;
margin-left: 400px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
overflow-x: hidden;
overflow-y: auto;
}
.container p {
font-size: 20px;
}
.header {
position: fixed;
left: 0;
top: 0;
bottom: 0;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
width: 400px;
z-index: 20;
padding-top: 50px;
padding-bottom: 100px;
background-color: white;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.16), 0 0 6px rgba(0, 0, 0, 0.23);
}
.header .content .logo {
padding: 10px 20px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.header .content .logo span {
text-transform: uppercase;
text-decoration: none;
font-size: 27px;
font-weight: 200;
color: #212121;
}
.header .content .logo img {
width: 50px;
height: 50px;
margin-right: 10px;
}
.header .content ul.navigation {
list-style: none;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-ms-flex-pack: distribute;
justify-content: space-around;
padding: 0;
}
.header .content ul.navigation li {
padding: 10px;
cursor: pointer;
-webkit-transition: all 300ms cubic-bezier(0.42, 0, 0.58, 1) 10ms;
transition: all 300ms cubic-bezier(0.42, 0, 0.58, 1) 10ms;
}
.header .content ul.navigation li a {
color: #212121;
}
.header .content ul.navigation li a.active {
text-decoration: underline;
}
.header .content ul.navigation li:hover a {
background-color: #212121;
color: white;
}
`
Check this out.
*, :before, :after {
box-sizing: border-box;
}
body {
background: url("https://s-media-cache-ak0.pinimg.com/originals/ca/5d/a4/ca5da4df54f6fc88531cbfff469043b0.jpg");
background-repeat: no-repeat;
}
.unstyled {
list-style: none;
padding: 0;
margin: 0;
}
.unstyled a {
text-decoration: none;
}
.list-inline {
overflow: hidden;
}
.list-inline li {
float: left;
}
.header {
position: fixed;
left: 0;
top: 0;
bottom: 0;
width: 17.5em;
background: #D13513;
}
.logo {
font: 300 2em "Source Sans Pro", Helvetica, Arial, sans-serif;
text-align: center;
padding: 0;
margin: 0;
}
.logo a {
display: block;
padding: 1em 0;
color: #DFDBD9;
text-decoration: none;
transition: .15s linear color;
}
.main-nav ul {
border-top: solid 1px #3C3735;
}
.main-nav li {
border-bottom: solid 1px #3C3735;
}
.main-nav a {
padding: 1.1em 0;
color: #DFDBD9;
font: 400 1.125em "Source Sans Pro", Helvetica, Arial, sans-serif;
text-align: center;
}
.main-nav a:hover {
color: #fff;
}
.list-hover-slide li {
position: relative;
overflow: hidden;
}
.list-hover-slide a {
display: block;
position: relative;
z-index: 1;
transition: .35s ease color;
}
.list-hover-slide a:before {
content: '';
display: block;
z-index: -1;
position: absolute;
left: -100%;
top: 0;
width: 100%;
height: 100%;
border-right: solid 5px #DF4500;
background: #3C3735;
transition: .35s ease left;
}
.list-hover-slide a.is-current:before, .list-hover-slide a:hover:before {
left: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" rel="stylesheet"/>
<body>
<header class="header" role="banner">
<h1 class="logo">
SideNav
</h1>
<div class="nav-wrap">
<nav class="main-nav" role="navigation">
<ul class="unstyled list-hover-slide">
<li>Home</li>
<li>My Work</li>
<li>Contact Me</li>
</ul>
</nav>
<script