Why my content won't clear this flex element? - html

In the snippet below, I have a slider, which works great. There's an h2 that is placed after the primary-content class. The content outside of the `.primary-content' class won't clear the container. I don't understand why.
(function () {
"use strict";
let slides = document.querySelectorAll(".testimonial__item"),
button = document.getElementById("button"),
arrows = document.querySelectorAll(".icon"),
carouselCount = 0,
scrollInterval,
interval = 5000;
arrows[0].addEventListener("click", function (e) {
e = e || window.event;
e.preventDefault();
carouselCount -= 100;
slider();
if (e.type !== "autoClick") {
clearInterval(scrollInterval);
scrollInterval = setInterval(interval);
}
});
arrows[1].addEventListener("click", sliderEvent);
function sliderEvent(e) {
e = e || window.event;
e.preventDefault();
carouselCount += 100;
slider();
}
function slider() {
switch (carouselCount) {
case -100:
carouselCount = 0;
break;
case 300:
carouselCount = 0;
break;
default:
break;
}
console.log(carouselCount);
for (var i = 0; i < slides.length; i += 1) {
slides[i].setAttribute(
"style",
"transform:translateX(-" + carouselCount + "%)"
);
}
}
// set timing of dispatch click events
scrollInterval = setInterval(interval);
})();
/* Duru Sans */
#import url("https://fonts.googleapis.com/css2?family=Duru+Sans&display=swap");
body {
box-sizing: border-box;
margin: 0;
padding: 0;
font-size: 16px;
font-family: "Duru Sans", sans-serif;
}
h2 {
padding: 5px;
background: fuchsia;
width: fit-content;
}
h4 {
font-family: "Lato", sans-serif;
font-size: 2em;
}
.img-fluid {
width: 100%;
height: auto;
}
.primary-content {
padding: 2em;
}
.testimonial__carousel {
width: 100%;
position: relative;
display: block;
flex-direction: column;
overflow-x: clip;
}
.testimonial__carousel--top {
display: flex;
flex-direction: column;
}
#media screen and (min-width: 576px) {
.testimonial__carousel--top {
flex-direction: row;
align-items: center;
justify-content: space-between;
}
}
#media screen and (min-width: 768px) {
.testimonial__carousel {
max-height: 320px;
}
}
.testimonial__icons {
display: flex;
justify-content: flex-start;
margin-top: 2rem;
margin-bottom: 2rem;
}
.testimonial__icons button.icon {
background: transparent;
border: 0;
display: flex;
align-items: center;
cursor: pointer;
padding: 0;
}
.testimonial__icons button.icon-left {
margin-right: 1.25rem;
}
.testimonial__icons button.icon img {
height: 25px;
width: 25px;
}
.testimonial__items {
flex: 1;
color: #000;
}
.testimonial__item {
width: 100%;
transition: transform 1s;
background: #f2f5f9;
display: flex;
flex-direction: column;
justify-content: center;
}
#media screen and (min-width: 576px) {
.testimonial__item {
flex-direction: row;
}
}
.testimonial__item.first {
left: 0;
position: absolute;
}
.testimonial__item.second {
left: 100%;
position: absolute;
}
.testimonial__item.third {
left: 200%;
position: absolute;
}
.testimonial__img {
min-width: 40%;
}
.testimonial__content {
background: #f2f5f9;
padding: 2.75rem 2.5rem 2.5rem;
display: flex;
flex-direction: column;
justify-content: space-between;
}
#media screen and (min-width: 768px) {
.testimonial__content {
padding: 3.5rem;
}
}
.testimonial__credits {
display: flex;
flex-direction: column;
margin-top: 2rem;
border-left: 4px solid #005fec;
padding-left: 0.75rem;
}
.testimonial__name {
margin-bottom: 0.5rem;
}
<div class="primary-content">
<h4>Testimonials</h4>
<div class="testimonial__carousel">
<div class="testimonial__carousel--top">
<h3>People love it here. See why</h3>
<div class="testimonial__icons">
<button class="icon icon-left">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Feather-arrows-arrow-left.svg/768px-Feather-arrows-arrow-left.svg.png" alt="">
</button>
<button class="icon icon-right">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/Feather-arrows-arrow-right.svg/1200px-Feather-arrows-arrow-right.svg.png" alt="">
</button>
</div>
</div>
<div class="testimonial__items">
<div class="testimonial__item first">
<div class="testimonial__img">
<img class="img-fluid" src="https://nextivaweb.imgix.net/heroes/case-study/Case-Study-Conan-hero.jpg?w=336&h=412&auto=format&crop=focalpoint&fit=crop&fp-x=.75&fp-z=1.3&fp-y=.39" alt="">
</div>
<div class="testimonial__content">
<div class="testimonial__text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Deleniti laboriosam fugiat perferendis blanditiis, dignissimos temporibus sunt aliquam sequi quia! Deleniti earum quibusdam dolorem accusantium ipsum?</div>
<div class="testimonial__credits">
<span class="testimonial__name kicker kicker--bold">Lorem, ipsum.</span>
<span class="testimonial__position kicker kicker--light">Lorem ipsum dolor sit amet,
Burbank,
CA</span>
</div>
</div>
</div>
<div class="testimonial__item second">
<div class="testimonial__img">
<img class="img-fluid" src="https://sandbox-uploads.imgix.net/u/1630477471-dd0cd5b16967417586c822d6dabcb995?w=336&h=412&auto=format&crop=focalpoint&fit=crop" alt="">
</div>
<div class="testimonial__content">
<div class="testimonial__text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Deleniti laboriosam fugiat perferendis blanditiis, dignissimos temporibus sunt aliquam sequi quia! Deleniti earum quibusdam dolorem accusantium ipsum?</div>
<div class="testimonial__credits">
<span class="testimonial__name kicker kicker--bold">Lorem, ipsum.</span>
<span class="testimonial__position kicker kicker--light">Lorem ipsum dolor sit amet,
Burbank,
CA</span>
</div>
</div>
</div>
<div class="testimonial__item third">
<div class="testimonial__img">
<img class="img-fluid" src="https://sandbox-uploads.imgix.net/u/1630477587-e54d61f4eef5e36c72dccd1fc0463514?w=336&h=412&auto=format&crop=focalpoint&fit=crop" alt="">
</div>
<div class="testimonial__content">
<div class="testimonial__text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Deleniti laboriosam fugiat perferendis blanditiis, dignissimos temporibus sunt aliquam sequi quia! Deleniti earum quibusdam dolorem accusantium ipsum?</div>
<div class="testimonial__credits">
<span class="testimonial__name kicker kicker--bold">Lorem, ipsum.</span>
<span class="testimonial__position kicker kicker--light">Lorem ipsum dolor sit amet,
Burbank,
CA</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="test-flex-parent">
<h2 class="flex-child">Hello</h2>
<h2 class="flex-child">World</h2>
</div>

Related

How to rotate a sidebar nav menu as in the model?

I'll explain what I'm looking for. At the moment, I created the entire layout with a CSS grid, I just missed the sidenavbar (example on the first link), but I don't know how to make a list fit in the grid, once I transform: rotate my element it goes away from the screen.
This is the model:
This is where I stand at the moment.
#import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght#100&display=swap');
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-size: medium;
font-family: noto;
}
:root {
/* colors */
--colNoirPhoto: #181818;
--col1: #2F4858;
--col2: #165B6F;
--col3: #00707E;
--col4: #008483;
--col5: #00987D;
--col6: #04AA6D;
--alt1: #0BE0BA;
--alt2: #00BFC9;
--alt3: #ffffff;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Noto Sans', sans-serif;
}
/*side nav bar*/
.sidebar {
display: flex;
position: fixed;
width: 10%;
height: 100%;
color: var(--alt3);
}
/* top content--------------------------------------------------------------------------------*/
.topcontainer {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr;
background-color: var(--colNoirPhoto);
margin-top: 7%;
width: 100%;
height: 20vh;
padding-left: 2vh;
}
.titretopcontainer {
color: var(--alt3);
display: flex;
flex-direction: column;
justify-content: center;
}
.tiretopcontainer h1 {
font-size: 18px;
}
.topcontainer img {
display: flex;
flex-direction: row;
align-items: center;
width: 88%;
grid-row-start: 1;
grid-column-start: 2;
}
/* fin detop content--------------------------------------------------------------------------------*/
/* biographie content--------------------------------------------------------------------------------*/
.containerAllContent {
display: grid;
grid-template-columns: 10% 90%;
background-image: url(/background\ page\ content.png);
}
.separateurdechapitre1 {
display: flex;
padding-left: 1vh;
padding-right: 1vh;
padding-top: 1vh;
background-color: var(--col1);
height: 5vh;
color: var(--alt3);
grid-column-start: 2;
}
.separateurdechapitre2 {
display: flex;
padding-left: 1vh;
padding-right: 1vh;
padding-top: 1vh;
background-color: var(--col2);
height: 5vh;
color: var(--alt3);
grid-column-start: 2;
}
.separateurdechapitre3 {
display: flex;
padding-left: 1vh;
padding-right: 1vh;
padding-top: 1vh;
background-color: var(--col3);
height: 5vh;
color: var(--alt3);
grid-column-start: 2;
}
.separateurdechapitre4 {
display: flex;
padding-left: 1vh;
padding-right: 1vh;
padding-top: 1vh;
background-color: var(--col4);
height: 5vh;
color: var(--alt3);
grid-column-start: 2;
}
.content {
padding-left: 2vh;
padding-right: 2vh;
padding-top: 2vh;
padding-bottom: 2vh;
grid-column-start: 2;
}
/* fin de biographie content--------------------------------------------------------------------------------*/
p {
color: black;
}
footer {
background-color: var(--col1);
}
<main>
<div class="topcontainer">
<div class="titretopcontainer">
<h1>John Conway
</h1>
<h2> Créateur du jeu de la vie
</h2>
</div>
<img src="/Photo de John Conway.png" alt="Photo de John Conway">
</div>
<div class="containerAllContent">
<div class="sidebar">
<a href="">Biographie
</a>
<a href="">Réalisations
</a>
<a href="">Distinctions
</a>
<a href="">Voir aussi
</a>
</div>
<div class="separateurdechapitre1">
<h6>En quelques lignes
</h6>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Architecto laudantium, temporibus nemo possimus inventore
soluta amet exercitationem cumque nobis quasi?
</p>
</div>
<div class="separateurdechapitre2">
<h6>En quelques lignes
</h6>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Architecto laudantium, temporibus nemo possimus inventore
soluta amet exercitationem cumque nobis quasi?
</p>
</div>
<div class="separateurdechapitre3">
<h6>En quelques lignes
</h6>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Architecto laudantium, temporibus nemo possimus inventore
soluta amet exercitationem cumque nobis quasi?
</p>
</div>
<div class="separateurdechapitre4">
<h6>En quelques lignes
</h6>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Architecto laudantium, temporibus nemo possimus inventore
soluta amet exercitationem cumque nobis quasi?
</p>
</div>
</div>
</main>
<footer>
<p>-
</p>
</footer>
Reading your question, I did not fully understand:
If you want your sidebar menu to be aligned vertically instead of horizontally as before.
Or whether you want the menu text to be laid out vertically.
Solution for 1.:
This can be done by setting the CSS property's flex-direction value to column for the element <div class="sidebar">.
CSS
.sidebar {
display: flex;
flex-direction: column;
position: fixed;
width: 10%;
height: 100%;
color: var(--alt3);
}
Solution for 2.:
This can be done by setting the CSS property's writing-mode value to vertical-lr for the element <div class="sidebar">.
CSS
.sidebar {
display: flex;
writing-mode: vertical-lr;
position: fixed;
width: 10%;
height: 100%;
color: var(--alt3);
}

alignment issue in media query

So am trying to align these cards I made using flexbox at a smaller screen size using media query but for some reason am having a bit of trouble aligning the items at the center of the screen when it shrinks down to match the media query am wondering why this occurs. I tried aligning them to the center but it doesnt work.
<section class="bg-lightcareml container">
<div class="container-section">
<h2 class="prod-items">Our Products</h2>
<div class="card-items">
<div class="card">
<img src="blackbird.jpg" alt="">
<div class="card-text">
<h2>CyberWare</h2>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ipsum perferendis iure asperiores
dicta quis vel fugiat, soluta nam laboriosam.
</p>
</div>
</div>
<div class="card">
<img src="blackbird.jpg" alt="">
<div class="card-text">
<h2>CyberWare</h2>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Sint tempore doloremque vero
placeat officiis eaque nisi velit rerum dolorums.</p>
</div>
</div>
<div class="card">
<img src="blackbird.jpg" alt="">
<div class="card-text">
<h2>CyberWare</h2>
<p>
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Veritatis nulla numquam in
provident deserunt! Cumque excepturi delectus
</p>
</div>
</div>
</div>
</div>
</section>
:root {
--clr-pr-200: #fceded;
--clr-pr-300: #bceeff;
--clr-pr-400: #0c0d0d;
--clr-pr-dr-: #ded9d9;
--clr-ctrl-100: #ffffff;
--clr-ntrl-900: #222C2A;
--ff-pr: 'Times New Roman', sans-serif;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.2%;
font-family: Roboto, Arial, Helvetica, sans-serif;
}
body {
font-weight: 400;
font-size: 1.3175rem;
line-height: 1.6;
}
.bg-lightblue {
background-color: var(--clr-pr-300);
height: 12vh;
}
.container {
margin-inline: auto;
width: min(95%, 210rem);
}
/*card-section*/
.bg-lightcareml {
background-color: var(--clr-pr-400);
}
.container-section {
margin-top: 3rem;
min-height: 820px;
max-width: 100%;
margin-bottom: 4rem;
padding: 0.6rem;
}
.container-section>.prod-items {
text-align: center;
font-size: x-large;
font-family: var(--ff-pr);
}
.prod-items {
padding: 1.8rem 0 0 0;
color: var(--clr-pr-200);
}
.card-items {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 2.5rem;
}
.card {
display: flex;
flex: 0 1 200px;
flex-direction: column;
}
.card .card-text {
display: flex;
flex-direction: column;
}
.card-text {
background: var(--clr-ctrl-100);
padding: 1.2rem;
margin-top: -6px;
}
#media (max-width:35rem) {
.container-section {
padding: 5rem 0;
display: flex;
flex-direction: row;
justify-content: center;
}
.card-items {
display: flex;
flex-direction: column;
margin-top: 1.1rem;
max-width: 200px;
}
}
h2,
p {
line-height: 1.4;
font-size: 1.666rem;
font-weight: 500;
}
h2 {
font-weight: bold;
font-size: 1.76rem;
}
.card-items h2 {
text-align: center;
}
.card-items p {
text-align: center;
max-width: 930px
}
.card img {
max-width: 300px;
aspect-ratio: 1.3 / 1;
width: 100%;
}
Will this help? I don't know how you wanted it to look, but I think I think it has a better base you can build on.
:root {
--clr-pr-200: #fceded;
--clr-pr-300: #bceeff;
--clr-pr-400: #0c0d0d;
--clr-pr-dr-: #ded9d9;
--clr-ctrl-100: #ffffff;
--clr-ntrl-900: #222C2A;
--ff-pr: 'Times New Roman', sans-serif;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.2%;
font-family: Roboto, Arial, Helvetica, sans-serif;
}
body {
font-weight: 400;
font-size: 1.3175rem;
line-height: 1.6;
}
.bg-lightblue {
background-color: var(--clr-pr-300);
height: 12vh;
}
.container {
margin-inline: auto;
width: min(95%, 210rem);
}
/*card-section*/
.bg-lightcareml {
background-color: var(--clr-pr-400);
}
.container-section {
margin-top: 3rem;
min-height: 820px;
max-width: 100%;
margin-bottom: 4rem;
padding: 0.6rem;
}
.container-section>.prod-items {
text-align: center;
font-size: x-large;
font-family: var(--ff-pr);
}
.prod-items {
padding: 1.8rem 0 0 0;
color: var(--clr-pr-200);
}
.card-items {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.card {
display: flex;
flex-direction: column;
width: 300px;
}
.card .card-text {
display: flex;
flex-direction: column;
}
.card-text {
background: var(--clr-ctrl-100);
padding: 1.2rem;
margin-top: -6px;
}
#media screen and (min-width: 700px) {
.card-items {
flex-direction: row;
}
.card {
width: auto;
margin: 0 10px;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./index.css" />
<title>Document</title>
</head>
<body>
<section class="bg-lightcareml container">
<div class="container-section">
<h2 class="prod-items">Our Products</h2>
<div class="card-items">
<div class="card">
<img src="blackbird.jpg" alt="">
<div class="card-text">
<h2>CyberWare</h2>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ipsum perferendis iure asperiores
dicta quis vel fugiat, soluta nam laboriosam.
</p>
</div>
</div>
<div class="card">
<img src="blackbird.jpg" alt="">
<div class="card-text">
<h2>CyberWare</h2>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Sint tempore doloremque vero
placeat officiis eaque nisi velit rerum dolorums.</p>
</div>
</div>
<div class="card">
<img src="blackbird.jpg" alt="">
<div class="card-text">
<h2>CyberWare</h2>
<p>
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Veritatis nulla numquam in
provident deserunt! Cumque excepturi delectus
</p>
</div>
</div>
</div>
</div>
</section>
</body>
</html>
You just have to make 2 changes when on mobile
#media (max-width: 35rem)
.container-section {
flex-direction: column;
align-items: center;
}
and it would be ok

Position element at the bottom of container without flex or position absolute

I'm trying to make a component that uses both a background color for half of the component and
an image for the other half, with the image acting as an element with a margin. The problem I'm having is that I cannot use display flex to space elements correctly in the content area, it breaks the component with the current solution I'm using and I have no idea why.
I'm specifically trying to position .service__link at the bottom of .service__content. I've tried using paddings/margins to get it in place, but at smaller screen sizes it ends up overflowing out of the box.
*, *::before, *::after {
box-sizing: border-box;
}
* {
padding: 0;
margin: 0;
}
body {
min-height: 100vh;
font-family: Arial;
}
.service-container {
max-width: 1800px;
margin-inline: auto;
padding: 40px 15px;
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 1.5rem;
}
.service {
flex: 1 1 calc(33.3336% - 1.5rem);
display: inline-block;
position: relative;
background: #144088;
min-height: 325px;
border: 2px solid #144088;
color: white;
}
.service::before {
content: "";
float: right;
width: 100%;
height: 100%;
background: url(https://images.unsplash.com/photo-1645069258059-6f5a71256c4a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2076&q=80) left center/150%;
shape-outside: polygon(79% 0, 100% 0, 100% 100%, 42% 100%);
clip-path: polygon(79% 0, 100% 0, 100% 100%, 42% 100%);
shape-margin: .3em;
}
.service::after {
content: "01";
position: absolute;
top: 0;
font-size: 60px;
font-weight: bold;
line-height: 1;
opacity: 25%;
}
.service__content {
padding: 3rem 0 1rem 1rem;
height: 100%;
}
.service__title {
font-size: 26px;
}
.service__description {
font-size: clamp(12px, 3vw + .25rem, 16px);
}
.service__title, .service__description {
margin-bottom: 1rem;
}
.service__link {
display: inline-flex;
justify-content: space-between;
align-items: center;
width: 35%;
}
.service__link a {
color: white;
}
.service__link img {
filter: brightness(0)invert(1);
}
#media screen and (max-width: 1200px) {
.service {
flex: 0 1 518px;
}
}
<body>
<div class="service-container">
<div class="service">
<div class="service__content">
<h4 class="service__title">Lorem</h4>
<p class="service__description">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Placeat doloremque molestiae eligendi voluptas veniam repellendus, aperiam tempora suscipit consectetur sint?</p>
<div class="service__link">
Link
<img src="https://img.icons8.com/ios/26/000000/image.png"/>
</div>
</div>
</div>
<div class="service">
<div class="service__content">
<h4 class="service__title">Lorem</h4>
<p class="service__description">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Placeat doloremque molestiae eligendi voluptas veniam repellendus, aperiam tempora suscipit consectetur sint?</p>
<div class="service__link">
Link
<img src="https://img.icons8.com/ios/26/000000/image.png"/>
</div>
</div>
</div>
<div class="service">
<div class="service__content">
<h4 class="service__title">Lorem</h4>
<p class="service__description">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Placeat doloremque molestiae eligendi voluptas veniam repellendus, aperiam tempora suscipit consectetur sint?</p>
<div class="service__link ">
Link
<img src="https://img.icons8.com/ios/26/000000/image.png"/>
</div>
</div>
</div>
</div>
</body>
What is going on when display: flex is added to .service__content?
Also, if anybody has a better idea of how to make this component in general I'd love to hear it.
Thanks!
I think you could use this:
position: absolute; bottom: 30px
to put it in the bottom part of the div.
If you set service__link to flex instead of inline flex and add margin-top auto it should stay on the bottom
you have to give position : relative for container
than for service__link position: absolute; left:10px; bottom:10px;
there will be no deterioration in smaller screen.
.service__content {
padding: 3rem 0 1rem 1rem;
height: 100%;
position: relative; // Added
}
.service__link {
display: inline-flex;
justify-content: space-between;
align-items: center;
width: 35%;
position: absolute; // Added
left:10px; // Added
bottom:10px; // Added
}
*, *::before, *::after {
box-sizing: border-box;
}
* {
padding: 0;
margin: 0;
}
body {
min-height: 100vh;
font-family: Arial;
}
.service-container {
max-width: 1800px;
margin-inline: auto;
padding: 40px 15px;
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 1.5rem;
}
.service {
flex: 1 1 calc(33.3336% - 1.5rem);
display: inline-block;
position: relative;
background: #144088;
min-height: 325px;
border: 2px solid #144088;
color: white;
}
.service::before {
content: "";
float: right;
width: 100%;
height: 100%;
background: url(https://images.unsplash.com/photo-1645069258059-6f5a71256c4a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2076&q=80) left center/150%;
shape-outside: polygon(79% 0, 100% 0, 100% 100%, 42% 100%);
clip-path: polygon(79% 0, 100% 0, 100% 100%, 42% 100%);
shape-margin: .3em;
}
.service::after {
content: "01";
position: absolute;
top: 0;
font-size: 60px;
font-weight: bold;
line-height: 1;
opacity: 25%;
}
.service__content {
padding: 3rem 0 1rem 1rem;
height: 100%;
position:relative;
}
.service__title {
font-size: 26px;
}
.service__description {
font-size: clamp(12px, 3vw + .25rem, 16px);
}
.service__title, .service__description {
margin-bottom: 1rem;
}
.service__link {
display: inline-flex;
justify-content: space-between;
align-items: center;
width: 35%;
position:absolute;
left:10px;
bottom:10px;
}
.service__link a {
color: white;
}
.service__link img {
filter: brightness(0)invert(1);
}
#media screen and (max-width: 1200px) {
.service {
flex: 0 1 518px;
}
}
<body>
<div class="service-container">
<div class="service">
<div class="service__content">
<h4 class="service__title">Lorem</h4>
<p class="service__description">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Placeat doloremque molestiae eligendi voluptas veniam repellendus, aperiam tempora suscipit consectetur sint?</p>
<div class="service__link">
Link
<img src="https://img.icons8.com/ios/26/000000/image.png"/>
</div>
</div>
</div>
<div class="service">
<div class="service__content">
<h4 class="service__title">Lorem</h4>
<p class="service__description">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Placeat doloremque molestiae eligendi voluptas veniam repellendus, aperiam tempora suscipit consectetur sint?</p>
<div class="service__link">
Link
<img src="https://img.icons8.com/ios/26/000000/image.png"/>
</div>
</div>
</div>
<div class="service">
<div class="service__content">
<h4 class="service__title">Lorem</h4>
<p class="service__description">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Placeat doloremque molestiae eligendi voluptas veniam repellendus, aperiam tempora suscipit consectetur sint?</p>
<div class="service__link ">
Link
<img src="https://img.icons8.com/ios/26/000000/image.png"/>
</div>
</div>
</div>
</div>
</body>

Make navbar exceed max-width [CSS]

Currently experimenting with HTML and CSS and am struggling with this issue.
I'm messing around with a responsive website, and somehow can't make my navigation bar exceed the max-width of my navbar exceed the max-width of my content.
What I'd like it to look like https://imgur.com/a/KAk9mOi
I do really hope anyone can help me.
TIA.
<nav class="navbar">
<ul class="nav-items">
<li class="nav-item nav-item--active">Home</li>
<li class="nav-item">Contact</li>
</ul>
</nav>
.main {
}
.navbar {
padding: 20px;
background-color: #1C2826;
max-width: 100%;
}
.nav-items {
display: flex;
justify-content: center;
}
.nav-items > li {
flex: 1;
text-align: center;
}
.nav-item:not(:last-of-type) {
margin-right: 20px;
}
.nav-item--active {
/* after */
}
.content {
padding: 8px;
}
.login-card {
border: 1px solid #999;
margin-bottom: 20px;
padding: 12px;
border-radius: 4px;
}
.login {
display: flex;
flex-direction: column;
}
.login-button {
background-color: #D64550;
padding: 4px;
border: none;
color: #ffffff;
font-size: 20px;
}
.login-input {
margin-bottom: 8px;
border: none;
border-bottom: 1px solid #999;
padding-top: 4px;
padding-bottom: 4px;
}
.footer {
padding: 8px;
}
.inline-block {
display: inline-block;
}
/* Alt over 460px */
#media only screen and (min-width: 460px) {
.main{
max-width: 600px;
}
.navigation-items{
flex-wrap: wrap;
}
.login-button {
font-size: inherit;
}
}
https://jsfiddle.net/m0u79e8s/
I hope this is useful
* {
padding: 0px;
margin: 0px;
}
.main {
}
.navbar {
padding: 20px;
background-color: #1C2826;
width: 100%;
}
.nav-items {
display: flex;
justify-content: center;
}
.nav-items > li {
flex: 1;
text-align: center;
}
.nav-item:not(:last-of-type) {
margin-right: 20px;
}
.nav-item--active {
/* after */
}
.content {
padding: 8px;
}
.login-card {
border: 1px solid #999;
margin-bottom: 20px;
padding: 12px;
border-radius: 4px;
}
.login {
display: flex;
flex-direction: column;
}
.login-button {
background-color: #D64550;
padding: 4px;
border: none;
color: #ffffff;
font-size: 20px;
}
.login-input {
margin-bottom: 8px;
border: none;
border-bottom: 1px solid #999;
padding-top: 4px;
padding-bottom: 4px;
}
.footer {
padding: 8px;
}
.inline-block {
display: inline-block;
}
/* Alt over 460px */
#media only screen and (min-width: 460px) {
.main {
display: flex;
flex-direction: column;
align-items: center;
}
.content {
max-width: 460px;
}
.navigation-items{
flex-wrap: wrap;
}
.login-button {
font-size: inherit;
}
}
<!doctype html>
<html>
<head>
<title>Responsive time</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Raleway:400,600,700" rel="stylesheet">
<link rel="stylesheet" href="./reset.css">
<link rel="stylesheet" href="./generic.css">
<link rel="stylesheet" href="./styles.css">
</head>
<html>
<body>
<main class="main">
<!-- Navigation elements -->
<nav class="navbar">
<ul class="nav-items">
<li class="nav-item nav-item--active">Home</li>
<li class="nav-item">Contact</li>
</ul>
</nav>
<!-- Section -->
<section class="content">
<h1 class="test">Time to get responsive</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore deleniti, quia provident!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis quas alias reiciendis velit, dolor eos temporibus culpa ex modi itaque nostrum natus doloribus sed maiores, a obcaecati quia sequi quisquam corrupti perspiciatis sit quam, qui expedita. Nemo sed dolor earum voluptate quod reiciendis rem laborum atque ex nulla sapiente ea ullam assumenda, fugiat quae incidunt dicta, cupiditate repellendus possimus aliquid! Ad veniam vero alias, rem quod atque dolores saepe possimus, tempora, eaque magnam culpa animi repellendus ratione dolorem harum quo.</p>
<!-- Form -->
<div class="login-card">
<form class="login" action="#" method="get">
<input class="login-input" type="email" placeholder="Indtast email">
<input class="login-input" type="password" placeholder="Indtast kodeord">
<button class="login-button">Send</button>
</form>
</div>
<picture>
<source media="(max-width:459px)" srcset="img/cow.jpg">
<source media="(min-width:460px)" srcset="img/dog.jpg">
<img src="/img/cow.jpg" alt="animals">
</picture>
</section>
<footer class="footer">
<div class="footer-content">
<p>Lorem ipsum dolor sit amet.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit quas beatae voluptate.</p>
Some other link
</div>
<div class="footer-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi!</p>
<img class="logo-image" src="/rubbish" alt="">
</div>
</footer>
</main>
</body>
</html>
</html>

2 (or more) columns photo grid maintaining aspect ratio

Simply in Facebook style, I'd like to do something like this:
I've used CSS flex but I am able to do only in row, not columns.
Total width is the fix dimension, total height and column width have to scale and cover all area. Images have to keep aspect ratio.
My code works with 2 rows. I want the same result with images in columns.
<style>
#main{
width:640px;
margin: 0 auto;
}
.flex-row1, .flex-row2 {
display: flex;
flex-direction: row;
}
.inner {
flex: 1 1 auto;
padding: 0;
margin: 0;
margin-right:2px;
}
.inner.last {
margin-right:0;
position:relative;
}
.flex-row1 .inner{
margin-bottom:2px;
}
img {
max-width:100%;
max-height: 250px;
}
.more-container {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4);
display: flex;
align-items: center;
justify-content: center;
}
.more {
font-family: Tahoma, Geneva, sans-serif;
color: #fff;
font-size: 30px;
}
</style>
<div id="main">
<div class="flex-row1">
<figure class="inner">
<img src="https://www.wemedia.it/cms/wp-content/uploads/2017/03/commodore64-android-640x283.jpg">
</figure>
<figure class="inner last">
<img src="https://www.wemedia.it/cms/wp-content/uploads/2017/02/Esslinger-Frog-Design-Apple-1982-640x480.jpg">
</figure>
</div>
<div class="flex-row2">
<figure class="inner">
<img src="https://www.wemedia.it/cms/wp-content/uploads/2017/04/commodore64-silver-label-640x435.jpg">
</figure>
<figure class="inner">
<img src="https://www.wemedia.it/cms/wp-content/uploads/2017/04/commodore64_sx.jpg">
</figure>
<figure class="inner last">
<img src="https://www.wemedia.it/cms/wp-content/uploads/2017/04/C64_golden_edition-640x500.jpg">
<div class="more-container"><div class="more">+3</div></div>
</figure>
</div>
</div>
.equal-height-container {
max-width: 900px;
margin: 0 auto;
display: flex;
}
.first {
background-color: yellow;
flex: 1;
display: flex;
flex-direction: column;
}
.first-a {
background-color: blue;
flex: 1;
}
.first-b {
background-color: orange;
flex: 1;
}
.second {
background-color: yellow;
flex: 1;
display: flex;
flex-direction: column;
}
.second-a {
background-color: #c0dbe2;
flex: 1;
}
.second-b {
background-color: #cdf1c3;
flex: 1;
}
.second-c {
background-color: red;
flex: 1;
}
<div class="equal-height-container">
<div class="first">
<div class="first-a"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsam quasi similique amet voluptatem molestiae nostrum ab nesciunt blanditiis repellendus quos, sequi sunt, dolorem quis facilis mollitia nemo modi doloribus quo.</p></div>
<div class="first-b"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat quisquam, veritatis ducimus, vero magnam hic quia pariatur asperiores laudantium quod nobis perspiciatis, expedita quo reprehenderit quasi iusto ullam error reiciendis.</p></div>
</div>
<div class="second">
<div class="second-a">A</div>
<div class="second-b">B</div>
<div class="second-c">C</div>
</div>
</div>