Displaying an inline block - html

I'm building a site and I've encountered a problem that an inline block doesn't work for me, I'm trying to add an inline block to the <section id="section-three"> section, but it doesn't work, I tried to add it to specific divs, but it also doesn't work, how can I fix it? I don't need to use flex, I need to use the inline block. I would like it to be like this https://prnt.sc/V14eLuOjtX2k
* {
margin: 0;
padding: 0;
}
body {
margin: 0;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
font-size: 17px;
color: #926239;
line-height: 1.6;
}
#header {
background-image: url("http://traversymedia.com/downloads/assets/beachshowcase.jpg");
background-size: cover;
background-position: center;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 0 20px;
}
h1 {
font-size: 50px;
line-height: 1.2;
}
#text {
margin: 5px;
font-size: 20px;
}
.button {
font-size: 18px;
text-decoration: none;
color: #926239;
border: #926239 1px solid;
padding: 10px 20px;
border-radius: 10px;
margin-top: 20px;
}
.button:hover {
background-color: #926239;
color: white;
}
#section-three {
display: inline-block;
}
.block {
background: #926239;
color: white;
padding: 20px;
}
#block-two {
padding: 20px;
}
#block-three {
background: #926239;
color: #fff;
padding: 20px;
}
<header id="header">
<h1>Welcome To The Beach</h1>
<p id="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi officiis ipsum officia numquam expedita ullam.
</p>
Read More
</header>
<section id="section-three">
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
<div id="block-two">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
</section>

You are applying display:inline-block to the container/parent (#section-three), but you should apply it to its children instead (and add a width setting!). Replace your #section-three {...} rule with
#section-three > * {
display: inline-block;
width: 32.66%;
box-sizing: border-box;
}
BTW: Still, using display:flex would be better since finding an appropriate width setting for the inline-blocks is difficult here.
* {
margin: 0;
padding: 0;
}
body {
margin: 0;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
font-size: 17px;
color: #926239;
line-height: 1.6;
}
#header {
background-image: url("http://traversymedia.com/downloads/assets/beachshowcase.jpg");
background-size: cover;
background-position: center;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 0 20px;
}
h1 {
font-size: 50px;
line-height: 1.2;
}
#text {
margin: 5px;
font-size: 20px;
}
.button {
font-size: 18px;
text-decoration: none;
color: #926239;
border: #926239 1px solid;
padding: 10px 20px;
border-radius: 10px;
margin-top: 20px;
}
.button:hover {
background-color: #926239;
color: white;
}
#section-three > * {
display: inline-block;
width: 32.66%;
box-sizing: border-box;
}
.block {
background: #926239;
color: white;
padding: 20px;
}
#block-two {
padding: 20px;
}
#block-three {
background: #926239;
color: #fff;
padding: 20px;
}
<header id="header">
<h1>Welcome To The Beach</h1>
<p id="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi officiis ipsum officia numquam expedita ullam.
</p>
Read More
</header>
<section id="section-three">
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
<div id="block-two">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
</section>

You should definitely just use flexbox. Browser support is wide. Inline block solution is also included below if you really want to use that.
* {
margin: 0;
padding: 0;
}
body {
margin: 0;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
font-size: 17px;
color: #926239;
line-height: 1.6;
}
#header {
background-image: url("http://traversymedia.com/downloads/assets/beachshowcase.jpg");
background-size: cover;
background-position: center;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 0 20px;
}
h1 {
font-size: 50px;
line-height: 1.2;
}
#text {
margin: 5px;
font-size: 20px;
}
.button {
font-size: 18px;
text-decoration: none;
color: #926239;
border: #926239 1px solid;
padding: 10px 20px;
border-radius: 10px;
margin-top: 20px;
}
.button:hover {
background-color: #926239;
color: white;
}
#section-three {
display: flex;
}
.block {
background: #926239;
color: white;
padding: 20px;
}
#block-two {
padding: 20px;
}
#block-three {
background: #926239;
color: #fff;
padding: 20px;
}
<header id="header">
<h1>Welcome To The Beach</h1>
<p id="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi officiis ipsum officia numquam expedita ullam.
</p>
Read More
</header>
<section id="section-three">
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
<div id="block-two">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
</section>
If you really want to use inline block for some reason you need to remove the whitespace from your HTML, add a width to your child divs and set them to box-sizing: border-box to work more easily with the padding you have added to them.
* {
margin: 0;
padding: 0;
}
body {
margin: 0;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
font-size: 17px;
color: #926239;
line-height: 1.6;
}
#header {
background-image: url("http://traversymedia.com/downloads/assets/beachshowcase.jpg");
background-size: cover;
background-position: center;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 0 20px;
}
h1 {
font-size: 50px;
line-height: 1.2;
}
#text {
margin: 5px;
font-size: 20px;
}
.button {
font-size: 18px;
text-decoration: none;
color: #926239;
border: #926239 1px solid;
padding: 10px 20px;
border-radius: 10px;
margin-top: 20px;
}
.button:hover {
background-color: #926239;
color: white;
}
#section-three > div{
display: inline-block;
width: 33.333%;
box-sizing: border-box;
}
.block {
background: #926239;
color: white;
padding: 20px;
}
#block-two {
padding: 20px;
}
#block-three {
background: #926239;
color: #fff;
padding: 20px;
}
<header id="header">
<h1>Welcome To The Beach</h1>
<p id="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi officiis ipsum officia numquam expedita ullam.
</p>
Read More
</header>
<section id="section-three">
<div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div><div id="block-two">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div><div class="block">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa dolorum est, molestias dolores quis sunt nobis temporibus veritatis libero odio!</div>
</section>

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.

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.

How can I style a pseudo-element as the title of a paragraph?

We are using Markdown (Kramdown) to generate a static website. For infoboxes, we can annotade paragraphs and get the following results:
{:.note .icon-check title="This is a title"}
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
And this is the converted HTML:
<p class="note icon-check" title="This is a title">
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
</p>
The style is (SCSS):
p.note {
&::before {
float: right;
}
position: relative;
&[title]::after {
content: attr(title);
position: relative;
top: 0;
left: 0;
}
}
.icon::before {
content: "#";
}
As we are using Icomoon icon fonts, where the content is set in :before, the title must be in :after.
we won't change the Iconfont, so the icon must stay in :before
no additional distracting markup in the markdown, so no HTML wrapper
no Javascript
It is possible to set an absolute positioning to the title, but this would be too narrow to the paragraph-text itself, as no margin can be set.
Here is a JSFiddle
Now, how does one style a box with :after as a title on top, that also looks good when no title is set?
main {
width: 50%;
display: block;
place-items: center;
margin: auto;
}
p.note {
border: 3px solid red;
border-radius: 3px;
padding: 1em;
position: relative;
}
p.note::before {
margin: auto 0 0.5em 0.5em;
float: right;
}
p.note[title]::after {
content: attr(title);
position: relative;
font-weight: bold;
top: 0;
left: 1em;
}
.icon::before {
font-size: 2em;
content: "#";
}
<html>
<body>
<main>
<p class="note icon" title="This is a title">
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolorem quidem non placeat quibusdam velit, dicta adipisci saepe magnam fuga debitis qui, minima, eius error laboriosam distinctio eos natus et!
</p>
</main>
</body>
</html>
What it looks like:
How it should look like:
A crazy idea using shape-outside. The trick is to use the before for the title where you apply float and after for the icon having position:absolute then the shape-outside will create a particular shape in order to simulate the float behaviour around the icon.
main {
width: 50%;
display: block;
margin: auto;
text-align:justify;
}
p.note {
border: 3px solid red;
border-radius: 3px;
padding: 1em;
position: relative;
}
p.note::after {
margin: auto 0 0.5em 0.5em;
position:absolute;
top: 1em;
right: 0.5em;
}
p.note[title]::before {
content: attr(title);
display:block;
height:3.5em;
float:right;
width:100%;
text-align:center;
font-weight: bold;
shape-outside:polygon(0 0,100% 0,100% 100%,calc(100% - 3em) 100%,calc(100% - 3em) calc(100% - 2em),0 calc(100% - 2em));
/* To illustrate the shape */
background:
linear-gradient(rgba(255,255,0,0.3) 0 0) top/100% calc(100% - 2em) no-repeat,
linear-gradient(rgba(255,255,0,0.3) 0 0) bottom right/3em 3em no-repeat;
border:1px solid rgba(0,0,0,0.2);
/**/
}
.icon::after {
font-size: 2em;
content: "#";
}
.icon:not([title])::after {
display:none;
}
.icon:not([title])::before {
font-size: 2em;
content: "#";
margin: auto 0 0.5em 0.5em;
float:right;
}
<main>
<p class="note icon" title="This is a title">
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolorem quidem non placeat quibusdam velit, dicta adipisci saepe magnam fuga debitis qui, minima, eius error laboriosam distinctio eos natus et!
</p>
</main>
<main>
<p class="note icon" >
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolorem quidem non placeat quibusdam velit, dicta adipisci saepe magnam fuga debitis qui, minima, eius error laboriosam distinctio eos natus et!
</p>
</main>
Or a basic idea like below:
main {
width: 50%;
display: block;
margin: auto;
text-align:justify;
}
p.note {
border: 3px solid red;
border-radius: 3px;
padding: 1em;
position: relative;
}
p.note::before {
margin: auto 0 0.5em 0.5em;
float: right;
}
p.note[title]::after {
content: attr(title);
position: absolute;
font-weight: bold;
top: 0.5em;
left: 0;
right:2em;
text-align:center;
}
p.note[title] {
padding-top:2em;
}
.icon::before {
font-size: 2em;
content: "#";
}
<main>
<p class="note icon" title="This is a title">
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolorem quidem non placeat quibusdam velit, dicta adipisci saepe magnam fuga debitis qui, minima, eius error laboriosam distinctio eos natus et!
</p>
</main>
<main>
<p class="note icon" >
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolorem quidem non placeat quibusdam velit, dicta adipisci saepe magnam fuga debitis qui, minima, eius error laboriosam distinctio eos natus et!
</p>
</main>
since grid doesn't help enough, let's go back in time with display :table and display:table-caption to add another answer and see if that could work too for you ;)
* {
box-sizing: border-box;
}
main {
width: 50%;
min-width:450px;
display: block;
place-items: center;
margin: auto;
}
p.note {
font-size:clamp(12px, 4vw, 30px);
border: 3px solid red;
border-radius: 3px;
padding: 1em;
display: table;
padding-top: 1.5em;
}
p.note::before {
margin: auto 0 0.5em 0.5em;
float: right;
font-weight:bold;
color:tomato;
}
p.note[title]::after {
content: attr(title);
font-weight: bold;
display: table-caption;
margin-bottom: -1.6em;
text-align: center;
padding-right: 3em;
}
.icon::before {
font-size: 2em;
content: "#";
line-height: 0.25;
}
<main>
<p class="note icon" title="This is a title">
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolorem quidem non placeat quibusdam velit, dicta adipisci saepe magnam fuga debitis qui, minima, eius error laboriosam distinctio eos natus et!
</p>
</main>

How to force a div to bottom of a wrapper div and set background color

I have a wrapper div that contains two other divs, a left-column div and a right-column div. Currently the left column has a fixed min-height of 421px. The problem becomes visible once content stretches out of the right column, effectively making the wrapper div larger than the initially specified height of 421px. Here is a Fiddle
I want the left column to have a min-height of 421px and stretch all the way to the bottom of the wrapper div and set a background color to it, even if it has no content in it. How can I do that?
.wrapper{
overflow: scroll;
background: white;
font-family: "Roboto";
font-size: 14px;
line-height: 1.5;
width: 298px;
display: block;
margin: 0;
margin-left: 20px;
margin-bottom: 0.5cm;
box-shadow: 0 0 0.5cm rgba(0, 0, 0, 0.35);
-webkit-font-smoothing: antialiased;
}
.left-column {
float: left;
width: 30%;
min-height: 421px;
background-color: #144071;
color: white;
}
.right-column {
float: right;
width: 70%;
height: 100%;
color: black;
}
<div class="wrapper">
<div class="left-column"> content content </div>
<div class="right-column"> Lorem ipsum dolor sit, amet consectetur adipisicing elit. Modi officiis iste culpa, pariatur vel dolores aspernatur quo sint fugit. Eveniet. Lorem ipsum dolor sit, amet consectetur adipisicing elit. Modi officiis iste culpa, pariatur vel dolores aspernatur quo sint fugit. Eveniet. Lorem ipsum dolor sit, amet consectetur adipisicing elit. Modi officiis iste culpa, pariatur vel dolores aspernatur
<div style="margin-top: 20px;">
<strong>Because the height of the right column is set to 100% and the left column to a fixed height of 421px, once content stretches out of the fixed height, the left column loses it's background color. How can I make it so that the left bkg color is stretched to the end, but has a minimal fixed height of 421px?</strong>
</div>
</div>
</div>
Use flexbox...
.wrapper {
background: white;
font-family: "Roboto";
font-size: 14px;
line-height: 1.5;
width: 298px;
display: flex;
margin: 0;
margin-left: 20px;
margin-bottom: 0.5cm;
box-shadow: 0 0 0.5cm rgba(0, 0, 0, 0.35);
-webkit-font-smoothing: antialiased;
}
.left-column {
width: 30%;
min-height: 421px;
background-color: #144071;
color: white;
}
.right-column {
width: 70%;
color: black;
}
<div class="wrapper">
<div class="left-column"> content content </div>
<div class="right-column"> Lorem ipsum dolor sit, amet consectetur adipisicing elit. Modi officiis iste culpa, pariatur vel dolores aspernatur quo sint fugit. Eveniet. Lorem ipsum dolor sit, amet consectetur adipisicing elit. Modi officiis iste culpa, pariatur vel dolores aspernatur
quo sint fugit. Eveniet. Lorem ipsum dolor sit, amet consectetur adipisicing elit. Modi officiis iste culpa, pariatur vel dolores aspernatur
<div style="margin-top: 20px;">
<strong>Because the height of the right column is set to 100% and the left column to a fixed height of 421px, once content stretches out of the fixed height, the left column loses it's background color. How can I make it so that the left bkg color is stretched to the end, but has a minimal fixed height of 421px?</strong>
</div>
</div>
</div>
change your css like this:
https://codepen.io/shahry4r/pen/PowZOre
.wrapper{
background: white;
font-family: "Roboto";
font-size: 14px;
line-height: 1.5;
width: 298px;
margin: 0;
margin-left: 20px;
margin-bottom: 0.5cm;
box-shadow: 0 0 0.5cm rgba(0, 0, 0, 0.35);
-webkit-font-smoothing: antialiased;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
height: auto;
}
.left-column {
float: left;
width: 30%;
min-height: 421px;
background-color: #144071;
color: white;
}
.right-column {
float: right;
width: 70%;
height: auto;
color: black;
}
First, change the height of left column to padding-bottom. Second, change dynamic this padding-bottom for the height off the right column. Like this:
$(document).ready(function() {
var rightHeight = $('right-column').offsetHeight;
$('.left-column').css(padding - bottom: rightHeight);
})

When I resize browsers window, my div gets down to bottom and a big space comes in top

When I resize browsers window, my div gets down to bottom and a big space comes in top. I want that my div should remain in center of page even if resize the size of window lesser than size of div. In my school they haven't teach about this but I want to align this div in center of page
<!DOCTYPE html>
<html>
<head>
<title>CSS centering Done Right.</title>
<style>
* {
margin: 0;
padding: 0;
}
html, body, .m {
height: 100%;
width: 100%;
}
.m {
opacity:1;
font-size: 0;
overflow: auto;
text-align: center;
/*styling>>*/
background-color: #8F1C10;
}
.m::before {
content:'';
display: inline-block;
height: 100%;
vertical-align: middle;
}
.m>div {
display: inline-block;
font-size: 19px;
margin: 20px;
max-width: 320px;
min-height: 20px;
min-width: 300px;
padding: 14px;
vertical-align: middle;
/*styling*/
color:white;
background-color: #140A08;
outline:none;
}
</style>
</head>
<body>
<title>CSS centering Done Right.</title>
<div class="m">
<div contenteditable="true">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corporis, enim, possimus, voluptates, quia voluptatibus voluptas eum quaerat iure aperiam asperiores debitis fuga itaque quibusdam a ad odio assumenda iusto voluptatem.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quidem, ex quia consequatur quae quasi amet veniam est quas error quos perferendis ducimus non similique in soluta magnam dolore molestias veritatis.Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate, doloremque iste magni in eveniet ipsa odio mollitia eligendi magnam placeat aliquam hic reprehenderit reiciendis itaque assumenda ratione delectus. Alias, quis.</div>
</div>
</body>
</html>
margin: auto; is what you need. Try this:
<style>
* {
margin: 0;
padding: 0;
}
/*html, body, .m {
height: 100%;
width: 100%;
}*/
.m {
opacity:1;
font-size: 0;
overflow: auto;
text-align: center;
margin: auto;
/*styling>>*/
background-color: #8F1C10;
}
.m::before {
content:'';
display: inline-block;
height: 100%;
vertical-align: middle;
}
.m>div {
display: inline-block;
font-size: 19px;
margin: 20px;
max-width: 320px;
min-height: 20px;
min-width: 300px;
padding: 14px;
vertical-align: middle;
/*styling*/
color:white;
background-color: #140A08;
outline:none;
}
</style>