I have been trying to get rid of the horizontal scrollbar in my code. I am creating a personal portfolio page. I have looked at all my widths and I don't think that's the issue. It might be my media queries. I am new to coding and I am sorry if this isn't a good question. I have tried researching and found vmin vh vw vmax and such but when applied to all the widths, it doesn't appear to affect the scroll bar.
#import url('https://fonts.googleapis.com/css2?family=PT+Sans&family=Roboto:wght#400;500&family=Ubuntu&display=swap');
html {
scroll-behavior: smooth;
box-sizing: border-box;
font-size: 62.5%;
background-image: linear-gradient(180deg, #001219, #005F73, #0A9396, #0B9669);
}
body {
font-size: 1.8rem;
font-family: Roboto, PT Sans, Ubuntu;
text-size-adjust: 80%;
}
#navbar {
background: linear-gradient(180deg, #001219, rgba(0, 0, 0, 0));
position: fixed;
width: 100%;
left: 0;
top: 0;
margin: 0;
padding: 0;
}
.navbar-links {
text-decoration: none!important;
color: #F2E9E4;
}
ul {
list-style: none!important;
}
nav>ul {
display: flex;
flex-direction: row;
justify-content: space-around;
}
.invisible-para {
opacity: 0%;
}
#welcome-section {
color: #CA6702;
text-shadow: 2px, 2px;
text-align: center;
height: 100vh;
width: 100%;
font-size: 5vmin;
position: relative;
bottom: 13.5em;
}
.welcome-header {
margin-bottom: 0;
text-shadow: 2px 2px 20px black;
}
.welcome-para {
text-shadow: 2px 2px 20px black;
}
.project-image {
width: 100%;
max-width: 100%;
height: auto;
border-radius: 10px;
}
.projects-header {
padding-top: 3rem!important;
padding-bottom: 2rem;
display: flex;
text-align: center;
justify-content: center;
font-size: 3.5rem;
text-shadow: 2px 2px 20px black;
color: #CA6702;
}
#projects {
display: flex;
flex-direction: column;
text-align: center;
width: 100%;
}
.project-tile {
text-decoration: none;
color: #001219;
text-align: center;
text-shadow: 2px 2px 20px;
font-size: 1.5em;
font-family: PT Sans;
font-weight: bold;
display: flex;
flex-direction: column;
background-color: #94D2BD;
border-radius: 10px;
width: 300px;
padding: 1rem;
margin: 8vh 10vw 0 10vw;
box-shadow: 2px 2px 20px;
}
.grid-container {
width: 100%;
display: grid!important;
grid-template-columns: 1fr 1fr;
grid-gap: 2rem;
align-self: center;
text-align: center;
}
#contact {
text-align: center;
padding: 3em;
height: auto;
text-shadow: 2px 2px 20px;
}
#contact-header {
font-size: 8vmin;
padding: 0 0 2em 0;
}
div>ul {
display: flex;
flex-direction: row;
justify-content: space-around;
}
#profile-link {
text-decoration: none;
color: black;
font-family: Ubuntu;
font-weight: bold;
font-size: 4vmin;
background-color: #94D2BD;
border-radius: 5px;
padding: 8px;
box-shadow: 2px 2px 20px;
}
/*MEDIA QUIERIES BELOW*/
#media (max-width: 800px) {
.grid-container {
grid-template-columns: 1fr;
}
}
#media (max-width:400px) {
#welcome-section {
bottom: 25em;
}
}
/*MEDIA QUEIRIES ABOVE*/
<p class="invisible-para" id="welcome-section"></p>
<nav id="navbar">
<ul>
<li><a class="navbar-links" href="#welcome-section">Welcome</a></li>
<li><a class="navbar-links" href="#projects">Projects</a></li>
<li><a class="navbar-links" href="#contact">Contact</a></li>
</ul>
</nav>
<section id="welcome-section">
<h1 class="welcome-header">Hi, I'm Timothy McMasters</h1>
<p class="welcome-para">an aspiring full-stack developer</p>
</section>
<section id="projects">
<h2 class="projects-header">The following are projects that I have created</h2>
<ul class="grid-container">
<li class="grid-box">
<a class="project-tile" href="https://codepen.io/tmmcmasters/full/QWOEXyO" target="_blank"><img src="https://i.ibb.co/3B42dcS/Form-Survey.png" class="project-image" alt="Form-Survey">Form Survey</img>
</a>
</li>
<li class="grid-box">
<a class="project-tile" href="https://codepen.io/tmmcmasters/full/zYPNdoX" target="_blank"><img src="https://i.ibb.co/wKLyykK/Product-Landing-Page.png" alt="Product-Landing-Page" class="project-image">Product Landing Page</img>
</a>
</li>
<li class="grid-box">
<a class="project-tile" href="https://codepen.io/tmmcmasters/full/MWOmaGJ" target="_blank" class="project-tile"><img src="https://i.ibb.co/0mdYX9X/Techncacal-Documentation-Page.png" alt="Technical-Documentation-Page" class="project-image">Technical Documentation Page</img>
</a>
</li>
<li class="grid-box">
<a href="https://codepen.io/tmmcmasters/full/MWOebeo" target="_blank" class="project-tile"><img src="https://i.ibb.co/tcJcWsw/Tribute-Page.png" alt="Tribute-Page" class="project-image">Tribute Page</img>
</a>
</li>
</ul>
</section>
<section id="contact">
<h2 id="contact-header">Contact Me</h2>
<div class="contact-links">
<ul>
<li><a id="profile-link" href="https://github.com/Tmmcmasters" target="_blank">Github</a></li>
<li><a id="profile-link" href="mailto:tmmcmasters#gmail.com?subject=" feedback " target="_blank ""> Email me </a></li>
<li><a id="profile-link" href="tel:12602672147" target="_blank">Call me</a></li>
</ul>
</div>
</section>
Add a padding: 0; to your grid-container to remove the padding which makes the page scroll:
This is the code:
#import url('https://fonts.googleapis.com/css2?family=PT+Sans&family=Roboto:wght#400;500&family=Ubuntu&display=swap');
html {
scroll-behavior: smooth;
box-sizing: border-box;
font-size: 62.5%;
background-image: linear-gradient(180deg, #001219, #005F73, #0A9396, #0B9669);
}
body {
font-size: 1.8rem;
font-family: Roboto, PT Sans, Ubuntu;
text-size-adjust: 80%;
}
#navbar {
background: linear-gradient(180deg, #001219, rgba(0, 0, 0, 0));
position: fixed;
width: 100%;
left: 0;
top: 0;
margin: 0;
padding: 0;
}
.navbar-links {
text-decoration: none!important;
color: #F2E9E4;
}
ul {
list-style: none!important;
}
nav>ul {
display: flex;
flex-direction: row;
justify-content: space-around;
}
.invisible-para {
opacity: 0%;
}
#welcome-section {
color: #CA6702;
text-shadow: 2px, 2px;
text-align: center;
height: 100vh;
width: 100%;
font-size: 5vmin;
position: relative;
bottom: 13.5em;
}
.welcome-header {
margin-bottom: 0;
text-shadow: 2px 2px 20px black;
}
.welcome-para {
text-shadow: 2px 2px 20px black;
}
.project-image {
width: 100%;
max-width: 100%;
height: auto;
border-radius: 10px;
}
.projects-header {
padding-top: 3rem!important;
padding-bottom: 2rem;
display: flex;
text-align: center;
justify-content: center;
font-size: 3.5rem;
text-shadow: 2px 2px 20px black;
color: #CA6702;
}
#projects {
display: flex;
flex-direction: column;
text-align: center;
width: 100%;
}
.project-tile {
text-decoration: none;
color: #001219;
text-align: center;
text-shadow: 2px 2px 20px;
font-size: 1.5em;
font-family: PT Sans;
font-weight: bold;
display: flex;
flex-direction: column;
background-color: #94D2BD;
border-radius: 10px;
width: 300px;
padding: 1rem;
margin: 8vh 10vw 0 10vw;
box-shadow: 2px 2px 20px;
}
.grid-container {
width: 100%;
display: grid!important;
grid-template-columns: 1fr 1fr;
grid-gap: 2rem;
align-self: center;
text-align: center;
padding: 0; /* added this one */
}
#contact {
text-align: center;
padding: 3em;
height: auto;
text-shadow: 2px 2px 20px;
}
#contact-header {
font-size: 8vmin;
padding: 0 0 2em 0;
}
div>ul {
display: flex;
flex-direction: row;
justify-content: space-around;
}
#profile-link {
text-decoration: none;
color: black;
font-family: Ubuntu;
font-weight: bold;
font-size: 4vmin;
background-color: #94D2BD;
border-radius: 5px;
padding: 8px;
box-shadow: 2px 2px 20px;
}
/*MEDIA QUIERIES BELOW*/
#media (max-width: 800px) {
.grid-container {
grid-template-columns: 1fr;
}
}
#media (max-width:400px) {
#welcome-section {
bottom: 25em;
}
}
/*MEDIA QUEIRIES ABOVE*/
<p class="invisible-para" id="welcome-section"></p>
<nav id="navbar">
<ul>
<li><a class="navbar-links" href="#welcome-section">Welcome</a></li>
<li><a class="navbar-links" href="#projects">Projects</a></li>
<li><a class="navbar-links" href="#contact">Contact</a></li>
</ul>
</nav>
<section id="welcome-section">
<h1 class="welcome-header">Hi, I'm Timothy McMasters</h1>
<p class="welcome-para">an aspiring full-stack developer</p>
</section>
<section id="projects">
<h2 class="projects-header">The following are projects that I have created</h2>
<ul class="grid-container">
<li class="grid-box">
<a class="project-tile" href="https://codepen.io/tmmcmasters/full/QWOEXyO" target="_blank"><img src="https://i.ibb.co/3B42dcS/Form-Survey.png" class="project-image" alt="Form-Survey">Form Survey</img>
</a>
</li>
<li class="grid-box">
<a class="project-tile" href="https://codepen.io/tmmcmasters/full/zYPNdoX" target="_blank"><img src="https://i.ibb.co/wKLyykK/Product-Landing-Page.png" alt="Product-Landing-Page" class="project-image">Product Landing Page</img>
</a>
</li>
<li class="grid-box">
<a class="project-tile" href="https://codepen.io/tmmcmasters/full/MWOmaGJ" target="_blank" class="project-tile"><img src="https://i.ibb.co/0mdYX9X/Techncacal-Documentation-Page.png" alt="Technical-Documentation-Page" class="project-image">Technical Documentation Page</img>
</a>
</li>
<li class="grid-box">
<a href="https://codepen.io/tmmcmasters/full/MWOebeo" target="_blank" class="project-tile"><img src="https://i.ibb.co/tcJcWsw/Tribute-Page.png" alt="Tribute-Page" class="project-image">Tribute Page</img>
</a>
</li>
</ul>
</section>
<section id="contact">
<h2 id="contact-header">Contact Me</h2>
<div class="contact-links">
<ul>
<li><a id="profile-link" href="https://github.com/Tmmcmasters" target="_blank">Github</a></li>
<li><a id="profile-link" href="mailto:tmmcmasters#gmail.com?subject=" feedback " target="_blank ""> Email me </a></li>
<li><a id="profile-link" href="tel:12602672147" target="_blank">Call me</a></li>
</ul>
</div>
</section>
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!
How can I make the containers fit in the page with no left white spaces?
I've tried html, body { margin: 0; padding: 0} besides adding all the content in a principal container than .container {max-width: 100%} but the margin is still there.
html,
body {
margin: 0;
padding: 0;
}
/* blue container, first container */
.header,
.about {
background-color: #1f2937;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 100px;
}
.logo {
color: #F9FAF8;
font-size: 24px;
font-weight: bolder;
display: flex;
padding-left: 150px;
flex: 1 0 auto;
}
.links {
font-size: 18px;
display: flex;
flex-shrink: 0;
gap: 16px;
padding-right: 150px;
}
.link-text {
font-size: 18px;
color: #e5e7eb;
}
a {
text-decoration: none;
}
ul {
list-style-type: none;
}
.about {
display: flex;
justify-content: space-between;
padding-bottom: 100px;
}
.about-text {
padding-left: 150px;
}
.main-text {
color: #F9FAF8;
font-size: 48px;
font-weight: bolder;
width: 350px;
margin-bottom: 5px;
}
.button-one {
background-color: #3882f6;
color: #F9FAF8;
font-weight: bold;
border-radius: 10px;
width: 90px;
height: 20px;
padding: 5px;
text-align: center;
}
.button-one:hover {
color: #F9FAF8;
font-weight: bold;
background-color: #1c5dc5;
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: 90px;
height: 20px;
padding: 5px;
text-align: center;
}
.button-text {
color: #F9FAF8;
}
.button-text:hover {
color: #F9FAF8;
}
.secondary-text {
width: 350px;
margin-bottom: 10px;
font-size: 18px;
color: #e5e7eb;
}
.header-image {
width: 400px;
height: 285px;
display: flex;
flex-shrink: 0;
padding-right: 150px;
padding-bottom: 25px;
}
/* second container, information */
.information-header-text {
font-size: 36px;
color: #1f2937;
font-weight: bolder;
padding-top: 50px;
display: flex;
justify-content: center;
}
.image img {
width: 150px;
height: 155px;
border: 2px solid #3882f6;
border-radius: 15px;
}
.image img:hover {
width: 150px;
height: 155px;
border: 2px solid rgb(56, 130, 246);
border-radius: 15px;
box-shadow: 2px 2px 2px 1px rgba(56, 129, 246, 0.175);
}
.subtext {
color: #1f2937;
width: 150px;
text-align: center;
padding-top: 5px;
padding-bottom: 100px;
}
.image-subtext {
display: flex;
justify-content: center;
align-content: center;
padding-top: 50px;
gap: 40px;
}
/* third container, quote container */
.quote {
background-color: #e5e7eb;
height: 500px;
}
.quote-text {
font-size: 36px;
color: #1f2937;
font-style: italic;
font-weight: lighter;
width: 755px;
padding: 150px 320px;
padding-bottom: 5px;
}
.author {
font-size: 24px;
color: #1f2937;
font-weight: bolder;
padding-top: 5px;
padding-left: 895px;
width: 250px;
display: flex;
flex-shrink: 0;
}
/* fourth container, box action */
.action {
background-color: #F9FAF8;
height: 440px;
display: flex;
justify-content: center;
align-items: center;
}
.box-action {
background-color: #3882f6;
height: 130px;
width: 760px;
border-radius: 10px;
box-shadow: 0 5px 8px 0px rgba(8, 8, 8, 0.145);
display: flex;
justify-content: space-around;
align-items: center;
flex-shrink: 0;
}
.action-title {
font-size: large;
color: #F9FAF8;
font-weight: bolder;
}
.action-subtext {
color: #e5e7eb;
font-weight: lighter;
}
.button-two {
background-color: #3882f6;
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: #3882f6;
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: #3882f6;
}
/* Footer */
.footer {
background-color: #1f2937;
color: #e5e7eb;
font-weight: lighter;
height: 80px;
display: flex;
justify-content: center;
align-items: center;
}
<div class="header">
<div class="logo">your surfboard decals</div>
<ul class="links">
<li><a class="link-text" href="#">home</a></li>
<li><a class="link-text" href="#">about</a></li>
<li><a class="link-text" href="#">contact</a></li>
</div>
</div>
<div class="about">
<div class="about-text">
<div class="main-text">Design your own decals</div>
<div class="secondary-text">Your art can be integrated into the build of your composite products, like surfboards, boats, SUPs, wake surf, paddle blades, skateboards, and even rockets headed for outer space! Literally, the sky is the limit for your creative and decorative potential.</div>
<div class="button-one">
<a class="button-text" href="#">Sign up</a>
</div>
</div>
<img class="header-image" src="./images/surfboards.jpg">
</div>
<div class="information">
<div class="information-header-text">Some of our customers arts</div>
<div class="image-subtext">
<div class="one">
<a href="https://storage.covet.pics/posts/5647583/standard_resolution/ff93db0981b0895fe2c4ac4120125f709d6908eb.jpg">
<div class="image"><img src="./images/design-one.jpg" alt="A man holding his board on his head"></div>
</a>
<div class="subtext">A man holding his board on his head</div>
</div>
<div class="two">
<a href="https://storage.covet.pics/posts/15039645/standard_resolution/e13ff9cc00e8119f16a324727ceb9b86">
<div class="image"><img src="./images/design-two.jpeg" alt="A white furry fluffy dog"></div>
</a>
<div class="subtext">A white furry fluffy dog</div>
</div>
<div class="three">
<a href="https://storage.covet.pics/postassets/7301301/standard_resolution/6913516f4a17a437faa32e83cd569e46">
<div class="image"><img src="./images/design-three.jpeg" alt="A logo with multiple colors"></div>
</a>
<div class="subtext">A logo with multiple colors</div>
</div>
<div class="four">
<a href="https://storage.covet.pics/posts/15087630/standard_resolution/9f218611200c504424b84a41b70c331b">
<div class="image"><img src="./images/design-four.jpeg" alt="Multiple surfboard stickers"> </div>
</a>
<div class="subtext">Multiple surfboard stickers</div>
</div>
</div>
<div class="quote">
<div class="quote-text">
You never really know what's coming. A small wave, or maybe a big one. All you can really do is hope that when it comes, you can surf over it, instead of drown in its monstrosity.
</div>
<div class="author">
- Alysha Speer
</div>
</div>
</div>
<div class="action">
<div class="box-action">
<div class="action-text">
<div class="action-title">Design your own art!</div>
<div class="action-subtext">Sign up for creating your art by clicking that button right over there!
</div>
</div>
<div class="button-two">
<a class="button-text-two" href="#">Sign up</a>
</div>
</div>
</div>
<div class="footer">
Copyright © The Odin Project 2023
</div>
enter image description
I am just practicing CSS/HTML and am trying to make a google clone. Everything else seems fine but now I am trying to make a footer and whenever I put a div inside the footer, they appear on top of the footer instead of inside the footer.
#import url('https://fonts.googleapis.com/css2?family=Roboto:wght#300;400;700&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
background-color: rgb(32, 33, 36);
color: white;
}
a {
text-decoration: none;
color: inherit;
}
.nav-bar a:nth-child(1):hover {
text-decoration: underline;
}
.nav-bar a:nth-child(2):hover {
text-decoration: underline;
}
.nav-bar {
height: 50px;
display: flex;
align-items: center;
justify-content: flex-end;
}
.nav-items {
list-style: none;
display: flex;
justify-content: flex-end;
align-items: center;
}
.nav-items li {
margin-left: 15px;
}
.menu-icon {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
width: 40px;
height: 40px;
padding: 10px;
border-radius: 50%;
}
.menu-icon:hover {
background-color: rgba(138, 133, 133, 0.26);
}
.menu-icon span {
background-color: #ffffff;
width: 20px;
height: 2px;
}
.profile-picture {
margin-right: 15px;
height: 32px;
width: 32px;
border-radius: 50%;
}
.profile-picture:hover {
box-shadow: 0px 0px 0px 5px #7068683b;
}
.profile-picture img {
border-radius: 50%;
width: 100%;
}
.main-section {
display: flex;
justify-content: center;
align-items: center;
margin-top: 80px;
}
.google-logo {
width: 375px;
height: 150px;
}
.google-logo img {
width: 100%;
}
.search-section {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.search-container {
display: flex;
justify-content: center;
align-items: center;
width: 580px;
border: solid;
border-color: #949090;
border-width: 1px;
border-radius: 300px;
padding: 9px;
height: 45px;
}
.search-container:hover {
box-shadow: 0px 0px 10px 2px #00000036;
}
.search-icon {
width: 25px;
height: 25px;
margin-right: 5px;
}
.search-icon img {
width: 100%;
}
.search-bar {
width: 550px;
height: 30px;
border: none;
outline: none;
}
.microphone {
width: 25px;
height: 25px;
}
.microphone img {
width: 100%;
}
.search-buttons {
margin-top: 25px;
}
.search-buttons button {
margin-left: 6px;
padding: 10px 16px 10px 16px;
background-color: #303134;
border: none;
border-radius: 4px;
color: #e8eaed;
font-size: 14px;
cursor: pointer;
border: solid 1px transparent;
}
.search-buttons button:hover {
border-color: #e8eaed;
}
.language-selector {
display: flex;
justify-content: center;
margin-top: 30px;
}
.language-selector p {
font-size: 13px;
color: #bdc1c6;
}
.language-selector a {
color: #8ab4f8;
}
.footer {
background-color: #446adb;
height: 100px;
margin-top: 92px;
}
<body>
<!-- start of the navigation bar-->
<nav class="nav-bar">
<ul class="nav-items">
<li>Gmail</li>
<li>სურათები</li>
<li>
<a href="#">
<div class="menu-icon">
<span>
</span>
<span>
</span>
<span>
</span>
</div>
</a>
</li>
<li>
<a href="#"><div class="profile-picture">
<img src="icons/unnamed.png">
</div></a>
</li>
</ul>
</nav>
<!-- end of the navigation bar -->
<!-- start of the main section (logo and search-bar)-->
<div class="main-section">
<a href="#"><div class="google-logo">
<img src="icons/google.png">
</div></a>
</div>
<div class="search-section">
<div class="search-container">
<div class="search-icon"><img src="icons/search.png"/></div>
<input type="text" class="search-bar">
<div class="microphone"><img src="icons/micro.png" alt=""></div>
</div>
<div class="search-buttons">
<button>
Google ძებნა
</button>
<button>
იღბალს მივენდობი
</button>
</div>
</div>
<div class="language-selector">
<p>Google ხელმისაწვდომია შემდეგ ენაზე: English</p>
</div>
<!-- end of the main section -->
<!-- start of the footer-->
<footer class="footer">
<div class="current-location">
this text should be inside the footer
</div>
</footer>
</body>
here is the picture of the problem I am having.
https://i.stack.imgur.com/AXMv6.png
It is inside the footer. Just this property:
background-color: rgb(32, 33, 36);
which you set for * gets inherited, and the bg color makes you think text it outside the footer. Comment it out for a while and you will see.
So on this one challenge I keep getting the error: "The height of the welcome section should be equal to the height of the viewport." I have 100vh on it but im not sure how to fix it.
html:
<header>
<nav id="navbar">
<a href="#welcome-section" id="logo-link">
<h1>Welcome</h1>
</a>
<ul class="nav-list">
<a href="#projects">
<li>Projects</li>
</a>
<a href="#profile">
<li>Profile</li>
</a>
<a href="#contact">
<li>Contact</li>
</a>
</ul>
</nav>
</header>
<!--BODY-->
<body>
<section id="welcome-section">
<div class="header-text">
<h1><code>Hello World!</code></h1>
<p>My name is Nick</p>
</div>
</section>
css:
#navbar {
position: fixed;
top: 0;
height: 80px;
width: 100%;
background-color: #007cc7;
display: flex;
justify-content: space-between;
z-index: 5;
}
.nav-list {
display: flex;
margin-right: 20px;
margin-top: auto;
margin-bottom: auto;
}
.nav-list a {
display: block;
font-size: 1.5rem;
padding: 10px;
color: white;
}
.nav-list a:hover {
color: cyan;
}
#logo-link {
color: white;
margin-top: auto;
margin-bottom: auto;
margin-left: 10px;
font-size: 1.5rem;
}
#welcome-section {
height: 100vh;
margin-top: 20px;
text-align: center;
background-color: #12232e;
border-style: solid;
border-color: #203647;
border-width: 10px;
border-top: 0;
border-right: 0;
border-left: 0;
display: flex;
}
.header-text {
margin: auto;
}
#welcome-section h1 {
font-size: 5rem;
}
#welcome-section p {
font-size: 1.5rem;
}
Link to the challenge: https://www.freecodecamp.org/learn/responsive-web-design/responsive-web-design-projects/build-a-personal-portfolio-webpage
Working Demo: https://dojo.telerik.com/EkoCUneS/2
You need to add
* {
box-sizing: border-box;
}
html, body {
margin: 0;
padding: 0;
}
Remove margin-top from #welcome-section.
* {
box-sizing: border-box;
}
html, body {
margin: 0;
padding: 0;
}
#navbar {
position: fixed;
top: 0;
height: 80px;
width: 100%;
background-color: #007cc7;
display: flex;
justify-content: space-between;
z-index: 5;
}
.nav-list {
display: flex;
margin-right: 20px;
margin-top: auto;
margin-bottom: auto;
}
.nav-list a {
display: block;
font-size: 1.5rem;
padding: 10px;
color: white;
}
.nav-list a:hover {
color: cyan;
}
#logo-link {
color: white;
margin-top: auto;
margin-bottom: auto;
margin-left: 10px;
font-size: 1.5rem;
}
#welcome-section {
height: 100vh;
text-align: center;
background-color: #12232e;
border-style: solid;
border-color: #203647;
border-width: 10px;
border-top: 0;
border-right: 0;
border-left: 0;
display: flex;
}
.header-text {
margin: auto;
}
#welcome-section h1 {
font-size: 5rem;
}
#welcome-section p {
font-size: 1.5rem;
}
<header>
<nav id="navbar">
<a href="#welcome-section" id="logo-link">
<h1>Welcome</h1>
</a>
<ul class="nav-list">
<a href="#projects">
<li>Projects</li>
</a>
<a href="#profile">
<li>Profile</li>
</a>
<a href="#contact">
<li>Contact</li>
</a>
</ul>
</nav>
</header>
<!--BODY-->
<body>
<section id="welcome-section">
<div class="header-text">
<h1><code>Hello World!</code></h1>
<p>My name is Nick</p>
</div>
</section>
</body>
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.