Div in section not behaving as expected - html

I have problem with div in my section i want it to follow the picture image (to be in line with it ) like this:
But instead it just stays on the left side like this:
I tried changing some styles and div position inside my HTML but nothing seems to work
My code is available at: https://codepen.io/wodosharlatan/pen/jOpLVBQ?editors=1100
Any help is appreciated, but please try to make it as responsive as possible. Thanks

Based on your codepen, just change your image width from 256px to 100%.
CSS like this:
.portfolio__img {
width : 100% ; /* change width */
height : auto ; /* add height auto */
border-radius : 0.5rem ;
justify-self : center ;
}

TLDR
use width:max-content on class .portfolio__content
Result
Explanation
When you use the CSS property width: max-content, you are telling the browser to make the width of an element as small as possible while still being able to fit all the content inside it.
It will automatically adjust the width of the element to the widest item within it.
this is working fine since you have a specific width for the images, so the width of the card is like this logic padding size + image width
More details
https://developer.mozilla.org/en-US/docs/Web/CSS/max-content
Modified code
/*==================== GOOGLE FONTS ====================*/
#import url("https://fonts.googleapis.com/css2?family=Poppins:wght#400;500;600&display=swap");
/*==================== VARIABLES CSS ====================*/
:root {
--header-height: 3rem;
/*========== Colors ==========*/
/* Change favorite color */
--hue-color: 255;
/*Purple 250 - Green 142 - Blue 230 - Pink 340*/
/* HSL color mode */
--first-color: hsl(var(--hue-color), 69%, 61%);
--first-color-second: hsl(var(--hue-color), 69%, 61%);
--first-color-alt: hsl(var(--hue-color), 57%, 53%);
--first-color-lighter: hsl(var(--hue-color), 92%, 85%);
--title-color: hsl(var(--hue-color), 8%, 15%);
--text-color: hsl(var(--hue-color), 8%, 45%);
--text-color-light: hsl(var(--hue-color), 8%, 65%);
--input-color: hsl(var(--hue-color), 70%, 96%);
--body-color: hsl(var(--hue-color), 60%, 99%);
--container-color: #fff;
--scroll-bar-color: hsl(var(--hue-color), 12%, 90%);
--scroll-thumb-color: hsl(var(--hue-color), 12%, 80%);
/*========== Font and typography ==========*/
--body-font: "Poppins", sans-serif;
/* .5rem = 8px, 1rem = 16px, 1.5rem = 24px ... */
--big-font-size: 2rem;
--h1-font-size: 1.5rem;
--h2-font-size: 1.25rem;
--h3-font-size: 1.125rem;
--normal-font-size: 0.938rem;
--small-font-size: 0.813rem;
--smaller-font-size: 0.75rem;
/*========== Font weight ==========*/
--font-medium: 500;
--font-semi-bold: 600;
/*========== Margenes Bottom ==========*/
/* .25rem = 4px, .5rem = 8px, .75rem = 12px ... */
--mb-0-25: 0.25rem;
--mb-0-5: 0.5rem;
--mb-0-75: 0.75rem;
--mb-1: 1rem;
--mb-1-5: 1.5rem;
--mb-2: 2rem;
--mb-2-5: 2.5rem;
--mb-3: 3rem;
/*========== z index ==========*/
--z-tooltip: 10;
--z-fixed: 100;
--z-modal: 1000;
}
/* Font size for large devices */
#media screen and (min-width: 968px) {
:root {
--big-font-size: 3rem;
--h1-font-size: 2.25rem;
--h2-font-size: 1.5rem;
--h3-font-size: 1.25rem;
--normal-font-size: 1rem;
--small-font-size: 0.875rem;
--smaller-font-size: 0.813rem;
}
}
/*========== Variables Dark theme ==========*/
/*========== Button Dark/Light ==========*/
/*==================== BASE ====================*/
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
html {
scroll-behavior: smooth;
}
body {
margin: 0 0 var(--header-height) 0;
font-family: var(--body-font);
font-size: var(--normal-font-size);
background-color: var(--body-color);
color: var(--text-color);
}
h1,
h2,
h3,
h4 {
color: var(--title-color);
font-weight: var(--font-semi-bold);
}
ul {
list-style: none;
}
a {
text-decoration: none;
}
img {
max-width: 100%;
height: auto;
}
/*==================== REUSABLE CSS CLASSES ====================*/
.section {
padding: 2rem 0 4rem;
}
.section__title {
font-size: var(--h1-font-size);
color: var(--title-color);
}
.section__subtitle {
display: block;
font-size: var(--small-font-size);
margin-bottom: var(--mb-3);
}
.section__title,
.section__subtitle {
text-align: center;
}
/*==================== LAYOUT ====================*/
.container {
max-width: 768px;
margin-left: var(--mb-1-5);
margin-right: var(--mb-1-5);
}
.grid {
display: grid;
gap: 1.5rem;
}
.header {
width: 100%;
position: fixed;
bottom: 0;
left: 0;
z-index: var(--z-fixed);
background-color: var(--body-color);
}
/*==================== BUTTONS ====================*/
.button {
display: inline-block;
background-color: var(--first-color);
color: #fff;
padding: 1rem;
border-radius: 0.5rem;
font-weight: var(--font-medium);
}
.button:hover {
background-color: var(--first-color-alt);
}
.button__icon {
font-size: 1.25rem;
margin-left: var(--mb-0-5);
transition: 0.5s;
}
.button--flex {
display: inline-flex;
align-items: center;
}
.button--small {
padding: 0.75rem 1rem;
}
.button--link {
padding: 0;
background-color: transparent;
color: var(--first-color);
}
.button--link:hover {
background-color: transparent;
color: var(--first-color-alt);
}
/*==================== PORTFOLIO ====================*/
.portfolio__container {
overflow: initial;
}
.portfolio__content {
padding: 0 1.5rem;
width: max-content;
/* line of code added from stackoverflow answer */
}
.portfolio__img {
width: 256px;
border-radius: 0.5rem;
justify-self: center;
}
.portfolio__title {
font-size: var(--h3-font-size);
margin-bottom: var(--mb-0-5);
}
.portfolio__description {
margin-bottom: var(--mb-0-75);
}
.portfolio__button:hover .button__icon {
transform: translate(0.25rem);
}
.swiper-button-prev::after,
.swiper-button-next::after {
content: "";
}
.swiper-portfolio-icon {
font-size: 2rem;
color: var(--first-color);
}
.swiper-button-prev {
left: -0.5rem;
}
.swiper-button-next {
right: -0.5rem;
}
.swiper-button-prev,
.swiper-button-next {
outline: none;
}
<section class="portfolio section" id="portfolio">
<h2 class="section__title">Portfolio</h2>
<span class="section__subtitle">Most recent work</span>
<div class="portfolio__container container swiper-container">
<div class="swiper-wrapper">
<!--=================== PORTFOLIO 1 ===================-->
<div class="portfolio__content grid swiper-slide">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQD3U1qBRmQOSJkBX5kmNbdrR_Q7InY1Q4zLEH0fZAjxg&s" alt="" class="portfolio__img" />
<div class="portfolio__data">
<h3 class="portfolio__title">Error 404</h3>
<p class="portfolio__description">Page not found</p>
<a href="#" class="button button--flex button--small portfolio__button">
Demo
<i class="uil uil-arrow-right button__icon"></i>
</a>
</div>
</div>
</div>
</div>
</section>

Related

Responsiveness issues with my project (image & footer acting weird)

I'm having the following issues : when switching on a resolution between 600px - 1024px, my image is acting weird and is not "stretching" (using full space available) as it's supposed to & my footer is not staying at the bottom of the page when changing resolution.
I tried multiple ways to fix it; modifying the min-width of my .card container, playing around with the media query values but unfortunately I didn't manage to find a solution. Same for the footer, changing the footer's position property and adding a media query to it didn't solve it either.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png" />
<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=Inter:wght#400;700&family=Lexend+Deca&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="reset.css" />
<link rel="stylesheet" href="style.css" />
<title>Frontend Mentor | Stats preview card component</title>
</head>
<body>
<main>
<article class="card">
<div class="card__content">
<h1 class="card__content--title">
Get
<span class="pretty">insights</span>
that help your business grow.
</h1>
<p class="card__content--text">
Discover the benefits of data analytics and make better decisions regarding revenue, customer experience, and overall efficiency.
</p>
<div class="card__content--stats">
<div class="flex-group">
<div class="companies">
<p class="stats-numbers">10k+</p>
<p class="stats-text">companies</p>
</div>
<div class="templates">
<p class="stats-numbers">314</p>
<p class="stats-text">templates</p>
</div>
<div class="queries">
<p class="stats-numbers">12M+</p>
<p class="stats-text">queries</p>
</div>
</div>
</div>
</div>
<div class="card__img">
<picture class="card__img--image">
<source srcset="https://i.imgur.com/wlktPe0.jpg" media="(min-width: 600px)" />
<img src="https://imgur.com/HCLtExf" alt="" />
</picture>
</div>
</article>
</main>
<footer>
<div class="attribution">
Coded by
Wilson.
</div>
</footer>
</body>
</html>
/*
1. Use a more-intuitive box-sizing model.
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
/*
2. Remove default margin
*/
* {
margin: 0;
}
/*
3. Allow percentage-based heights in the application
*/
/* html, body {
height: 100%;
} */
/*
Typographic tweaks!
4. Add accessible line-height
5. Improve text rendering
*/
body {
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
/*
6. Improve media defaults
*/
img,
picture,
video,
canvas,
svg {
display: block;
max-width: 100%;
}
/*
7. Remove built-in form typography styles
*/
input,
button,
textarea,
select {
font: inherit;
}
/*
8. Avoid text overflows
*/
p,
h1,
h2,
h3,
h4,
h5,
h6 {
overflow-wrap: break-word;
}
/*
9. Create a root stacking context
*/
#root,
#__next {
isolation: isolate;
}
:root {
--clr-primary-main-background: hsl(233, 47%, 7%);
--clr-primary-card-background: hsl(244, 38%, 16%);
--clr-primary-accent: hsl(277, 64%, 61%);
--clr-neutral-main-heading: hsl(0, 0%, 100%);
--clr-neutral-main-paragraph: hsla(0, 0%, 100%, 0.75);
--clr-neutral-stats-headings: hsla(0, 0%, 100%, 0.6);
--fs-regular: 0.938rem;
--ff-regular: "Inter", sans-serif;
--ff-special: "Lexend Deca", sans-serif;
--fw-regular: 400;
--fw-bold: 700;
}
/* general styling */
body {
font-family: var(--ff-regular);
font-weight: var(--fw-regular);
color: var(--clr-neutral-main-paragraph);
font-size: var(--fs-regular);
background-color: var(--clr-primary-main-background);
/* specific */
display: grid;
place-content: center;
min-height: 100vh;
}
/* utilities */
.flex-group {
display: flex;
flex-direction: column;
gap: 1.4rem;
flex-wrap: wrap;
}
/* card styles */
.card {
display: grid;
border-radius: 0.5rem;
overflow: hidden;
background-color: var(--clr-primary-card-background);
text-align: center;
max-width: 1024px;
margin: 5rem 1.5rem;
}
.card__content {
display: grid;
gap: 1.5rem;
padding: 2rem;
grid-row: 2;
}
.card__content--title {
font-size: 1.7rem;
font-weight: var(--fw-bold);
color: var(--clr-neutral-main-heading);
line-height: 2rem;
}
.pretty {
color: var(--clr-primary-accent);
}
.card__content--text {
margin-top: -0.5rem;
line-height: 1.5rem;
}
.card__content--stats {
margin-top: 1rem;
}
.stats-numbers {
color: var(--clr-neutral-main-heading);
font-weight: var(--fw-bold);
font-size: 1.25rem;
margin-bottom: 0.2rem;
}
.stats-text {
font-family: var(--ff-special);
text-transform: uppercase;
font-size: 0.75rem;
letter-spacing: 0.05rem;
}
.card__img {
position: relative;
}
.card__img::after {
position: absolute;
content: "";
width: 100%;
height: 100%;
left: 0;
top: 0;
background-color: rgba(83, 0, 138, 0.5);
}
#media (min-width: 1024px) {
.card {
grid-template-columns: 1fr 1fr;
}
.card__content {
text-align: left;
grid-row: 1;
margin: 2rem;
padding-right: 3.5rem;
padding: -1rem;
}
.card__content--title {
font-size: 2rem;
line-height: 2.5rem;
}
.card__content--text {
line-height: 1.5rem;
}
.flex-group {
flex-direction: row;
justify-content: space-between;
}
}
/* footer */
footer {
width: 100%;
position: fixed;
bottom: 0;
}
.attribution {
font-size: 11px;
text-align: center;
}
.attribution a {
color: hsl(228, 45%, 44%);
}
This is because you don't set the image width to 100% anywhere. If you use width: 100%, referring to the image in question, you will get the desired result.
For the footer instead the problem is the position: fixed. The latter specifies a fixed position for an element, meaning it will remain in the same place on the screen even if the page is scrolled.
/*
1. Use a more-intuitive box-sizing model.
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
/*
2. Remove default margin
*/
* {
margin: 0;
}
/*
3. Allow percentage-based heights in the application
*/
/* html, body {
height: 100%;
} */
/*
Typographic tweaks!
4. Add accessible line-height
5. Improve text rendering
*/
body {
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
/*
6. Improve media defaults
*/
img,
picture,
video,
canvas,
svg {
display: block;
max-width: 100%;
}
/*
7. Remove built-in form typography styles
*/
input,
button,
textarea,
select {
font: inherit;
}
/*
8. Avoid text overflows
*/
p,
h1,
h2,
h3,
h4,
h5,
h6 {
overflow-wrap: break-word;
}
/*
9. Create a root stacking context
*/
#root,
#__next {
isolation: isolate;
}
:root {
--clr-primary-main-background: hsl(233, 47%, 7%);
--clr-primary-card-background: hsl(244, 38%, 16%);
--clr-primary-accent: hsl(277, 64%, 61%);
--clr-neutral-main-heading: hsl(0, 0%, 100%);
--clr-neutral-main-paragraph: hsla(0, 0%, 100%, 0.75);
--clr-neutral-stats-headings: hsla(0, 0%, 100%, 0.6);
--fs-regular: 0.938rem;
--ff-regular: "Inter", sans-serif;
--ff-special: "Lexend Deca", sans-serif;
--fw-regular: 400;
--fw-bold: 700;
}
/* general styling */
body {
font-family: var(--ff-regular);
font-weight: var(--fw-regular);
color: var(--clr-neutral-main-paragraph);
font-size: var(--fs-regular);
background-color: var(--clr-primary-main-background);
/* specific */
display: grid;
place-content: center;
min-height: 100vh;
}
/* utilities */
.flex-group {
display: flex;
flex-direction: column;
gap: 1.4rem;
flex-wrap: wrap;
}
/* card styles */
.card {
display: grid;
border-radius: 0.5rem;
overflow: hidden;
background-color: var(--clr-primary-card-background);
text-align: center;
max-width: 1024px;
margin: 5rem 1.5rem;
}
.card__content {
display: grid;
gap: 1.5rem;
padding: 2rem;
grid-row: 2;
}
.card__content--title {
font-size: 1.7rem;
font-weight: var(--fw-bold);
color: var(--clr-neutral-main-heading);
line-height: 2rem;
}
.pretty {
color: var(--clr-primary-accent);
}
.card__content--text {
margin-top: -0.5rem;
line-height: 1.5rem;
}
.card__content--stats {
margin-top: 1rem;
}
.stats-numbers {
color: var(--clr-neutral-main-heading);
font-weight: var(--fw-bold);
font-size: 1.25rem;
margin-bottom: 0.2rem;
}
.stats-text {
font-family: var(--ff-special);
text-transform: uppercase;
font-size: 0.75rem;
letter-spacing: 0.05rem;
}
.card__img {
position: relative;
}
.card__img img {
width: 100%;
}
.card__img::after {
position: absolute;
content: "";
width: 100%;
height: 100%;
left: 0;
top: 0;
background-color: rgba(83, 0, 138, 0.5);
}
#media (min-width: 1024px) {
.card {
grid-template-columns: 1fr 1fr;
}
.card__content {
text-align: left;
grid-row: 1;
margin: 2rem;
padding-right: 3.5rem;
padding: -1rem;
}
.card__content--title {
font-size: 2rem;
line-height: 2.5rem;
}
.card__content--text {
line-height: 1.5rem;
}
.flex-group {
flex-direction: row;
justify-content: space-between;
}
}
/* footer */
footer {
width: 100%;
position: relative;
bottom: 0;
}
.attribution {
font-size: 11px;
text-align: center;
}
.attribution a {
color: hsl(228, 45%, 44%);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png" />
<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=Inter:wght#400;700&family=Lexend+Deca&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="reset.css" />
<link rel="stylesheet" href="style.css" />
<title>Frontend Mentor | Stats preview card component</title>
</head>
<body>
<main>
<article class="card">
<div class="card__content">
<h1 class="card__content--title">
Get
<span class="pretty">insights</span>
that help your business grow.
</h1>
<p class="card__content--text">
Discover the benefits of data analytics and make better decisions regarding revenue, customer experience, and overall efficiency.
</p>
<div class="card__content--stats">
<div class="flex-group">
<div class="companies">
<p class="stats-numbers">10k+</p>
<p class="stats-text">companies</p>
</div>
<div class="templates">
<p class="stats-numbers">314</p>
<p class="stats-text">templates</p>
</div>
<div class="queries">
<p class="stats-numbers">12M+</p>
<p class="stats-text">queries</p>
</div>
</div>
</div>
</div>
<div class="card__img">
<picture class="card__img--image">
<source srcset="https://i.imgur.com/wlktPe0.jpg" media="(min-width: 600px)" />
<img src="https://imgur.com/HCLtExf" alt="" />
</picture>
</div>
</article>
</main>
<footer>
<div class="attribution">
Coded by
Wilson.
</div>
</footer>
</body>
</html>

CSS media queries are selectively not working

Thank you in advance.
I'm working on the mobile responsiveness of a challenge project and my media queries are only selectively working. Here is my full HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- displays site properly based on user's device -->
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Frontend Mentor | Sunnyside agency landing page</title>
</head>
<body>
<section class="splash_page">
<header>
<nav class="navbar">
<img src="./images/logo.svg" class="sunnyside_logo" alt="sunnyside_logo">
<ul class="nav_links">
<li>About</li>
<li>Services</li>
<li>Projects</li>
<li>Contact</li>
</ul>
</nav>
</header>
<div class="intro_screen">
<h2>We are creatives</h2>
<img src="images/icon-arrow-down.svg" />
</div>
</section>
<section class="grid_card">
<div class="card_information">
<div class="transform_information_container">
<h2>Transform your brand</h2>
<p>We are a full-service creative agency specializing in helping brands grow fast.
Engage your clients through compelling visuals that do most of the marketing for you.</p>
<a>Learn More</a>
</div>
</div>
<div class="card_image">
<img src="./images/desktop/image-transform.jpg" />
</div>
</section>
<section class="grid_card_2">
<div class="card_information">
<div class="stand_out_information_container">
<h2>Stand out to the right audience</h2>
<p> Using a collaborative formula of designers, researchers, photographers, videographers, and copywriters,
we’ll build and extend your brand in digital places.
</p>
<a>Learn More</a>
</div>
</div>
<div class="card_image">
<img src="./images/desktop/image-stand-out.jpg" />
</div>
</section>
<section class="grid_card_3">
<div class="card_image">
<div class="graphic_design_text">
<h2> Graphic Design</h2>
<p>Great design makes you memorable. We deliver artwork that underscores your brand message and captures
potential clients’ attention.
</p>
</div>
<img src="./images/desktop/image-graphic-design.jpg" />
</div>
<div class="card_image">
<div class="photography_text">
<h2>Photography</h2>
<p>Increase your credibility by getting the most stunning, high-quality photos that improve your business image.
</p>
</div>
<img src="./images/desktop/image-photography.jpg" />
</div>
</div>
</section>
<section class="testimonials">
<h2>Client Testimonials</h2>
<div class="testimonial_group">
<div class="single_testimonial">
<img src="images/image-emily.jpg" />
<p> We put our trust in Sunnyside and they delivered, making sure our needs were met and deadlines were always
hit.
</p>
<h3 class="testimonial_name">
Emily R.
</h3>
<small>Marketing Director</small>
</div>
<div class="single_testimonial">
<img src="images/image-thomas.jpg" />
<p> Sunnyside’s enthusiasm coupled with their keen interest in our brand’s success made it a satisfying and
enjoyable experience.
</p>
<h3 class="testimonial_name">
Thomas S.
</h3>
<small>Chief Operating Officer</small>
</div>
<div class="single_testimonial">
<img src="images/image-jennie.jpg" />
<p> Incredible end result! Our sales increased over 400% when we worked with Sunnyside. Highly recommended!
</p>
<h3 class="testimonial_name">
Jennie F.
</h3>
<small>Business Owner</small>
</div>
</div>
</section>
<section class="footer">
<div class="image_banner">
<img src="./images/desktop/image-gallery-milkbottles.jpg">
<img src="./images/desktop/image-gallery-orange.jpg">
<img src="./images/desktop/image-gallery-cone.jpg">
<img src="./images/desktop/image-gallery-sugarcubes.jpg">
</div>
<div class="banner_information">
<img src="./images/logo-footer.svg" class="logo_footer"/>
<div class="footer_nav">
<p>About</p>
<p>Services</p>
<p>Projects</p>
</div>
<div class="footer_links">
<svg class="facebook_logo" width="20" height="20" xmlns="http://www.w3.org/2000/svg"><path d="M18.896 0H1.104C.494 0 0 .494 0 1.104v17.793C0 19.506.494 20 1.104 20h9.58v-7.745H8.076V9.237h2.606V7.01c0-2.583 1.578-3.99 3.883-3.99 1.104 0 2.052.082 2.329.119v2.7h-1.598c-1.254 0-1.496.597-1.496 1.47v1.928h2.989l-.39 3.018h-2.6V20h5.098c.608 0 1.102-.494 1.102-1.104V1.104C20 .494 19.506 0 18.896 0z" fill="#2C7566" fill-rule="nonzero"/></svg>
<svg class="instagram_logo" width="20" height="20" xmlns="http://www.w3.org/2000/svg"><path d="M10 1.802c2.67 0 2.987.01 4.042.059 2.71.123 3.975 1.409 4.099 4.099.048 1.054.057 1.37.057 4.04 0 2.672-.01 2.988-.057 4.042-.124 2.687-1.387 3.975-4.1 4.099-1.054.048-1.37.058-4.041.058-2.67 0-2.987-.01-4.04-.058-2.718-.124-3.977-1.416-4.1-4.1-.048-1.054-.058-1.37-.058-4.041 0-2.67.01-2.986.058-4.04.124-2.69 1.387-3.977 4.1-4.1 1.054-.048 1.37-.058 4.04-.058zM10 0C7.284 0 6.944.012 5.877.06 2.246.227.227 2.242.061 5.877.01 6.944 0 7.284 0 10s.012 3.057.06 4.123c.167 3.632 2.182 5.65 5.817 5.817 1.067.048 1.407.06 4.123.06s3.057-.012 4.123-.06c3.629-.167 5.652-2.182 5.816-5.817.05-1.066.061-1.407.061-4.123s-.012-3.056-.06-4.122C19.777 2.249 17.76.228 14.124.06 13.057.01 12.716 0 10 0zm0 4.865a5.135 5.135 0 100 10.27 5.135 5.135 0 000-10.27zm0 8.468a3.333 3.333 0 110-6.666 3.333 3.333 0 010 6.666zm5.338-9.87a1.2 1.2 0 100 2.4 1.2 1.2 0 000-2.4z" fill="#2C7566" fill-rule="nonzero"/></svg>
<svg class="twitter_logo" width="20" height="17" xmlns="http://www.w3.org/2000/svg"><path d="M20 2.172a8.192 8.192 0 01-2.357.646 4.11 4.11 0 001.805-2.27 8.22 8.22 0 01-2.606.996A4.096 4.096 0 0013.847.248c-2.65 0-4.596 2.472-3.998 5.037A11.648 11.648 0 011.392 1a4.109 4.109 0 001.27 5.478 4.086 4.086 0 01-1.858-.513c-.045 1.9 1.318 3.679 3.291 4.075a4.113 4.113 0 01-1.853.07 4.106 4.106 0 003.833 2.849A8.25 8.25 0 010 14.658a11.616 11.616 0 006.29 1.843c7.618 0 11.923-6.434 11.663-12.205A8.354 8.354 0 0020 2.172z" fill="#2C7566" fill-rule="nonzero"/></svg>
<svg class="pinterest_logo" width="20" height="20" xmlns="http://www.w3.org/2000/svg"><path d="M10 0C4.477 0 0 4.477 0 10c0 4.237 2.636 7.855 6.356 9.312-.088-.791-.167-2.005.035-2.868.181-.78 1.172-4.97 1.172-4.97s-.299-.6-.299-1.486c0-1.39.806-2.428 1.81-2.428.852 0 1.264.64 1.264 1.408 0 .858-.546 2.14-.828 3.33-.236.995.5 1.807 1.48 1.807 1.778 0 3.144-1.874 3.144-4.58 0-2.393-1.72-4.068-4.176-4.068-2.845 0-4.516 2.135-4.516 4.34 0 .859.331 1.781.745 2.281a.3.3 0 01.069.288l-.278 1.133c-.044.183-.145.223-.335.134-1.249-.581-2.03-2.407-2.03-3.874 0-3.154 2.292-6.052 6.608-6.052 3.469 0 6.165 2.473 6.165 5.776 0 3.447-2.173 6.22-5.19 6.22-1.013 0-1.965-.525-2.291-1.148l-.623 2.378c-.226.869-.835 1.958-1.244 2.621.937.29 1.931.446 2.962.446 5.523 0 10-4.477 10-10S15.523 0 10 0z" fill="#2C7566" fill-rule="nonzero"/></svg>
</div>
</div>
</section>
<script src="script.js"></script>
</body>
</html>
Here is the entire CSS:
#import url('https://fonts.googleapis.com/css2?family=Barlow:wght#600&family=Fraunces:wght#700;900&display=swap');
:root {
--Soft-red: hsl(7, 99%, 70%);
--Yellow: hsl(51, 100%, 49%);
--Dark-desaturated-cyan: hsl(167, 40%, 24%);
--Dark-blue: hsl(198, 62%, 26%);
--Dark-moderate-cyan: hsl(168, 34%, 41%);
--Very-dark-desaturated-blue: hsl(212, 27%, 19%);
--Very-dark-grayish-blue: hsl(213, 9%, 39%);
--Dark-grayish-blue: hsl(232, 10%, 55%);
--Grayish-blue: hsl(210, 4%, 67%);
--White: hsl(0, 0%, 100%);
}
* {
box-sizing: border-box;
}
html, body {
padding: 0;
margin: 0;
height: 100vh;
font-size: 18px;
}
h2, p, h3 {
margin: 0;
padding: 0;
}
.splash_page {
height: 100vh;
width: 100%;
background-image: url('./images/desktop/image-header.jpg');
background-position: center;
background-size: cover;
background-repeat: no-repeat;
font-family: "Barlow";
}
.navbar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 2em 3em;
}
.navbar > .nav_links {
display: flex;
list-style: none;
align-items: center;
justify-content: space-between;
margin: 0;
width: 35%;
}
.navbar > .nav_links > li {
font-size: .90em;
}
.navbar > .nav_links > li > a {
text-decoration: none;
color: white;
}
.navbar > .sunnyside_logo {
width: 10em;
}
.navbar > .nav_links > li > .contact_button {
background-color: white;
padding: 1.25em 2em;
color: var(--Very-dark-desaturated-blue);
font-family: "Fraunces";
font-size: .85em;
font-weight: 900;
text-transform: uppercase;
border-radius: 30px;
}
.navbar > .nav_links > li > .contact_button:hover {
background-color: hsl(199, 100%, 75%);
color: white;
transition: .15s;
}
.intro_screen {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.intro_screen > h2 {
font-family: "Fraunces";
font-weight: 900;
font-size: 3.5em;
letter-spacing: .1em;
text-transform: uppercase;
color: white;
margin: 2em 0 1.65em 0;
}
.grid_card, .grid_card_2, .grid_card_3 {
display: flex;
/* max-height: 75vh; */
}
.grid_card_2 {
flex-direction: row-reverse;
}
.card_information, .card_image {
flex: 1;
}
.card_information {
display: flex;
justify-content: center;
align-items: center;
}
div[class$="information_container"] {
display: flex;
flex-direction: column;
justify-content: center;
max-width: 22rem;
text-align: start;
}
div[class$="information_container"] > h2 {
font-family: "Fraunces";
font-weight: 900;
font-size: 2.5rem;
color: var(--Very-dark-desaturated-blue);
}
div[class$="information_container"] > p {
line-height: 1.75em;
font-size: 1.1em;
color: var(--Dark-grayish-blue);
font-family: "Barlow";
margin: 2rem 0 2rem 0;
}
div[class$="information_container"] > a {
font-family: "Fraunces";
font-size: 1em;
font-weight: 900;
text-transform: uppercase;
color: var(--Very-dark-desaturated-blue);
position: relative;
align-self: flex-start;
padding: 0 .5em;
cursor: pointer;
}
div[class$="information_container"] > a::after {
content: '';
z-index: -1;
width: 100%;
height: 0.5rem;
position: absolute;
left: 0;
top: 70%;
border-radius: 1rem;
/* background-color: hsl(51, 95%, 83%); */
}
div[class^="transform"] > a::after {
background-color: hsl(51, 95%, 83%);
}
div[class^="transform"] > a:hover::after {
background-color: var(--Yellow);
transition: .15s;
}
div[class^="stand_out"] > a::after {
background-color: hsl(7, 91%, 91%);
}
div[class^="stand_out"] > a:hover::after {
background-color: var(--Soft-red);
transition: .15s;
}
.card_image > img {
width: 100%;
height: 100%;
}
.card_image {
position: relative;
display: flex;
justify-content: center;
}
.graphic_design_text, .photography_text {
position: absolute;
z-index: 1;
text-align: center;
bottom: 0;
margin-bottom: 5em;
width: 22em;
}
div[class$="_text"] > h2 {
margin-bottom: .8em;
font-size: 1.75em;
font-weight: 900;
font-family: "Fraunces";
}
div[class$="_text"] > p {
font-family: "Barlow";
font-size: 1em;
line-height: 1.65em;
}
.graphic_design_text > * {
color: var(--Dark-desaturated-cyan);
}
.photography_text > * {
color: var(--Dark-blue);
}
.testimonials {
/* height: 97vh; */
margin: 10em 0 10em 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.testimonials > h2 {
margin-bottom: 5em;
text-transform: uppercase;
letter-spacing: .4em;
font-size: 1.1em;
color: var(--Dark-grayish-blue);
font-family: "Fraunces";
}
.testimonial_group {
display: flex;
width: 70vw;
}
.single_testimonial {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 0 .75em 0 .75em;
}
.single_testimonial > img {
border-radius: 50%;
width: 3.5em;
}
.single_testimonial > p {
font-family: "Barlow";
color: var(--Very-dark-grayish-blue);
margin: 3em 0 4em 0;
line-height: 1.5em;
text-align: center;
font-size: 1em;
}
.single_testimonial > .testimonial_name {
font-family: "Fraunces";
}
.single_testimonial > small {
font-family: "Barlow";
color: var(--Grayish-blue);
margin-top: 1em;
}
.footer {
/* max-height: 100vh; */
background-color: hsl(168, 57%, 72%);
display: flex;
flex-direction: column;
}
.footer > .image_banner {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: 1fr;
width: 100%;
/* margin: 1em 0 1em 0; */
/* height: 60vh; */
}
.footer > .image_banner > img {
width: 100%;
}
.banner_information {
width: 100%;
/* height: 40vh; */
display: flex;
flex-direction: column;
justify-content: center;
margin: 5em 0 5em 0;
}
.logo_footer {
align-self: center;
width: 9em;
margin-bottom: 2.5em;
}
.footer_nav {
width: 20em;
display: flex;
justify-content: space-between;
font-family: "Barlow";
color: var(--Dark-moderate-cyan);
}
.banner_information > .footer_nav {
align-self: center;
display: flex;
margin-bottom: 5em;
}
.banner_information > .footer_nav > *:hover {
color: white;
cursor: pointer;
transition: .15s;
}
.banner_information > .footer_links {
align-self: center;
display: flex;
justify-content: space-between;
width: 9em;
cursor: pointer;
}
.banner_information > .footer_links > svg:hover > path {
fill: white;
transition: .15s;
}
#media (max-width: 1440px) {
.intro_screen > h2 {
font-size: 3em;
margin: 2.5em 0 2em 0;
}
.graphic_design_text, .photography_text {
margin-bottom: 3em;
}
div[class$="_text"] > h2 {
font-size: 1.5em;
}
div[class$="_text"] > p {
font-size: 1em;
}
div[class$="information_container"] {
max-width: 23em;
}
div[class$="information_container"] > h2 {
font-size: 2em;
}
div[class$="information_container"] > p {
font-size: .9em;
line-height: 1.5em;
}
div[class$="information_container"] > a {
font-size: .9em;
}
.testimonial_group {
width: 85vw;
}
}
#media (max-width: 1200px) {
.navbar > .nav_links {
width: 55%;
}
.graphic_design_text, .photography_text {
margin-bottom: 1.5em;
width: 20em;
}
div[class$="_text"] > h2 {
font-size: 1.5em;
}
div[class$="_text"] > p {
font-size: .9em;
}
.testimonials {
margin: 7em 0 7em 0;
}
.testimonials > h2 {
font-size: 1em;
}
.single_testimonial > p {
font-size: .9em;
margin: 2em 0 3em 0;
}
};
#media (max-width: 992px) {
.intro_screen > h2 {
color: red;
}
};
#media (max-width: 600px) {
.grid_card, .grid_card_2, .grid_card_3 {
flex-direction: column-reverse;
}
.navbar > .nav_links {
display: none;
}
.intro_screen > h2 {
font-size: 1em;
}
.testimonial_group {
flex-direction: column;
}
};
My problem lies at the end of the CSS code:
#media (max-width: 1440px) {
.intro_screen > h2 {
font-size: 3em;
margin: 2.5em 0 2em 0;
}
.graphic_design_text, .photography_text {
margin-bottom: 3em;
}
div[class$="_text"] > h2 {
font-size: 1.5em;
}
div[class$="_text"] > p {
font-size: 1em;
}
div[class$="information_container"] {
max-width: 23em;
}
div[class$="information_container"] > h2 {
font-size: 2em;
}
div[class$="information_container"] > p {
font-size: .9em;
line-height: 1.5em;
}
div[class$="information_container"] > a {
font-size: .9em;
}
.testimonial_group {
width: 85vw;
}
}
#media (max-width: 1200px) {
.navbar > .nav_links {
width: 55%;
}
.graphic_design_text, .photography_text {
margin-bottom: 1.5em;
width: 20em;
}
div[class$="_text"] > h2 {
font-size: 1.5em;
}
div[class$="_text"] > p {
font-size: .9em;
}
.testimonials {
margin: 7em 0 7em 0;
}
.testimonials > h2 {
font-size: 1em;
}
.single_testimonial > p {
font-size: .9em;
margin: 2em 0 3em 0;
}
};
#media (max-width: 992px) {
.intro_screen > h2 {
color: red;
}
};
#media (max-width: 600px) {
.grid_card, .grid_card_2, .grid_card_3 {
flex-direction: column-reverse;
}
.navbar > .nav_links {
display: none;
}
.intro_screen > h2 {
font-size: 1em;
}
.testimonial_group {
flex-direction: column;
}
};
The first two media queries, max-width: 1440px and max-width: 1200px, function perfectly.
The next two, max-width: 992px and max-width: 600px, do not function at all. The red color for the 992 entry is for testing purposes.
If I comment the first two entries out—the larger queries that work—the next one will actually function. I've also tried repositioning the media queries, but the same general problem occurs: the top queries will function, while the bottom ones will not.
I think the issue may stem from either my lack of min-height parameters, although I've tried adding those to the existing code and it breaks or tweaks their current function, or my query positioning. All help is much appreciated!

Header Responsiveness issue

I am trying to make the header for a site but i have a issue when it comes to responsiveness on height.
And something i am not sure that it can be resolved with media queries breakpoints as you can see from the photo below.
and here is how it looks on full window
Html
<body>
<header class="header">
<div class="logo-box"></div>
<img src="/img/logo-white.png" class="logo">
<div class="text-box">
<h1 class="heading-primary">
<span class="heading-primary-main">City</span>
<span class="heading-primary-sub">is where life happens</span>
</h1>
Discover our City
Discover our Tours
</div>
</header>
</body>
CSS
*{
margin:0;
padding:0;
box-sizing: border-box;
}
body{
font-family: "Lato", sans-serif;
font-weight: 400;
font-size: 16px;
line-height: 1.7;
color: #777;
}
.header{
height:65vh;
background-image: linear-gradient(to right bottom, rgba(132,248,198 , 0.8), rgba(26,187,137,0.8)),url(../img/ch4.jpg);
background-size: cover;
background-position: top;
background-color:#4FD1A9;
}
.logo-box{
position: absolute;
top:40px;
left:40px;
}
.logo{
height:35px;
}
.heading-primary {
color:#fff;
text-transform: uppercase;
}
.heading-primary-main{
display: block;
font-size: 60px;
font-weight: 400;
letter-spacing: 35px;
}
.heading-primary-sub {
display: block;
font-size: 20px;
font-weight: 700;
letter-spacing: 15px;
margin-bottom: 60px;
}
.text-box {
display: inline-block;
position: absolute;
top:30%;
left:50%;
transform: translate(-50% ,-50%);
text-align: center;
}
.btn:link,
.btn:visited {
text-transform: uppercase;
text-decoration: none;
padding:15px 40px;
display: inline-block;
border-radius: 100px;
transition: all .2s;
margin: 5px;
}
.btn:hover {
transform: translateY(-3px);
box-shadow: 0 5px 10px rgb(0,0,0,.2);
}
.btn:active {
transform: translateY(-1px) ;
}
.btn-white {
background-color: #fff;
color:#777;
}
Should i make the entire header with CSS grid Layout breaking it its own parts?
My solution is somewhat opinionated, but I think that's unavoidable for this kind of question as there's so many different ways that it could be done.
I take the view that the height of elements should be determined only by their contents. If it was the case that users were comfortable scrolling horizontally as well as vertically through a website, then responsive design would be a complete non-issue. Responsive Design only becomes necessary because we prevent horizontal scrolling. We should not therefore concern ourselves with the height of content, only with the width.
Accordingly, I've removed the fixed height from the header as well as the absolute positioning from some of the elements and allowed the content to be laid out according to the natural flow. For desktop, I think this works fine.
A slightly different approach is required for narrower screens since on these you do begin to have issues with the width of the content. My solution here is to introduce a break-point at around the point when the content starts to get too wide for the viewport. Then I set all dimensions - font-sizes, margins, padding etc - to be a proportion of the current viewport width. A little math is required here to calculate the correct values, and I've also used CSS Custom Properties to make things a bit DRYer. In fact, there's only one declaration within the media query, and that's to set the base-unit from which all other values are calculated.
I've made notes in the CSS giving the reasoning for some of the changes I've made.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Lato", sans-serif;
font-weight: 400;
font-size: 16px;
line-height: 1.7;
color: #777;
}
.header {
--unit: 1px;
/* removing this since the height of an element should be determined by content */
/* height:65vh;*/
background-image: linear-gradient(to right bottom, rgba(132, 248, 198, 0.8), rgba(26, 187, 137, 0.8)), url(https://s.abcnews.com/images/Business/gty_detroit_mi_130718_4x3_992.jpg);
background-size: cover;
background-position: center;
background-color: #4FD1A9;
/*
* flexbox is the best way to layout content along a single axis
* for various practical and performance reasons
*/
display: flex;
}
.text-box {
--padding-v: calc(var(--unit) * 50);
--padding-h: calc(var(--unit) * 10);
display: inline-block;
padding: var(--padding-v) var(--padding-h);
/* This content should just be in the normal flow of the page */
/*
position: absolute
top:30%;
left:50%;
transform: translate(-50% ,-50%);
*/
text-align: center;
/* Because we're using flexbox, we can center the content both horizontally and vertically
* using this declaration
*/
margin: auto;
}
.heading-primary {
color: #fff;
text-transform: uppercase;
}
.heading-primary-main {
--font-size: calc(var(--unit) * 60);
--letter-spacing: calc(var(--unit) * 35);
display: block;
font-size: var(--font-size);
font-weight: 400;
letter-spacing: var(--letter-spacing);
}
.heading-primary-sub {
--font-size: calc(var(--unit) * 20);
--letter-spacing: calc(var(--unit) * 15);
--margin-bottom: calc(var(--unit) * 60);
display: block;
font-size: var(--font-size);
font-weight: 700;
letter-spacing: var(--letter-spacing);
margin-bottom: var(--margin-bottom);
}
.btn {
--padding-v: calc(var(--unit) * 15);
--padding-h: calc(var(--unit) * 40);
--border-radius: calc(var(--unit) * 100);
--margin: calc(var(--unit) * 5);
--font-size: calc(var(--unit) * 16);
font-size: var(--font-size);
text-transform: uppercase;
text-decoration: none;
padding: var(--padding-v) var(--padding-h);
display: inline-block;
border-radius: var(--border-radius);
transition: all .2s;
margin: var(--margin);
background-color: #fff;
color: #777;
}
.btn:hover {
transform: translateY(-3px);
box-shadow: 0 5px 10px rgb(0, 0, 0, .2);
}
.btn:active {
transform: translateY(-1px);
}
/*
* This is around the point at which the text starts to wrap
*
* We take a fundamentally different approach to layout here. Now we want dimensions to
* scale with the width of the viewport so that it will look good at all sizes
*/
#media only screen and (max-width: 550px) {
.header {
--unit: calc(100vw / 550);
}
}
<html>
<head>
<link href="./header.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<header class="header">
<div class="text-box">
<h1 class="heading-primary">
<span class="heading-primary-main">City</span>
<span class="heading-primary-sub">is where life happens</span>
</h1>
Discover our City
Discover our Tours
</div>
</header>
</body>
</html>
Use media-quires to adjust your layout.
Problem occurs due to position:absolute
Reference
*{
margin:0;
padding:0;
box-sizing: border-box;
}
body{
font-family: "Lato", sans-serif;
font-weight: 400;
font-size: 16px;
line-height: 1.7;
color: #777;
}
.header{
height:65vh;
background-image: linear-gradient(to right bottom, rgba(132,248,198 , 0.8), rgba(26,187,137,0.8)),url(../img/ch4.jpg);
background-size: cover;
background-position: top;
background-color:#4FD1A9;
}
.logo-box{
position: absolute;
top:40px;
left:40px;
}
.logo{
height:35px;
}
.heading-primary {
color:#fff;
text-transform: uppercase;
}
.heading-primary-main{
display: block;
font-size: 60px;
font-weight: 400;
letter-spacing: 35px;
}
.heading-primary-sub {
display: block;
font-size: 20px;
font-weight: 700;
letter-spacing: 15px;
margin-bottom: 60px;
}
.text-box {
display: inline-block;
position: absolute;
top:30%;
left:50%;
transform: translate(-50% ,-50%);
text-align: center;
}
.btn:link,
.btn:visited {
text-transform: uppercase;
text-decoration: none;
padding:15px 40px;
display: inline-block;
border-radius: 100px;
transition: all .2s;
margin: 5px;
}
.btn:hover {
transform: translateY(-3px);
box-shadow: 0 5px 10px rgb(0,0,0,.2);
}
.btn:active {
transform: translateY(-1px) ;
}
.btn-white {
background-color: #fff;
color:#777;
}
#media only screen and (max-width: 767px) {
.header {
height: 100vh;//adjust as per your req
}
.text-box {
display: block;
position: relative;
top: 0;
left: 0;
transform: none;
text-align: center;
height: 100%;
}
}
<body>
<header class="header">
<div class="logo-box"></div>
<img src="/img/logo-white.png" class="logo">
<div class="text-box">
<h1 class="heading-primary">
<span class="heading-primary-main">City</span>
<span class="heading-primary-sub">is where life happens</span>
</h1>
Discover our City
Discover our Tours
</div>
</header>
</body>

Fix CSS width issue on mobile

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
#import "variables";
#import "utilities";
body {
color: $neutral;
font-family: "Open Sans", sans-serif;
background-color: $main-bg;
}
a {
color: $cyan;
text-decoration: none;
}
ul {
list-style: none;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "Raleway", sans-serif;
}
p {
font-family: "Raleway", sans-serif;
}
#header {
grid-area: heading;
height: 100vh;
background-color: $intro-email;
position: relative;
background-image: $bg-image;
background-size: contain;
background-repeat: no-repeat;
background-position: left bottom;
// &::before {
// content: "";
// background-image: $bg-image;
// position: absolute;
// width: 100%;
// background-size: contain;
// background-repeat: no-repeat;
// background-position: left bottom;
// }
.navbar {
grid-area: heading;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 6rem;
.nav-list {
display: flex;
li {
padding: 1rem 1.2rem;
text-transform: uppercase;
a {
text-decoration: none;
color: #fff;
text-transform: uppercase;
border-bottom: 3px transparent solid;
padding-bottom: 0.5rem;
transition: border-color 0.5s;
font-size: 0.8rem;
font-weight: 400;
font-family: "Raleway", sans-serif;
&:hover {
border-color: #fff;
}
&.current {
border-color: #fff;
}
}
}
}
}
.header-content {
max-width: 100%;
margin: 20px auto;
text-align: center;
width: 600px;
img {
max-width: 90%;
margin-top: -50px;
}
}
}
Variabes for CSS $intro-email: hsl(217, 28%, 15%);
$main-bg: hsl(218, 28%, 13%);
$footer-bg: hsl(216, 53%, 9%);
$testimonial-bg: hsl(219, 30%, 18%);
$neutral: hsl(0, 0%, 100%);
$cyan: hsl(176, 68%, 64%);
$blue: hsl(198, 60%, 50%);
$website-width: 1440px;
$bg-image: url("../img/bg-curvy-desktop.svg");
Container .container {
width: $website-width;
max-width: 100%;
padding: 2rem;
margin: 0 auto;
overflow: hidden;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.13.1/umd/react.production.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" />
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght#400;700&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght#400;700&display=swap" rel="stylesheet" />
<header id="header">
<div class="container">
<div class="wrapper">
<nav class="navbar">
<img src="../dist/img/logo.svg" alt="" />
<ul class="nav-list">
<li>Features</li>
<li>Team</li>
<li>SignIn</li>
</ul>
</nav>
<div class="header-content">
<img src="../dist/img/illustration-intro.png" alt="" />
<h1 class="title">
All your files in one secue location, accessible anywhere
</h1>
<p class="text">
Flyo stores all your most important files in one secure location. Access them whenever you need, share and collaborate with friends, family and co-workers
</p>
<button class="btn-main">Get Started</button>
</div>
</div>
</div>[Image showing what is happening in my code][1]
</header>
Website width is set to 1440px but anytime i move to the mobile version on my screen, width of the website is never the same and some elements of the website begin to fall out of place of the website, is there a way to fix this or should i remove the container that i am nesting the elements in because that is the website width the design was made for
For your container, consider using a responsive width like width: 100vw (i.e. 100% of viewport/window width). Or, if you really want to stick with 1440px, you can use media queries.
Media queries help applying different CSS rules to different device screen sizes, as a dummy example:
#media(max-width: 599px) {
.container {
/* Your styling for mobile phones */
}
}
#media(min-width: 600px) {
/* Your styling for desktops */
}

Getting these responsive square divs to sit next to each other

I'm working on a site that is going to look like this:
However, I am having some trouble getting the divs on the third row not to move when I resize the window. To give you an idea of what i'm talking about, here are pictures...
At normal window size:
When I make the window smaller:
How can I make it so that the two divs stay the same as they are in the first picture and don't change position when i adjust the window size. Also, is there any way I can make the text resize along with the div?
Here is my code so far:
#font-face {
font-family: 'Trend Sans 004'; /*a name to be used later*/
src: url('fonts/Trend Sans W00 Four.ttf'); /*URL to font*/
}
#font-face {
font-family: 'Utopia Regular'; /*a name to be used later*/
src: url('fonts/utopia-regular.ttf'); /*URL to font*/
}
#font-face {
font-family: 'Trend Sans 001'; /*a name to be used later*/
src: url('fonts/Trend Sans W00 One.ttf'); /*URL to font*/
}
/*
* Skeleton V2.0.4
* Copyright 2014, Dave Gamache
* www.getskeleton.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 12/29/2014
*/
/* Table of contents
––––––––––––––––––––––––––––––––––––––––––––––––––
- Grid
- Base Styles
- Typography
- Links
- Buttons
- Forms
- Lists
- Code
- Tables
- Spacing
- Utilities
- Clearing
- Media Queries
*/
/* Grid
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.container {
position: relative;
width: 100%;
max-width: 100%;
margin: 0 auto;
padding: 0 20px;
box-sizing: border-box; }
.column,
.columns {
width: 100%;
float: left;
box-sizing: border-box; }
/* For devices larger than 400px */
#media (min-width: 400px) {
.container {
width: 85%;
padding: 0; }
}
/* For devices larger than 550px */
#media (min-width: 550px) {
.container {
width: 80%; }
.column,
.columns {
margin-left: 4%; }
.column:first-child,
.columns:first-child {
margin-left: 0;
}
.one.column,
.one.columns { width: 4.66666666667%; }
.two.columns { width: 13.3333333333%; }
.three.columns { width: 22%; }
.four.columns { width: 30.6666666667%; }
.five.columns { width: 39.3333333333%; }
.six.columns { width: 48%; }
.seven.columns { width: 56.6666666667%; }
.eight.columns { width: 65.3333333333%; }
.nine.columns { width: 74.0%; }
.ten.columns { width: 82.6666666667%; }
.eleven.columns { width: 91.3333333333%; }
.twelve.columns { width: 100%; margin-left: 0; }
.one-third.column { width: 30.6666666667%; }
.two-thirds.column { width: 65.3333333333%; }
.one-half.column { width: 48%; }
/* Offsets */
.offset-by-one.column,
.offset-by-one.columns { margin-left: 8.66666666667%; }
.offset-by-two.column,
.offset-by-two.columns { margin-left: 17.3333333333%; }
.offset-by-three.column,
.offset-by-three.columns { margin-left: 26%; }
.offset-by-four.column,
.offset-by-four.columns { margin-left: 34.6666666667%; }
.offset-by-five.column,
.offset-by-five.columns { margin-left: 43.3333333333%; }
.offset-by-six.column,
.offset-by-six.columns { margin-left: 52%; }
.offset-by-seven.column,
.offset-by-seven.columns { margin-left: 60.6666666667%; }
.offset-by-eight.column,
.offset-by-eight.columns { margin-left: 69.3333333333%; }
.offset-by-nine.column,
.offset-by-nine.columns { margin-left: 78.0%; }
.offset-by-ten.column,
.offset-by-ten.columns { margin-left: 86.6666666667%; }
.offset-by-eleven.column,
.offset-by-eleven.columns { margin-left: 95.3333333333%; }
.offset-by-one-third.column,
.offset-by-one-third.columns { margin-left: 34.6666666667%; }
.offset-by-two-thirds.column,
.offset-by-two-thirds.columns { margin-left: 69.3333333333%; }
.offset-by-one-half.column,
.offset-by-one-half.columns { margin-left: 52%; }
}
/* Base Styles
–––––––––––––––––––––––––––––––––––––––––––––––––– */
/* NOTE
html is set to 62.5% so that all the REM measurements throughout Skeleton
are based on 10px sizing. So basically 1.5rem = 15px :) */
html {
font-size: 62.5%; }
body {
background-color:#C8D7DC;
}
/* Typography
–––––––––––––––––––––––––––––––––––––––––––––––––– */
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 2rem;
font-weight: 300; }
h1 { font-size: 4.0rem; line-height: 1.2; letter-spacing: -.1rem;}
h2 { font-size: 3.6rem; line-height: 1.25; letter-spacing: -.1rem; }
h3 { font-size: 3.0rem; line-height: 1.3; letter-spacing: -.1rem; }
h4 { font-size: 2.4rem; line-height: 1.35; letter-spacing: -.08rem; }
h5 { font-size: 1.8rem; line-height: 1.5; letter-spacing: -.05rem; }
h6 { font-size: 1.5rem; line-height: 1.6; letter-spacing: 0; }
/* Larger than phablet */
#media (min-width: 550px) {
h1 { font-size: 5.0rem; }
h2 { font-size: 4.2rem; }
h3 { font-size: 3.6rem; }
h4 { font-size: 3.0rem; }
h5 { font-size: 2.4rem; }
h6 { font-size: 1.5rem; }
}
p {
margin-top: 0; }
/* Buttons
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.button,
button,
input[type="submit"],
input[type="reset"],
input[type="button"] {
display: inline-block;
height: 38px;
padding: 0 30px;
color: #555;
text-align: center;
font-size: 11px;
font-weight: 600;
line-height: 38px;
letter-spacing: .1rem;
text-transform: uppercase;
text-decoration: none;
white-space: nowrap;
background-color: transparent;
border-radius: 4px;
border: 1px solid #bbb;
cursor: pointer;
box-sizing: border-box; }
.button:hover,
button:hover,
input[type="submit"]:hover,
input[type="reset"]:hover,
input[type="button"]:hover,
.button:focus,
button:focus,
input[type="submit"]:focus,
input[type="reset"]:focus,
input[type="button"]:focus {
color: #333;
border-color: #888;
outline: 0; }
.button.button-primary,
button.button-primary,
input[type="submit"].button-primary,
input[type="reset"].button-primary,
input[type="button"].button-primary {
color: #FFF;
background-color: #33C3F0;
border-color: #33C3F0; }
.button.button-primary:hover,
button.button-primary:hover,
input[type="submit"].button-primary:hover,
input[type="reset"].button-primary:hover,
input[type="button"].button-primary:hover,
.button.button-primary:focus,
button.button-primary:focus,
input[type="submit"].button-primary:focus,
input[type="reset"].button-primary:focus,
input[type="button"].button-primary:focus {
color: #FFF;
background-color: #1EAEDB;
border-color: #1EAEDB; }
/* Forms
–––––––––––––––––––––––––––––––––––––––––––––––––– */
input[type="email"],
input[type="number"],
input[type="search"],
input[type="text"],
input[type="tel"],
input[type="url"],
input[type="password"],
textarea,
select {
height: 38px;
padding: 6px 10px; /* The 6px vertically centers text on FF, ignored by Webkit */
background-color: #fff;
border: 1px solid #D1D1D1;
border-radius: 4px;
box-shadow: none;
box-sizing: border-box; }
/* Removes awkward default styles on some inputs for iOS */
input[type="email"],
input[type="number"],
input[type="search"],
input[type="text"],
input[type="tel"],
input[type="url"],
input[type="password"],
textarea {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none; }
textarea {
min-height: 65px;
padding-top: 6px;
padding-bottom: 6px; }
input[type="email"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="text"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
border: 1px solid #33C3F0;
outline: 0; }
label,
legend {
display: block;
margin-bottom: .5rem;
font-weight: 600; }
fieldset {
padding: 0;
border-width: 0; }
input[type="checkbox"],
input[type="radio"] {
display: inline; }
label > .label-body {
display: inline-block;
margin-left: .5rem;
font-weight: normal; }
/* Lists
–––––––––––––––––––––––––––––––––––––––––––––––––– */
ul {
list-style: circle inside; }
ol {
list-style: decimal inside; }
ol, ul {
padding-left: 0;
margin-top: 0; }
ul ul,
ul ol,
ol ol,
ol ul {
margin: 1.5rem 0 1.5rem 3rem;
font-size: 90%; }
li {
margin-bottom: 1rem; }
/* Code
–––––––––––––––––––––––––––––––––––––––––––––––––– */
code {
padding: .2rem .5rem;
margin: 0 .2rem;
font-size: 90%;
white-space: nowrap;
background: #F1F1F1;
border: 1px solid #E1E1E1;
border-radius: 4px; }
pre > code {
display: block;
padding: 1rem 1.5rem;
white-space: pre; }
/* Tables
–––––––––––––––––––––––––––––––––––––––––––––––––– */
th,
td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #E1E1E1; }
th:first-child,
td:first-child {
padding-left: 0; }
th:last-child,
td:last-child {
padding-right: 0; }
/* Spacing
–––––––––––––––––––––––––––––––––––––––––––––––––– */
button,
.button {
margin-bottom: 1rem; }
input,
textarea,
select,
fieldset {
margin-bottom: 1.5rem; }
pre,
blockquote,
dl,
figure,
table,
p,
ul,
ol,
form {
margin-bottom: 2.5rem; }
/* Utilities
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.u-full-width {
width: 100%;
box-sizing: border-box; }
.u-max-full-width {
max-width: 100%;
box-sizing: border-box; }
.u-pull-right {
float: right; }
.u-pull-left {
float: left; }
/* Misc
–––––––––––––––––––––––––––––––––––––––––––––––––– */
/* Clearing
–––––––––––––––––––––––––––––––––––––––––––––––––– */
/* Self Clearing Goodness */
.container:after,
.row:after,
.u-cf {
content: "";
display: table;
clear: both; }
/* Media Queries
–––––––––––––––––––––––––––––––––––––––––––––––––– */
/*
Note: The best way to structure the use of media queries is to create the queries
near the relevant code. For example, if you wanted to change the styles for buttons
on small devices, paste the mobile query code up in the buttons section and style it
there.
*/
/* Larger than mobile */
#media (min-width: 400px) {}
/* Larger than phablet (also point when grid becomes active) */
#media (min-width: 550px) {}
/* Larger than tablet */
#media (min-width: 750px) {}
/* Larger than desktop */
#media (min-width: 1000px) {}
/* Larger than Desktop HD */
#media (min-width: 1200px) {}
/* Header
–––––––––––––––––––––––––––––––––––––––––––––––––– */
#header {
font-size:10vw;
margin-top:5%;
text-align: center;
font-family:'Trend Sans 004';
color: #806239;
}
/* Row 1
–––––––––––––––––––––––––––––––––––––––––––––––––– */
#row1 {
font-family:'Trend Sans 001';
color:#806239;
border: 2px #806239 solid;
margin-top:2%;
padding:1%;
font-size:2vw;
white-space: nowrap;
}
#row1 a:link {
text-decoration: none;
color:#806239;
}
#row1 a:visited {
text-decoration: none;
color:#806239;
}
#row1 a:hover {
text-decoration: none;
color:#806239;
}
#row1 a:active {
text-decoration: none;
color:#806239;
}
#row1 ul {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
}
#row1 li {
display: inline;
}
#row1 li {
display: inline;
}
#kjn {
padding-right:25%;
padding-left:25%;
}
/* Row 3
–––––––––––––––––––––––––––––––––––––––––––––––––– */
#row3 {
background-color:#806239;
font-family:'Utopia Regular';
margin-top:2%;
text-align:center;
color: white;
padding:5%;
}
#mail {
font-family:'Trend Sans 001';
letter-spacing:2px;
font-size:1.8vw;
}
#first {
margin-top:-5%;
font-size:1.5vw;
letter-spacing:.4px;
}
/* Box Row
–––––––––––––––––––––––––––––––––––––––––––––––––– */
#boxRow {
font-family:'Utopia Regular';
margin-top:2%;
}
#boxRowImg1 {
background-image: url("images/interior.png");
background-color:grey;
background-repeat: no-repeat;
background-size: cover;
font-family:'Utopia Regular';
width: 48%;
height: 0;
padding-bottom: 48%;
}
#boxRowTxt {
font-family:'Utopia Regular';
box-shadow:0px 0px 0px 3px #806239 inset;
width: 48%;
color:#806239;
position:relative;
height: 0;
padding-bottom: 48%;
}
#boxRowTxt h5 {
font-family:'Trend Sans 001';
font-size:3vw;
}
#boxRowTxt p {
margin-top:-20px;
color:#806239;
font-size:10px;
}
#boxRowTxt hr {
height:1px;
width:40%;
background-color:#806239;
border-width:0px;
}
#aa {
padding-top:20px;
padding-bottom:20px;
padding-left:10%;
padding-right:10%;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
/* hr
–––––––––––––––––––––––––––––––––––––––––––––––––– */
#row5 hr {
height:2px;
width:100%;
background-color:#806239;
border-width:0px;
margin-top:3%;
}
/* Row 6
–––––––––––––––––––––––––––––––––––––––––––––––––– */
#row6 {
font-family:'Trend Sans 001';
margin-top:.5%;
margin-bottom:1.5%;
font-size:1.3vw;
color:#806239;
}
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Basic Page Needs
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta charset="utf-8">
<title>Cupid's Cafe & Bakery</title>
<meta name="description" content="Cupid's Cafe & Bakery">
<meta name="author" content="">
<!-- Mobile Specific Metas
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- FONT
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<!-- CSS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="stylesheet" href="normalize.css">
<link rel="stylesheet" href="Cupids.css">
<!-- Favicon
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="icon" type="image/png" href="images/favicon.png">
</head>
<body>
<!-- Primary Page Layout
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<div class="container">
<div class="row">
<div class="twelve columns" id="header">
Cupid's
</div>
</div>
<div class="row">
<div class="twelve columns" id="row1">
<ul>
<li>Menu</li>
<li><a id="kjn" href="#about">About</a></li>
<li>Gallery</li>
</ul>
</div>
</div>
<div class="row" id="boxRow">
<div class="six columns" id="boxRowImg1" >
</div>
<div class="six columns" id="boxRowTxt" >
<div id="aa">
<h5>The Cafe</h5></br>
<p>Like a home away from home, our secluded cafe is the perfect place to relax, work, or settle in with a good book. Make sure to try one of our delicious lunch options or expertly brewed hot drinks. </p>
<hr align="left" >
</div>
</div>
</div>
<div class="row">
<div class="twelve columns" id="row5">
<hr width="100%">
</div>
</div>
<div class="row">
<div class="twelve columns" id="row6">
copyright 2016, emily baker
</div>
</div>
</div>
<!-- End Document
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
</body>
</html>
Be careful about this media query :
#media (min-width: 550px)
.column, .columns {
margin-left: 4%;
}
This query add a margin-left when the size of the window is larger than 550px. You have to adapt it to fix your issue ;)
Another solution could be to change the layout when you're with a very small width. For example, putting the two div in a 100% width one above the other.
You can do that with a media query.
For your first question, it seems like the divs snap together when the window hits ~550px wide. More likely than not, its skeleton doing that for you, so I'd look for a media query which changes padding or margin.
As for your second question, yes, you can change the size of the text as the window changes sizes, but whether or not that is something you want for your users is another question. You can look into using rem or percentages for the font-size property of that element.