How can I center image and text in grid? - html

I'm still a rookie, trying to learn HTML and CSS. I'm trying to use 1fr 1fr grid for my "welcome" section. Idea is to put an image on the left side, and text on the right side.
When i go to Inspect and try to see it in Responsive mode, my grid colapses when width goes below 1300, or when height goes below 900.
This is my first section after header, so my question is how should I handle this situation? I don't want to build entire page like this and then realize that I need hundreds of lines of media queries because I used the wrong concept from the beginning :)
I'm trying to get something like this: Example
Below is my code:
.welcome {
padding: 7em 0;
display: flex;
justify-content: center;
}
.welcome-container {
display: grid;
justify-content: center;
align-content: stretch;
grid-template-columns: 1fr 1fr;
width: 100%;
height: 100%;
background-color: white;
height: 50vh;
width: 50vw;
overflow: hidden;
}
.welcome-left {
padding: 3em;
border: 1px blue solid;
text-align: center;
}
.welcome-img {
background-image: url(../../img/tetiana-padurets-B-xb7VFtlZg-unsplash.jpg);
width: 100%;
height: 100%;
}
.img {
display: block;
}
.welcome-right {
border: 1px red solid;
padding: 5em 3em;
}
.welcome-title {
text-align: center;
color: #3f3f3f;
font-weight: 400;
margin-top: 1em;
}
<section class="welcome">
<div class="welcome-container">
<div class="welcome-left">
<div class="welcome-img"></div>
</div>
<div class="welcome-right">
<h2 class="welcome-title"><span>Lorem Ipsum!</h2></span>
<p class="welcome-desc">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Sint dolor voluptas quo id maiores distinctio quidem, voluptatum voluptates dolorem eum eius vitae. Doloremque maiores, inventore vel error perferendis necessitatibus quae debitis cumque ipsa explicabo facere soluta vero asperiores, voluptates reprehenderit labore accusantium dolores.
</p>
</div>
</div>
</section>
Cheers!

<section class="welcome">
<div class="welcome-container">
<div class="welcome-left">
<div class="welcome-img">
<img class="image" src="https://i.picsum.photos/id/237/200/300.jpg?hmac=TmmQSbShHz9CdQm0NkEjx1Dyh_Y984R9LpNrpvH2D_U">
</div>
</div>
<div class="welcome-right">
<h2 class="welcome-title"><span>Lorem Ipsum!</h2></span>
<p class="welcome-desc">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Sint dolor voluptas quo id maiores distinctio quidem, voluptatum voluptates dolorem eum eius vitae. Doloremque maiores, inventore vel error perferendis necessitatibus quae debitis cumque ipsa explicabo facere soluta vero asperiores, voluptates reprehenderit labore accusantium dolores.
</p>
</div>
</div>
</section>
In CSS
.welcome {
display: flex;
justify-content: center;
width: 100%;
}
.welcome-container {
display: grid;
justify-content: center;
align-content: stretch;
grid-template-columns: 1fr 1fr;
background-color: white;
width: 50vw;
}
.welcome-left {
padding: 10px;
border: 1px blue solid;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
.image {
width: 100%;
height: auto;
}
.img {
display: block;
}
.welcome-right {
border: 1px red solid;
padding: 10px;
}
.welcome-title {
text-align: center;
color: #3f3f3f;
font-weight: 400;
font-size: 2vw;
margin-top: 1em;
}
.welcome-desc {
font-size: 1vw;
}
.welcome-img {
width: 100%;
}
I guess you want something like this.

Related

Background color change is not applying while changing the width of the page

I'm learning html/css, and while making a page, I want to test if I could make the color of a button to change from red to green when the width is under 900px. After multiple tests, the other properties work fine (bold text, text color) but the background-color of the button doesn't seem to change at all, and I can't find why.
The HTML code is :
<!DOCTYPE html>
<html lang="fr">
<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">
<title>Landing EST</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="styleaccueil.css">
<!-- <link rel="stylesheet" href="styleaccueilphone.css"> -->
</head>
<body>
<header id="hautdepage">
<img class="logoheader" src="/">
Nos activités
Formulaire
Nous connaître
<a href="mailto:xxx" class="texteheader" target="_blank" >Nous contacter</a>
</header>
<div id="toutsaufheaderfooter" >
<div class="presentation">
<div class="textepresentation">
<h1 class="titrepresentation">Qui sommes nous ?</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facilis atque consectetur ut amet laboriosam ratione fugit impedit velit, dolore in aliquid sint sit corporis ad sequi excepturi a tenetur molestiae eligendi ex delectus alias officia! Ratione dignissimos necessitatibus doloribus! Ipsa vel officiis optio, iure modi atque quo at aspernatur numquam.</p>
<div class="boutonspresentation" >
<a href="https://fr.linkedin.com" class="bouton1" target="_blank" >Faisons connaissance</a>
<a href="mailto:xxx" class="bouton1" target="_blank" >Contactez-nous</a>
</div>
</div>
<iframe src= "https://www.youtube.com/embed/weP6BLvfzG8" frameborder= "0" allowfullscreen></iframe>
</div>
<div class="deuxiemesalve">
<div class="deuxiemesalveparagraphetitre">
<div class="blocdeuxiemesalve" >
<h2 class="h2deuxiemesalve">Lorem ipsum dolor sit amet.</h2>
<p class="textedeuxiemesalve">Lorem ipsum dolor sit amet consectetur adipisicing elit. Esse, tenetur quasi magnam fuga beatae eum voluptas repellat. Unde quam asperiores esse? Nesciunt praesentium enim aperiam culpa fugiat reprehenderit esse labore, nulla molestias. Hic debitis, officiis pariatur odit enim ut facere.</p>
</div>
<div class="blocdeuxiemesalve" >
<h2 class="h2deuxiemesalve">Lorem ipsum dolor sit amet.</h2>
<p class="textedeuxiemesalve">Lorem ipsum dolor sit amet consectetur adipisicing elit. Esse, tenetur quasi magnam fuga beatae eum voluptas repellat. Unde quam asperiores esse? Nesciunt praesentium enim aperiam culpa fugiat reprehenderit esse labore, nulla molestias. Hic debitis, officiis pariatur odit enim ut facere.</p>
</div>
<div class="blocdeuxiemesalve" >
<h2 class="h2deuxiemesalve">Lorem ipsum dolor sit amet.</h2>
<p class="textedeuxiemesalve">Lorem ipsum dolor sit amet consectetur adipisicing elit. Esse, tenetur quasi magnam fuga beatae eum voluptas repellat. Unde quam asperiores esse? Nesciunt praesentium enim aperiam culpa fugiat reprehenderit esse labore, nulla molestias. Hic debitis, officiis pariatur odit enim ut facere.</p>
</div>
</div>
</div>
<div class="troisiemesalve">
<img class="imagedouble" src="images/howscrumwork.jpg">
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Voluptatum laudantium vel non quas eum aliquid ut quo incidunt aspernatur in aperiam, nulla, commodi vitae placeat. Magni similique cum omnis quae!</p>
<img class="imagedouble" src="images/mecpostit.jpg">
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Voluptatum laudantium vel non quas eum aliquid ut quo incidunt aspernatur in aperiam, nulla, commodi vitae placeat. Magni similique cum omnis quae!</p>
</div>
</div>
<footer>
<div class="boitefooter">
<div class="footerun">
<p>ici on mettrais des liens vers les réseaux sociaux ou les mentions légales par exemple</p>
</div>
<div class="footerdeux">
<a class="retourvershautdepage" href="#hautdepage" > Retour en haut de page </a>
</div>
</div>
</footer>
</body>
</html>
The 1st CSS code is :
/* Reset CSS */
*{
margin: 0;
padding: 0;
/* box-sizing: border-box; */
}
body{
font-family: 'Lato', sans-serif;
width: 100%;
}
/*Ici je dis que toute la page sera en Lato sauf contradiction*/
/*Ici je me met le leins de la police Libre Franklin si besoin = font-family: 'Libre Franklin', sans-serif; */
header{
display: flex;
justify-content: center;
flex-direction: row;
align-items: center;
width: 100%;
}
.logoheader{
min-width: 10%;
min-height: 10%;
max-width: 12%;
max-height: 12%;
margin : 1em
}
.texteheader{
margin: 1em;
color: black;
text-decoration:none;
}
.retourvershautdepage{
padding: 10px 30px;
background: rgb(192, 44, 44);
color: white;
text-decoration:none;
border-radius: 50px;
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
}
.retourvershautdepage:hover{
background: rgb(196, 104, 17);
}
.retourverspageaccueil{
padding: 10px 30px;
background: rgb(192, 44, 44);
color: white;
text-decoration:none;
border-radius: 50px;
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
}
.retourverspageaccueil:hover{
background: rgb(196, 104, 17);
}
footer{
margin-top: 3em;
text-align: center;
background-color: darkblue;
color: aliceblue;
width: 100%;
}
.boitefooter{
width: 100%;
display: flex;
align-items: center;
justify-content: space-evenly;
flex-wrap: wrap;
}
#media only screen and (max-width:900px) {
.retourvershautdepage{
font-weight: bold;
background: rgb(44, 192, 44);
}
.retourvershautdepage:hover{
background: rgb(231, 217, 16);
}
}
.footerdeux{
margin-top: 15px;
}
The 2nd CSS is :
.presentation{
display: flex;
margin-top: 3em;
align-items: center;
justify-content: flex-end;
}
.presentation p{
margin-bottom: 20px;
}
.textepresentation{
width: 30%;
max-height: 15%;
margin-right: 8em;
}
a.bouton1 {
padding: 10px 30px;
margin: 5px;
background: rgb(0, 0, 95);
color: white;
text-decoration:none;
border-radius: 50px;
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
}
a.bouton1:hover {
background: rgb(196, 17, 115);
}
iframe{
width: 900px;
height: 500px;
}
.deuxiemesalveparagraphetitre{
display: flex;
justify-content: space-evenly;
align-content: center;
align-items: center;
}
.deuxiemesalve{
display: flex;
justify-content: space-evenly;
align-content: center;
align-items: center;
margin-left: 7em;
margin-right: 7em;
text-align: center;
}
.h2deuxiemesalve{
margin-left: 2em;
margin-right: 2em;
margin-top: 3em;
}
.deuxiemesalveparagraphe{
display: flex;
justify-content: space-evenly;
align-content: center;
align-items: center;
}
.textedeuxiemesalve{
margin-left: 2em;
margin-right: 2em;
}
.troisiemesalve{
display: flex;
margin-top: 5em;
align-items: center;
}
.imagedouble{
width: 20%;
height: 15%;
margin-left: 2em;
margin-right: 2em;
}
.retourvershautdepage{
padding: 10px 30px;
background: rgb(192, 44, 44);
color: white;
}
#media only screen and (max-width: 900px) {
body{
display: flex;
flex-direction: column;
text-align: center;
width: 100%;
font-family: 'Lato', sans-serif;
}
#toutsaufheaderfooter{
padding: 0 20px;
display: flex;
flex-direction: column;
}
.presentation{
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
margin-top: 15px;
}
iframe{
height: 248px;
width: 100%;
}
.textepresentation{
width: 95%;
padding: 15px 0;
margin-right: 0;
}
.boutonspresentation{
display: flex;
flex-direction: column;
}
.blocdeuxiemesalve{
padding: 15px 0;
}
.deuxiemesalve{
margin: 0;
margin-top: 15px;
}
.deuxiemesalveparagraphetitre{
display: flex;
flex-direction: column;
align-content: none;
align-items: none;
}
.h2deuxiemesalve{
margin: 0 0 15px 0;;
}
.textedeuxiemesalve{
margin: 0;
}
.troisiemesalve{
display: flex;
flex-direction: column;
margin-top: 0;
}
.imagedouble{
width: 60%;
padding: 10px 0;
margin: 15px 0;
}
}
Because your 2nd file define "retourvershautdepage backgroup color" again ,
You need to ensure #media is in the last of your css file , or it will be replaced by your 2nd file.

How to make square image container with css grid

I want to make a modal with a image and other elements to the right, something like this:
I tried making the modal content as a grid with two columns, the problems is when I try to adjust the image to fill all the avaiable space in the modal content, it overflows like this:
My css code looks like this:
<div class="modal">
<div class="content">
<div class="frame">
<img src="https://picsum.photos/400" alt="Example">
</div>
<div class="text">
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Quis est mollitia possimus omnis nisi quo
aliquid ad accusantium dignissimos corrupti. Impedit, asperiores magnam corporis iste possimus tempore
quisquam provident dicta. Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quibusdam
consequuntur, incidunt hic dolorum tempora inventore id sint ullam magnam veniam eveniet vitae, harum
dolorem tenetur libero voluptate voluptatibus. Inventore, excepturi!
</div>
</div>
</div>
.modal {
position: fixed;
height: 100%;
width: 100%;
background-color: rgba($color: #000000, $alpha: 0.6);
display: grid;
place-items: center;
}
.content {
background-color: $color-white;
width: 60%;
height: 600px;
border-radius: 5px;
display: grid;
grid-template-columns: auto 300px;
}
.frame > img {
width: 100%;
max-height: 100%;
object-fit: cover;
}
.text {
padding: 2rem 1rem;
}
The modal I tried to do has the problem of the image overflow. I setted the container div to grid with two columns, but the image column overflows the container as we can see in the picture. I want the image to take the space avaiable in the container but maintaining the 1 : 1 aspect ratio, also to be responsive, when the user change the screen size the image always has to maintain the 1:1 aspect ratio and not crop the image.I setted the height as static pixels because I want to add a element with a scrolling bar that otherwise will overflow or expand the container if its height was declared as percentages.
Just specify a max-height to the container(.frame) it will start working fine for 1:1 images because max-height:100% doesn't mean anything if you don't specify a height for its parent
and if you want to work for any ratio then remove the width property from the .frame > img because if you don't specify a width it will adjust itself according to it's height
I think the easiest way would be to use css aspect-ratio like this:
img {
width: 100%;
aspect-ratio: 1;
}
you can read more about it here
I think the problem might be the fact that your image's parent ( .frame ) does not have a set height.Try adding this:
.frame {
height:100%
}
I solved it removing the height of the modal content div. This allow the image to take all the space it needs. For the text to the right to not overgrow the image, what i did was make a div container and inside it a p tag with position absolute and with the widht and height of his parent, but with overflow: scroll. This allowed me to have mi image in 1:1 ratio taking all the space it needs in the card but without the text overflowing things. Here is how I did it.
.modal {
position: fixed;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
display: grid;
place-items: center;
}
.container {
width: 60%;
display: grid;
grid-template-columns: 1fr 30%;
background-color: #f4f4ed;
}
.frame {
width: 100%;
height: 100%;
}
.frame img {
width: 100%;
height: 100%;
object-fit: cover;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
padding: 2em 0.8em;
}
.content h5 {
font-size: 1.4rem;
font-weight: 600;
color: #00f0b5;
}
.text {
flex-grow: 1;
position: relative;
height: 100%;
width: 100%;
overflow-y: scroll;
}
.text p {
font-size: 0.8rem;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.actions {
width: 100%;
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 0.5rem;
}
.actions button {
font-family: "Roboto Condensed", sans-serif;
font-weight: 600;
text-transform: uppercase;
border: none;
outline: none;
background-color: #00f0b5;
padding: 0.2em 0;
cursor: pointer;
font-size: 0.5rem;
}
body {
font-size: 62.5%;
box-sizing: border-box;
}
h5{
margin: 0;
line-height: 1;
}
<div class="modal">
<div class="container">
<div class="frame">
<img src="https://picsum.photos/800" alt="Some lorem picsum">
</div>
<div class="content">
<h5>Title</h5>
<div class="text">
<p>
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Laborum placeat sed voluptatem optio esse facere accusamus tempore, provident dolorem nemo rerum sit accusantium labore quae eveniet ea aliquam. Ipsa, aliquam? Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Laborum placeat sed voluptatem optio esse facere accusamus tempore, provident dolorem nemo rerum sit accusantium labore quae eveniet ea aliquam. Ipsa, aliquam? Lorem ipsum dolor sit amet consectetur, adipisicing elit. Laborum
placeat sed voluptatem optio esse facere accusamus tempore, provident dolorem nemo rerum sit accusantium labore quae eveniet ea aliquam. Ipsa, aliquam?
</p>
</div>
<div class="actions">
<button>Accept</button>
<button>Cancel</button>
</div>
</div>
</div>
</div>

section overlaps on another section

I am having a problem with positioning, everything works fine except the last section contactform.
The problem is that when I zoom in, the contactform overlaps on services section.
Here's the code:
.services {
width: 100%;
height: 160vh;
margin: 100px 0;
position: relative;
}
.services-content {
/* position: relative; */
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.services-content h1 {
font-size: 40px;
letter-spacing: 4px;
}
.content-row-one {
width: 90%;
height: 100%;
justify-content: center;
display: flex;
margin-top: 100px;
}
.row-one {
display: flex;
width: 85%;
height: 300px;
margin: 20px 30px;
}
.quality-management {
display: flex;
flex-direction: column;
width: 35%;
height: 200px;
margin: 0px 60px;
}
.quality-management h6 {
font-size: 18px;
text-transform: uppercase;
}
.testing-calibration {
display: flex;
flex-direction: column;
width: 35%;
height: 200px;
margin: 0px 60px;
}
.testing-calibration h6 {
font-size: 18px;
text-transform: uppercase;
}
.medical-devices {
display: flex;
flex-direction: column;
width: 35%;
height: 200px;
margin: 0px 60px;
}
.medical-devices h6 {
font-size: 18px;
text-transform: uppercase;
}
.content-row-two {
width: 90%;
height: 100%;
justify-content: center;
display: flex;
}
.row-two {
display: flex;
width: 85%;
height: 300px;
margin: 20px 30px;
}
.lead-auditor {
display: flex;
flex-direction: column;
width: 35%;
height: 200px;
margin: 0px 60px;
}
.lead-auditor h6 {
font-size: 18px;
text-transform: uppercase;
}
.project-management {
display: flex;
flex-direction: column;
width: 35%;
height: 24px;
margin: 0px 60px;
}
.project-management h6 {
font-size: 18px;
text-transform: uppercase;
}
.quality-assurance {
display: flex;
flex-direction: column;
width: 35%;
height: 200px;
margin: 0px 60px;
}
.quality-assurance h6 {
font-size: 18px;
text-transform: uppercase;
}
.content-row-three {
width: 90%;
height: 100%;
justify-content: center;
display: flex;
}
.row-three {
display: flex;
width: 85%;
height: 300px;
margin: 20px 30px;
}
.document-management {
display: flex;
flex-direction: column;
width: 35%;
height: 200px;
margin: 0px 60px;
}
.document-management h6 {
font-size: 18px;
text-transform: uppercase;
}
.contactform {
width: 100%;
height: 50vh;
position: relative;
}
.contact {
width: 100%;
height: 100%;
text-align: center;
}
.contact h1 {
font-size: 40px;
letter-spacing: 4px;
}
.contact-content {
width: 70%;
height: 100%;
display: flex;
/* justify-content: center;
text-align: center; */
margin: 0 auto;
/* position: absolute; */
margin-top: 50px;
}
.contact-column-one {
width: 33%;
height: 50%;
}
.contact-column-one .location i {
font-size: 50px;
cursor: pointer;
}
.contact-column-one .location i:hover{
color: rgb(19, 112, 233);
transition: .5s;
}
.contact-column-one h1 {
font-size: 30px;
}
.contact-column-two {
width: 33%;
height: 50%;
}
.contact-column-two .phone i {
font-size: 50px;
cursor: pointer;
}
.contact-column-two .phone i:hover {
color: rgb(19, 112, 233);
transition: .5s;
}
.contact-column-two h1 {
font-size: 30px;
}
.contact-column-three {
width: 33%;
height: 50%;
}
.contact-column-three .email i {
font-size: 50px;
cursor: pointer;
}
.contact-column-three .email i:hover {
color: rgb(19, 112, 233);
transition: .5s;
}
.contact-column-three h1 {
font-size: 30px;
}
<section class="services" id="services">
<div class="services-content">
<h1>OUR SERVICES</h1>
<div class="content-row-one">
<div class="row-one">
<div class="quality-management">
<h6>1. Quality Management Systems according to ISO 9000 2015</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
<div class="testing-calibration">
<h6>2. Quality Management Systems for Testing and Calibration Laboratories</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
<div class="medical-devices">
<h6>3. Quality Management for Medical Devices according to ISO 13485</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
</div>
</div>
<div class="content-row-two">
<div class="row-two">
<div class="lead-auditor">
<h6>4. Lead Auditor according to ISO 9001</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
<div class="project-management">
<h6>5. Project Management</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
<div class="quality-assurance">
<h6>6. Quality Assurance</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
</div>
</div>
<div class="content-row-three">
<div class="row-three">
<div class="document-management">
<h6>7. Document Management with SharePoint Server</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
</div>
</div>
</section>
<section class="contactform" id="contactform">
<div class="contact">
<h1>CONTACT US</h1>
<div class="contact-content">
<div class="contact-column-one">
<span class="location">
<i class="material-icons">
place
</i>
</span>
<h1>ADDRESS</h1>
<p>Address</p>
</div>
<div class="contact-column-two">
<span class="phone">
<i class="material-icons">
phone
</i>
</span>
<h1>PHONE</h1>
<p>Phone Number</p>
</div>
<div class="contact-column-three">
<span class="email">
<i class="material-icons">
email
</i>
</span>
<h1>EMAIL</h1>
<p>Email</p>
</div>
</div>
</div>
</section>
I've tried removing position, from absolute to relative and vice versa, but nothing changed.
If you need more code or explanation please feel free to ask.
Thank you for your time!
Here's a photo:
While you have a fixed height for .services it will always overlap when the content total height higher than .services height, instead you could use min-height so if the content height less than 160vh the height will remain 160vh but if the content height more than 160vh then .services height will grow corresponding to the content.
.services {
width: 100%;
min-height: 160vh;
margin: 100px 0;
position: relative;
}
.services-content {
/* position: relative; */
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.services-content h1 {
font-size: 40px;
letter-spacing: 4px;
}
.content-row-one {
width: 90%;
height: 100%;
justify-content: center;
display: flex;
margin-top: 100px;
}
.row-one {
display: flex;
width: 85%;
height: 300px;
margin: 20px 30px;
}
.quality-management {
display: flex;
flex-direction: column;
width: 35%;
height: 200px;
margin: 0px 60px;
}
.quality-management h6 {
font-size: 18px;
text-transform: uppercase;
}
.testing-calibration {
display: flex;
flex-direction: column;
width: 35%;
height: 200px;
margin: 0px 60px;
}
.testing-calibration h6 {
font-size: 18px;
text-transform: uppercase;
}
.medical-devices {
display: flex;
flex-direction: column;
width: 35%;
height: 200px;
margin: 0px 60px;
}
.medical-devices h6 {
font-size: 18px;
text-transform: uppercase;
}
.content-row-two {
width: 90%;
height: 100%;
justify-content: center;
display: flex;
}
.row-two {
display: flex;
width: 85%;
height: 300px;
margin: 20px 30px;
}
.lead-auditor {
display: flex;
flex-direction: column;
width: 35%;
height: 200px;
margin: 0px 60px;
}
.lead-auditor h6 {
font-size: 18px;
text-transform: uppercase;
}
.project-management {
display: flex;
flex-direction: column;
width: 35%;
height: 24px;
margin: 0px 60px;
}
.project-management h6 {
font-size: 18px;
text-transform: uppercase;
}
.quality-assurance {
display: flex;
flex-direction: column;
width: 35%;
height: 200px;
margin: 0px 60px;
}
.quality-assurance h6 {
font-size: 18px;
text-transform: uppercase;
}
.content-row-three {
width: 90%;
height: 100%;
justify-content: center;
display: flex;
}
.row-three {
display: flex;
width: 85%;
height: 300px;
margin: 20px 30px;
}
.document-management {
display: flex;
flex-direction: column;
width: 35%;
height: 200px;
margin: 0px 60px;
}
.document-management h6 {
font-size: 18px;
text-transform: uppercase;
}
.contactform {
width: 100%;
height: 50vh;
position: relative;
}
.contact {
width: 100%;
height: 100%;
text-align: center;
}
.contact h1 {
font-size: 40px;
letter-spacing: 4px;
}
.contact-content {
width: 70%;
height: 100%;
display: flex;
/* justify-content: center;
text-align: center; */
margin: 0 auto;
/* position: absolute; */
margin-top: 50px;
}
.contact-column-one {
width: 33%;
height: 50%;
}
.contact-column-one .location i {
font-size: 50px;
cursor: pointer;
}
.contact-column-one .location i:hover{
color: rgb(19, 112, 233);
transition: .5s;
}
.contact-column-one h1 {
font-size: 30px;
}
.contact-column-two {
width: 33%;
height: 50%;
}
.contact-column-two .phone i {
font-size: 50px;
cursor: pointer;
}
.contact-column-two .phone i:hover {
color: rgb(19, 112, 233);
transition: .5s;
}
.contact-column-two h1 {
font-size: 30px;
}
.contact-column-three {
width: 33%;
height: 50%;
}
.contact-column-three .email i {
font-size: 50px;
cursor: pointer;
}
.contact-column-three .email i:hover {
color: rgb(19, 112, 233);
transition: .5s;
}
.contact-column-three h1 {
font-size: 30px;
}
<section class="services" id="services">
<div class="services-content">
<h1>OUR SERVICES</h1>
<div class="content-row-one">
<div class="row-one">
<div class="quality-management">
<h6>1. Quality Management Systems according to ISO 9000 2015</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
<div class="testing-calibration">
<h6>2. Quality Management Systems for Testing and Calibration Laboratories</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
<div class="medical-devices">
<h6>3. Quality Management for Medical Devices according to ISO 13485</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
</div>
</div>
<div class="content-row-two">
<div class="row-two">
<div class="lead-auditor">
<h6>4. Lead Auditor according to ISO 9001</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
<div class="project-management">
<h6>5. Project Management</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
<div class="quality-assurance">
<h6>6. Quality Assurance</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
</div>
</div>
<div class="content-row-three">
<div class="row-three">
<div class="document-management">
<h6>7. Document Management with SharePoint Server</h6>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. In omnis magni praesentium velit sit
sapiente sed magnam accusamus quisquam, maxime rem! Adipisci, quisquam? Dolor fugiat dolores
porro
quo perferendis accusamus!</p>
</div>
</div>
</div>
</section>
<section class="contactform" id="contactform">
<div class="contact">
<h1>CONTACT US</h1>
<div class="contact-content">
<div class="contact-column-one">
<span class="location">
<i class="material-icons">
place
</i>
</span>
<h1>ADDRESS</h1>
<p>Address</p>
</div>
<div class="contact-column-two">
<span class="phone">
<i class="material-icons">
phone
</i>
</span>
<h1>PHONE</h1>
<p>Phone Number</p>
</div>
<div class="contact-column-three">
<span class="email">
<i class="material-icons">
email
</i>
</span>
<h1>EMAIL</h1>
<p>Email</p>
</div>
</div>
</div>
</section>
You should set height: auto;
jsfiddle:
https://jsfiddle.net/qhsygpb5/
Explanation: when you set "height: 200px" element height will be 200px no matter how much content contains. Other solution is to add "overflow:hidden;" but than you will not see all content if there is not room. Also you can add "overflow: scroll;" if you want to scroll the content within 200px height.

css grid - hide row in media query

I'm using css grid to make my layout. I would like to hide my details row and only show sidebar row in media query (max-576px). When i want to see Details row i should do click in "Show detail" button and hide Sidebar row. I have tried different ways but i couldn't achieve solve.
I really appreciate any helps .
My code
* {
margin: 0;
padding: 0;
}
.container {
margin: 0;
height: 100%;
display: grid;
grid-template-columns: 100%;
grid-template-rows: 40px 1fr;
grid-column-gap: 0;
}
.header {
background-color: #ececec;
}
.main {
background-color: yellow;
display: grid;
grid-template-columns: 40px 1fr;
}
.apps {
background-color: lightgrey;
}
.content {
background-color: blue;
display: grid;
grid-template-columns: 100%;
grid-template-rows: auto 1fr;
}
.content-header {
background-color: red;
/* display: flex; */
}
.content-body {
background-color: antiquewhite;
display: grid;
grid-template-columns: 250px 1fr;
grid-template-rows: 1fr;
}
.sidebar-panel {
background-color: aquamarine;
}
.sidebar-button,
.detail-panel-button {
display: none;
}
.details-panel {
background-color: cyan;
}
#media screen and (max-width:576px) {
.main {
grid-template-columns: 100%;
grid-template-rows: 1fr 40px;
}
.content {
order: 1;
}
.apps {
order: 2
}
.content-body {
grid-template-columns: 1fr;
grid-template-rows: 1fr;
}
.sidebar-panel {
display: block;
}
.details-panel {
display: none;
}
.sidebar-button,
.detail-panel-button {
display: block;
}
}
button {
background: #0084ff;
border: none;
border-radius: 5px;
padding: 8px 14px;
font-size: 15px;
color: #fff;
}
#banner-message.alt {
background: #0084ff;
color: #fff;
margin-top: 40px;
width: 200px;
}
#banner-message.alt button {
background: #fff;
color: #000;
}
<div class="container">
<div class="header">
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eveniet, expedita.
</div>
<div class="main">
<div class="apps">
App1 <br>
App2
</div>
<div class="content">
<div class="content-header">
<div style="height: 40px;">
Ribbon
</div>
</div>
<div class="content-body">
<div class="sidebar-panel">
<h3>Sidebar</h3>
<button class="sidebar-button">Show Detail</button>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Laboriosam reprehenderit suscipit
molestias minus velit earum sed quasi tenetur sit voluptate.
</div>
<div class="detail-panel">
<h3>Detail</h3>
<button class="detail-panel-button">Show Sidebar</button>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Facilis ex nam, laudantium cumque
voluptas aliquid harum esse veniam deserunt numquam. Odit tenetur sunt, harum laborum
voluptatibus pariatur. Ad, nemo ipsa iure recusandae dignissimos iusto odio libero sapiente
neque! Tenetur et quam magnam, numquam assumenda a aut! Dignissimos, sit. Impedit modi
necessitatibus alias voluptatum odio ipsum enim quam eum, harum animi quidem, itaque
</div>
</div>
</div>
</div>
</div>
Damn it bro
You made a tiny little mistake. Just modify .details-panel to .detail-panel.
And pls paste this <meta name="viewport" content="width=device-width, initial-scale=1"> inside your <head> tag

What is wrong with the layout of div's?

I'm fairly new to html and css and I have a trouble with understanding of the layout. Here is an example which I have created to show my problem.
What I would expect is for #bottom to be inside the #page but it is below it. Additionally the div #else which I would thought should be below the #page is in the same space as the #bottom.
Could you please help me understand what I'm doing wrong here?
header {
display: block;
margin: 0px auto;
height: 20vh;
width: 80vw;
border: 1px solid green;
}
#page {
margin: 0 auto;
width: 90vw;
border: 3px solid black;
}
#main {
display: block;
float: left;
height: 60vh;
width: 67.5vw;
border: 1px solid green;
}
#side {
display: inline-block;
margin-left: 2px;
height: 60vh;
width: 21.5vw;
border: 1px solid green;
}
#bottom {
float: left;
margin: 0 auto;
height: 4vh;
width: 90vw;
border: 1px solid green;
}
#else {
height: 10vh;
width: 90vw;
background-color: red;
margin: 0 auto;
}
<div id="page">
<header>
</header>
<div id="main">
</div>
<div id="side">
</div>
<div id="bottom">
</div>
</div>
<div id="else">
</div>
I don't get why did you put this float:left in your footer.If you remove it everything should work fine
#bottom {
margin: 0 auto;
height: 4vh;
width: 90vw;
border: 1px solid green;
}
Remove float left from #bottom
#bottom {
background-color:green;
margin: 0 auto;
height:50px;
width:100px;
border: 1px solid green;
}
here is the link: https://codepen.io/Dholu_Effect/pen/PoqByQa?editors=1100
Also I would sugges you to use Flex-box, it will make things much easier.
<body>
<div id="page">
<header>Header</header>
<div id="main">Main</div>
<div id="side">Side</div>
<div id="bottom">Bottom</div>
</div>
<div id="else">Else</div>
</body>
And the css
header {
display: block;
margin: 0px auto;
height: 20vh;
width: 80vw;
border: 1px solid green;
}
#page {
margin: 0 auto;
width: 90vw;
border: 3px solid black;
}
#main {
display: block;
float: left;
height: 60vh;
width: 67.5vw;
border: 1px solid green;
}
#side {
display: inline-block;
margin-left: 2px;
height: 60vh;
width: 21.5vw;
border: 1px solid green;
}
#bottom {
margin: 0 auto;
height: 4vh;
width: 90vw;
border: 1px solid green;
background-color:#ddd;
}
#else {
height: 10vh;
width: 90vw;
background-color: red;
margin: 0 auto;
}
https://codepen.io/erwinagpasa/pen/ZEGjqjY
I think you can see this
header {
display: block;
margin: 0px auto;
height: 20vh;
width: 90vw;
background-color: #011a2f
}
#page {
margin: 0 auto;
width: 90vw;
}
#main {
float: left;
height: 60vh;
width: 67.5vw;
background-color: #323232
}
#side {
overflow: hidden;
margin-left: 2px;
height: 60vh;
width: 22.5vw;
background-color: #ff1e56;
}
#bottom {
height: 5vh;
width: 90vw;
background-color: #000000;
}
#else {
height: 10vh;
width: 90vw;
background-color: #ffac41;
margin: 0 auto;
}
<div id="page">
<header></header>
<div id="main"></div>
<div id="side"></div>
<div id="bottom"></div>
</div>
<div id="else"></div>
This is the closest i can do for you to understand it in your beginner level
*{
box-sizing:border-box; /* this will let the border/padding be included in the elements size */
}
#page {
margin: 0 auto;
width: 90%;
border: 3px solid black;
}
header {
display: inline-block;
margin: 0 10%;
height: 20vh;
width: 80%;/* changed to percentage which is more logic to follow its parent not the viewport width */
border: 1px solid green;
}
#main {
display: inline-block;
height: 60vh;
width: 67.5%;
border: 1px solid green;
margin:0;
margin-left:5%;
}
#side {
display: inline-block;
margin-left: 2px;
height: 60vh;
width: calc(22.5% - 6px);/* 2 for the margin left, 4 for the borders*/
border: 1px solid green;
}
#bottom {
/*float: left;*/
margin: 0 auto;
height: 4vh;
width: 90%; /* percentage */
border: 1px solid green;
}
#else {
height: 10vh;
width: 90%;
background-color: red;
margin: 0 auto;
}
<div id="page">
<header>
</header>
<div id="main">
</div>
<div id="side">
</div>
<div id="bottom">
</div>
</div>
<div id="else">
</div>
I just made few adjustments in your code, I hope that is fine with you:
Note: View in full screen mode for more clarity.
#page {
margin: 0 auto;
width: 90vw;
border: 1px solid black;
}
header {
display: absolute;
margin: 0px auto;
height: 20vh;
width: 80vw;
border: 1px solid green;
}
#main {
float: left;
height: 60vh;
width: 67.5vw;
border: 1px solid green;
}
#side {
display: inline-block;
margin-left: 2px;
height: 60vh;
width: 21.5vw;
border: 1px solid green;
}
#bottom {
height: 4vh;
width: 90vw;
border: 1px solid green;
background-color:green;
}
#else {
height: 10vh;
width: 90vw;
background-color: pink;
margin: 0 auto;
}
<div id="page">
<header>header
</header>
<div id="main">main
</div>
<div id="side">side
</div>
<div id="bottom">bottom
</div>
</div>
<div id="else">else
</div>
My recommendation is that you use flexbox. Here is a quick responsive design I did with HTML5 selectors. Since you're new to HTML/CSS, I would suggest you start learning this way and avoid so many div classes, as that doesn't work that great with accessibility, which is a huge issue in today's development world.
And here is a codepen you can play with.
/* Roboto Font */
#import url('https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i&display=swap');
html {
height: 100%;
}
body {
display: flex;
flex-direction: column;
height: 100vh; /* Avoid the IE 10-11 `min-height` bug. */
font-family: 'Roboto', sans-serif;
}
.content {
flex: 1 0 auto; /* Prevent Chrome, Opera, and Safari from letting these items shrink to smaller than their content's default minimum size. */
background: darkgray;
}
header {
height: 20vh;
display: flex;
justify-content: center;
align-items: center;
background: #ccc;
}
header h1 {
font-size: 4rem;
font-weight: 300;
}
main {
display: flex;
}
article {
width: 70%;
justify-content: flex-start;
padding: 0.5rem;
}
aside {
width: 30%;
justify-content: flex-end;
padding: 0.5rem;
}
.footer {
flex-shrink: 0; /* Prevent Chrome, Opera, and Safari from letting these items shrink to smaller than their content's default minimum size. */
padding: 20px;
}
#media (max-width: 600px) {
main {
flex-direction: column;
}
main > article, aside {
width: 100%;
}
}
* {
box-sizing: border-box;
}
body {
margin: 0;
}
footer {
background: #333333;
color: white;
margin: 0;
text-align: center;
}
<div class="content">
<header>
<h1>Header</h1>
</header>
<main>
<article>
<h3>Current Article</h3>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Odit vero quibusdam maxime magnam rerum nemo provident? Commodi, non! Ad facilis, doloribus voluptatum alias nostrum voluptatibus enim libero, distinctio nam sunt similique pariatur nesciunt accusantium eveniet perferendis ea doloremque molestiae culpa consequuntur quia aspernatur, itaque voluptate? Voluptatem magni delectus harum totam.</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Fuga rerum repudiandae error eveniet est explicabo, nihil eum. Inventore laboriosam consectetur dolor consequatur. Unde in doloribus repellendus dolorum perferendis officia hic?</p>
<p>Dicta molestias doloremque, corrupti dolorum ipsum ea perferendis neque a, animi magnam ab sint impedit repudiandae aspernatur vel natus cum suscipit vero nisi nihil blanditiis iste laborum. Eum, sunt quo!</p>
<ul>
<li>Lorem ipsum dolor sit.</li>
<li>Nisi doloremque ut deserunt?</li>
<li>Impedit aliquam itaque placeat.</li>
<li>Sit incidunt iure assumenda.</li>
<li>Inventore fuga optio perferendis!</li>
</ul>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Natus illum aut quia alias delectus labore, maiores, excepturi quae nisi a non consequuntur! Officia fugiat enim nostrum molestias ipsa! Deleniti, repudiandae!</p>
<p>Illo, reprehenderit? Ipsum velit aut, ducimus minima in accusamus aperiam ex cumque recusandae tenetur architecto nemo repellat asperiores eum. Corrupti blanditiis, odio sequi ea ducimus ipsam temporibus culpa asperiores dicta.</p>
<p>Maxime alias, natus veritatis quis mollitia itaque voluptate iure neque dolore, expedita eaque, in ea sunt quibusdam ut ducimus fugit doloribus! Corporis molestiae nobis quae nesciunt inventore alias sed error.</p>
<p>Id est repellendus pariatur harum, hic sequi vero ab mollitia corporis nisi, consequuntur eaque doloremque, suscipit nobis velit dolore totam exercitationem facere voluptas iure? Temporibus eius minus vero aut cumque!</p>
</article>
<aside>
<h4>In other news:</h4>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Placeat, culpa.</p>
<p>Molestiae, officiis non esse perspiciatis provident a doloribus dignissimos sint!</p>
<p>Inventore nihil illum maxime ipsa repudiandae quia omnis quae consequuntur!</p>
</aside>
</main>
</div>
<footer class="footer">
Company Name | All rights reserved ©2020
</footer>