Left border for text should have same height as text - html

I'm trying to make the parent div's left border the exact same height as the text inside the div.
Here's the problem:
My code is simple:
#box {
width: 500px;
padding-left: 2rem;
border-color: #01B288;
border-style: solid;
border-width: 0 0 0 3px;
}
h1 {
font-size: 80px;
font-family: Arial;
line-height: 1.2;
margin: 0;
padding: 0;
}
p {
font-size: 20px;
font-family: Arial;
line-height: 1.2;
margin: 0;
padding: 0;
}
<div id="box">
<h1>BIGGER FONT EXAMPLE</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit ullanec fermentum enim.</p>
</div>
I found a solution that only works for one block of text, but I have 2 blocks inside the same div.

Use ::before CSS selector.
See the snippet below.
#box {
position: relative;
width: 500px;
height: auto;
padding-left: 2rem;
}
h1 {
font-size: 80px;
font-family: Arial;
line-height: 1.2;
margin: 0;
padding: 0;
}
p {
font-size: 20px;
font-family: Arial;
line-height: 1.2;
margin: 0;
padding: 0;
}
#box::before {
content: "";
width: 3px;
height: 95%;
background-color: #01B288;
left: 0;
bottom: 0;
position: absolute;
display: block;
}
<div id="box">
<h1>BIGGER FONT EXAMPLE</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit ullanec fermentum enim.</p>
</div>
EDIT 1
Use #media query and set different height for mobile. It's currently set to 50% if the viewport is smaller than 576px (50% is obviously too much, so you can see the effect).
See the snippet below.
#box {
position: relative;
width: 500px;
height: auto;
padding-left: 2rem;
overflow: hidden;
}
h1 {
font-size: 80px;
font-family: Arial;
line-height: 1.2;
margin: 0;
padding: 0;
}
p {
font-size: 20px;
font-family: Arial;
line-height: 1.2;
margin: 0;
padding: 0;
}
#box::before {
content: "";
width: 3px;
height: 95%;
background-color: #01B288;
left: 0;
bottom: 0;
position: absolute;
display: block;
}
#media screen and (max-width: 576px) {
#box::before {
height: 50%;
}
}
<div id="box">
<h1>BIGGER FONT EXAMPLE</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit ullanec fermentum enim.</p>
</div>
EDIT 2
What about if you remove line-height only from the first line?
See the snippet below.
#box {
position: relative;
width: 500px;
height: auto;
padding-left: 2rem;
overflow: hidden;
}
h1 {
font-size: 80px;
font-family: Arial;
line-height: 1.2;
margin: 0;
padding: 0;
}
p {
font-size: 20px;
font-family: Arial;
line-height: 1.2;
margin: 0;
padding: 0;
}
#box::before {
content: "";
width: 3px;
height: 100%;
background-color: #01B288;
left: 0;
bottom: 0;
position: absolute;
display: block;
}
h1:first-line {
line-height: 0.8;
}
<div id="box">
<h1>BIGGER FONT EXAMPLE</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit ullanec fermentum enim.</p>
</div>

So have a look at the code below. If you remove the margins and set the line-height to the same height (1em for example) for all the elements in the div that its concerning then you can recreate the line like below.
It might be minimal but if your going to use a different font and it's a bit off just play with the calc(1em / ..). If your going to change te line-height you might try to fiddle with calc(..em / 8).
body{ font-family: Arial, sans-serif; }
h1{ font-size: 80px; }
p{ font-size: 20px; }
div > *{
position: relative;
line-height: 1em;
margin-top: 0;
margin-bottom: 0;
}
div > *::before {
position: absolute;
content: '';
border-left: 3px solid DarkSeaGreen;
height: 100%;
left: -5px;
}
div > *:first-child::before{ top: calc(1em / 8); }
div > *:last-child::before { bottom: calc(1em / 8); }
<div>
<h1>BIGGER FONT EXAMPLE</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod.</p>
</div>

Using :Before selector with height:93% of its parent and eyeballing it from top:5.5%
#box {
width: 500px;
padding-left: 2rem;
position:relative;
}
#box:before{
content:"";
position:absolute;
height:93%;
top:7%;
left:0;
border-color: #01B288;
border-style: solid;
border-width: 0 0 0 3px;
}
h1 {
font-size: 80px;
font-family: Arial;
line-height: 1.2;
margin:0;
padding:0;
}
p {
font-size: 20px;
font-family: Arial;
line-height: 1.2;
margin:0;
padding:0;
}
<div id="box">
<h1>BIGGER FONT EXAMPLE</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit ullanec fermentum enim.</p>
</div>

Related

Footer not in the correct place

Somehow, my HTML and CSS won't work properly. My main doubt is in the span. Because it's all working on any other pages.
The footer is not detecting any object, so it is staying at the most top of the page. (I've also tried putting the footer on the <footer> tag and it still shows the same result.)
The situation is illustrated in the picture that is attached.
Here is my code snippet:
.aboutuspagetitle {
width: 100%;
color: rgba(159,74,74,1);
position: absolute;
top: 176px;
left: 660px;
font-family: Merriweather Sans;
font-weight: Bold;
font-size: 40px;
opacity: 1;
}
.aboutuspagedesc {
width: 100%;
color: rgba(0,0,0,1);
position: absolute;
top: 313px;
left: 30px;
font-family: Merriweather Sans;
font-weight: normal;
font-size: 33px;
opacity: 1;
text-align: left;
}
.footer {
clear: both;
position: absolute;
height: 75px;
background-color: #121212;
font-family: Karla Tamil Upright;
color: white;
text-align: center;
left: 0px;
width: 300%;
}
.foot1{
width: 304px;
color: rgba(255,255,255,1);
position: absolute;
top: 0px;
left: 568px;
font-family: Karla Tamil Upright;
font-weight: normal;
font-size: 18px;
opacity: 1;
text-align: center;
}
.foot2{
width: 304px;
color: rgba(255,255,255,1);
position: absolute;
top: 45px;
left: 568px;
font-size: 14px;
opacity: 1;
text-align: center;
}
<body>
<span class="aboutuspagetitle">ABOUT US</span>
<span class="aboutuspagedesc">
<p>Lorem ipsum dolor sit amet.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut commodo nisl ut justo tincidunt, ac laoreet nunc elementum.</p>
</span>
<div class="footer">
<p class="foot1">THIS IS AN ADDRESS</p>
<span class="foot2">© 2021</span>
</div>
</body>
You just forgot to add bottom: 0; to the footer style. And position it using position: fixed; so it will stay at the bottom even when you scroll.
.aboutuspagetitle {
color: rgba(159,74,74,1);
font-family: Merriweather Sans;
font-weight: Bold;
font-size: 40px;
text-align: center;
}
.aboutuspagedesc {
width: 100%;
color: rgba(0,0,0,1);
font-family: Merriweather Sans;
font-weight: normal;
font-size: 33px;
text-align: left;
padding-bottom: 75px;
}
.footer {
display: flex;
position: fixed;
height: 75px;
background-color: #121212;
font-family: Karla Tamil Upright;
font-weight: normal;
color: white;
text-align: center;
left: 0px;
bottom:0;
width: 100%;
align-items: center;
justify-content: center;
flex-direction: column;
}
.foot1{
color: rgba(255,255,255,1);
font-size: 18px;
margin: 0;
}
.foot2{
color: rgba(255,255,255,1);
font-size: 14px;
}
<body>
<h1 class="aboutuspagetitle">ABOUT US</h1>
<span class="aboutuspagedesc">
<p>Lorem ipsum dolor sit amet.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut commodo nisl ut justo tincidunt, ac laoreet nunc elementum.</p>
</span>
<footer class="footer">
<p class="foot1">THIS IS AN ADDRESS</p>
<span class="foot2">© 2021</span>
</footer>
</body>
Here are some advices.
First, as said in the comments, don't use position absolute on everything !! As the moment you'll try a different screen size, everything will be offest.
Second, try not to add too many style that won't do anything at all at the end. If you try something and it doesn't work, remove it from the style !

Why are my heading elements overlapping on small screens?

I am new to frontend dev. When I reduce the browser window size the layout breaks. Elements overlap each other and height of section changes etc.
Here is my HTML code in which I have made a navbar and a section in which I created 3 items.
#import url('https://fonts.googleapis.com/css2?family=Dancing+Script&family=Lobster&display=swap');
#import url('https://fonts.googleapis.com/css2?family=Dancing+Script&family=Lobster&family=Varela+Round&display=swap');
* {
margin: 0;
padding: 0;
}
ul li {
list-style-type: none;
text-decoration: none;
}
#navbar {
display: flex;
align-items: center;
position: relative;
top: 0;
/* justify-content: center; */
}
#navbar::before {
content: "";
background-color: black;
position: absolute;
height: 100%;
width: 100%;
z-index: -1;
opacity: 0.4;
}
/* Logo */
#logo {
margin: 10px 34px;
}
/* Logo and Image */
#logo img {
margin: 3px 6px;
height: 56px;
}
#navbar ul {
display: flex;
font-size: 1.3rem;
}
#navbar ul li a {
text-decoration: none;
display: block;
padding: 3px 23px;
border-radius: 20px;
color: white;
}
#navbar ul li a:hover {
background-color: white;
color: black;
}
/* Home section */
#home {
display: flex;
flex-direction: column;
padding: 3px 200px;
height: 278px;
justify-content: center;
align-items: center;
font-family: 'Lobster', cursive;
}
#home::before {
content: "";
background: url('../bg1.jpg') no-repeat center center/cover;
position: absolute;
height: 56%;
width: 100%;
z-index: -1;
opacity: 0.89;
top: 0px;
left: 0px;
}
#home h1 {
color: white;
text-align: center;
}
#home p {
color: white;
text-align: center;
font-size: 1.5rem;
}
.h-primary {
font-size: 3.8rem;
padding: 12px;
font-family: 'Varela Round', sans-serif;
}
.h-secondary {
font-size: 2.2rem;
padding: 12px;
font-family: 'Varela Round', sans-serif;
}
.h-tertiary {
font-size: 0.9rem;
padding: 12px;
font-family: 'Varela Round', sans-serif;
}
#services {
margin: 110px 0;
margin-left: 20px;
margin-right: 20px;
display: flex;
}
#services .box {
border: 2px solid brown;
padding: 20px;
margin: 3px 6px;
border-radius: 20px;
background-color: rgb(236, 229, 229);
}
#services .box img {
display: block;
height: 171px;
margin: auto;
}
.btn {
padding: 6px 20px;
border: 2px solid white;
background-color: brown;
color: white;
margin: 17px;
font-size: 1.5rem;
border-radius: 10px;
cursor: pointer;
}
.center {
text-align: center;
}
<nav id="navbar">
<div id="logo">
<img src="logo.png" alt="">
</div>
<ul>
<li class="items">Home</li>
<li class="items">Service</li>
<li class="items">About</li>
<li class="items">Contact</li>
</ul>
</nav>
<section id="home">
<h1 class="h-primary">Welcome to Myonline meal</h1>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Voluptatem aperiam quaerat cumque consequatur quasi
</p>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Debitis consequatur </p>
<button class="btn">Order Now</button>
</section>
<section class="services-container">
<h1 class="h-primary center">Our Service</h1>
<div id="services">
<div class="box">
<img src="img/1.png" alt="">
<h2 class="h-secondary center">Food Ordering</h2>
<p class="center h-tertiary">Lorem ipsum dolor sit amet consectetur adipisicing elit. Laudantium quia atque, corrupti</p>
</div>
<div class="box">
<img src="img/2.png" alt="">
<h2 class="h-secondary center">Food Ordering</h2>
<p class="center h-tertiary">Lorem ipsum dolor sit amet consectetur adipisicing elit. Laudantium quia atque, corruptir</p>
</div>
<div class="box">
<img src="img/3.png" alt="">
<h2 class="h-secondary center">Food Ordering</h2>
<p class="center h-tertiary">Lorem ipsum dolor sit amet consectetur adipisicing elit. Laudantium quia atque, corruptir</p>
</div>
</div>
</section>
You should learn about responsiveness, when you make a website, it usually looks different on different screen sizes and devices, and in order to make it look better on smaller screens, you need to style your page differently according to the device's size, for example using media queries.
In your case you mostly use px unit to set sizes for margins, paddings and such in your css, but there are better units that are described as relative, such as %, em and rem.
You can learn more about all this just googling or watching tutorials, but in short, percentage unit is relative to the parent's size, em is relative to this element's font-size, and rem is relative to the root font-size (html tag) which is usually 16px, so for example if you set a font-size on a div of 3rem, that would mean 3 * 16px, which is 48px, but the difference between saying 3rem and just 48px, is that in some cases 3rem might become smaller or larger depending on the device or any other factor.
div {
display: flex;
flex-direction: column;
align-items: start;
margin: 1em 0;
}
.small button {
font-size: 16px;
}
.big button {
font-size: 48px;
}
.non-relative {
padding: 8px 16px;
}
.relative {
padding: 0.5em 1em;
}
<div class="small">
<button class="non-relative">Non-Relative</button>
<button class="relative">Relative</button>
</div>
<div class="big">
<button class="non-relative">Non-Relative</button>
<button class="relative">Relative</button>
</div>
Here you can see that, when I set the button's padding with px, it stays the same no matter the font size, but with the em unit, it will be relative to it, so proportionally it will be the same as the smaller version. Hope this is a good enough example, I am kind of sleepy and might've missed something, but hope this helps you!

Unable to put a png image on the border edge of a container

Not sure why I am unable to butt the .png image to the border of the container. I have tried everything. Padding, margin, position, and the image does not move down. I even tried moving the image out of the container but that would add too much extra work and script. I am hoping someone can help me here. I was unable to load the code. It's a document with HTML and CSS. The image is a class within a div. Any help would be wonderful. I am unable to load the image as well.
file:///Users/suzannehunter/Desktop/web%20development/CSS-My%20Site/index.html
Give your parent div position relative and the child position absolute. Then you specify on with side the image is going to overlap the border. if the left side use left: -5px(the negative value of the border thickness), or right: for the right side.
<div style="background:red;border:5px solid black;position: relative;height: 200px;width: 100px;">
<div style="background: blue;height: 50px;width: 50px;position: absolute;right: -5px;"></div>
</div>
Thank you so much for your response, I tried changing the position's like you stated. The Parent was already (top container) was already relative. When I changed the child (img of boxer) absolute it stays fixed and doesn't float with the rest of the children within the Parent. Do I add Float? Placement is another matter. I will try once again to include the code. Wouldn't let me add the code and the image last time. How do you add the code or won't they allow it?[
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>AnimalKrate</title>
<link rel="stylesheet" href="css/styles.css">
<link rel="icon" href="favicon.ico">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Fredoka+One&family=Open+Sans+Condensed:wght#300&family=Raleway&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=EB+Garamond&display=swap" rel="stylesheet">
</head>
<body>
<div class="top-container">
<img class="top-bone" src="images/bone.png" alt="bone-img">
<h1>AnimalKrate</h1>
<h2><span class="pet">PET</span> source for everything</h2>
<img class="bottom-bone" src="images/bone.png" alt="bone">
<img class="boxer" src="images/boxer.png" alt="boxer-img">
</div>
<div class="middle-container">
<div class="profile">
<img src="images/pawprint.png" alt="pawprint" style = "padding-top:25px">
<h2 style="margin-bottom:5px;">Woof</h2>
<p class="intro">We are your source for everything a pet lover loves. Buying and selling only the most sought after specialty items.</p>
</div>
<hr>
<div class="skills">
<h2>Pet Toys</h2>
<div class="skill-row" style="margin-top: 30px;">
<img class="dog-ball" src="images/dog-ball.png" alt="dog-ball">
<h3>Lorem & Ipsum</h3>
<p>Lorem ipsum dolor sit amet, quis in duis, iaculis id felis. Consectetuer vestibulum, nunc urna lectus, erat ligula. Hendrerit nam, lectus ante, ut lorem eros.</p>
</div>
<div class="skill-row" style= "margin-bottom: 50px;">
<img class="dog-toy" src="images/dog-toy.png" alt="dog-toy">
<h3>Lorem Ipsum Dolor</h3>
<p>Lorem ipsum dolor sit amet, mauris sed consectetuer. Etiam et eu, bibendum interdum, lacus quis mauris. Curabitur wisi, quisque vel eu, rutrum nam.</p>
</div>
</div>
<hr>
</div>
<div class="bottom-container">
<div class="contact-me">
<h2 style = "padding-top: 25px;">Get In Touch</h2>
<h3>Lorem ipsum dolor sit amet, non elit.</h3>
<p class="contact-message">Lorem ipsum dolor sit amet, in quis, aenean amet. Phasellus sodales, tellus donec dui, ornare erat.</p>
<a class="myButton">Contact Me</a>
</div>
<a class="footer-link" href="https://www.chewy.com/">Chewy</a>
<a class="footer-link" href="https://www.krisers.com/">Krisers</a>
<a class="footer-link" href="https://www.petsmart.com/">Petsmart</a>
<p class="copyright">© 2018 Hunter.</p>
</div>
</div>
</body>
</html>
]1
body{
color: #405143;
margin: 0;
text-align: center;
font-family: Garamond, serif;
font-size: 18px;
}
h1{
color: #5b5b5b;
font-size: 60px;
margin: 50px auto 0 auto;
font-family:'Fredoka One', cursive;
}
h2 {
color: #5b5b5b;
font-family: 'EB Garamond', serif;
font-size: 2rem;
font-weight: normal;
margin-top: 25px;
}
h3 {
color:#794646;
font-family: 'open sans condensed';
font-weight:bolder;
}
a{
color: #794646;
font-family: 'EB Garamond', serif;
margin: 5px 5px;
text-decoration: none;
}
a:hover{
color: #5b5b5b;
}
p {
line-height: 1.5;
}
.top-container {
background-color: #d8c292;
position:relative;
padding-top: 20px;
}
.middle-container{
}
.bottom-container{
background-color: #c19065;
position: relative;
padding-bottom: 25px;
}
.pet {
text-decoration: underline;
}
.bottom-bone{
position: absolute;
left: 150px;
bottom: 300px;
}
.top-bone{
position: absolute;
right: 200px;
top: 150px;
}
.contact-message {
width: 40%;
margin: 20px auto 30px;
}
.copyright{
font-size: 1rem;
padding:20px 0px;
}
.skill-row{
width: 50%;
margin: 100px auto 100px auto;
text-align: left;
}
.intro {
width:30%;
margin: auto;
}
.pawprint {
width: 25%;
}
.dog-ball {
width: 35%;
float: left;
margin-right: 30px;
}
.dog-toy {
width: 35%;
float: right;
margin-left: 30px;
}
hr{
margin-top:40px;
margin-bottom: 40px;
border-style: none;
border-top-style: dotted;
border-color: grey;
border-width:5px;
width: 5%;
}
.style {
margin-top:30px;
}
.boxer{
}
.myButton {
margin-bottom: 20px;
box-shadow: 0px 1px 0px 0px;
background-color:#eae0c2;
border-radius:6px;
border:1px solid #333029;
display:inline-block;
cursor:pointer;
color:#505739;
font-family: 'Arial';
font-size:14px;
font-weight:bold;
padding:9px 10px;
text-decoration:none;
text-shadow:0px 1px 0px #ffffff;
}
.myButton:hover {
background-color:#ccc2a6;
}
.myButton:active {
position:relative;
top:1px;
}
body{
color: #405143;
margin: 0;
text-align: center;
font-family: Garamond, serif;
font-size: 18px;
}
h1{
color: #5b5b5b;
font-size: 60px;
margin: 50px auto 0 auto;
font-family:'Fredoka One', cursive;
}
h2 {
color: #5b5b5b;
font-family: 'EB Garamond', serif;
font-size: 2rem;
font-weight: normal;
margin-top: 25px;
}
h3 {
color:#794646;
font-family: 'open sans condensed';
font-weight:bolder;
}
a{
color: #794646;
font-family: 'EB Garamond', serif;
margin: 5px 5px;
text-decoration: none;
}
a:hover{
color: #5b5b5b;
}
p {
line-height: 1.5;
}
.top-container {
background-color: #d8c292;
position:relative;
padding-top: 20px;
}
.middle-container{
}
.bottom-container{
background-color: #c19065;
position: relative;
padding-bottom: 25px;
}
.pet {
text-decoration: underline;
}
.bottom-bone{
position: absolute;
left: 150px;
bottom: 300px;
}
.top-bone{
position: absolute;
right: 200px;
top: 150px;
}
.contact-message {
width: 40%;
margin: 20px auto 30px;
}
.copyright{
font-size: 1rem;
padding:20px 0px;
}
.skill-row{
width: 50%;
margin: 100px auto 100px auto;
text-align: left;
}
.intro {
width:30%;
margin: auto;
}
.pawprint {
width: 25%;
}
.dog-ball {
width: 35%;
float: left;
margin-right: 30px;
}
.dog-toy {
width: 35%;
float: right;
margin-left: 30px;
}
hr{
margin-top:40px;
margin-bottom: 40px;
border-style: none;
border-top-style: dotted;
border-color: grey;
border-width:5px;
width: 5%;
}
.style {
margin-top:30px;
}
.boxer{
}
.myButton {
margin-bottom: 20px;
box-shadow: 0px 1px 0px 0px;
background-color:#eae0c2;
border-radius:6px;
border:1px solid #333029;
display:inline-block;
cursor:pointer;
color:#505739;
font-family: 'Arial';
font-size:14px;
font-weight:bold;
padding:9px 10px;
text-decoration:none;
text-shadow:0px 1px 0px #ffffff;
}
.myButton:hover {
background-color:#ccc2a6;
}
.myButton:active {
position:relative;
top:1px;
}

Why is my div image not appearing inside parent div?

I am making an author box. I want the person's picture at the right of the box while still inside the parent div. Whatever styles I apply, I can't make the picture appear inside the div and on the right smoothly, what is wrong here?
.authorBox {
background: #222222;
width: 100%;
padding:1.5em 2em;
position: relative;
border-left:15px solid #d53362;
box-sizing: border-box;
}
h5.author {
color: #fff;
font-weight: 600;
font-size: 1.5em;
}
h5.authorRole {
color: #d53362;
font-weight: 600;
font-size: 1.3em;
}
p.authorQuote {
color:#444;
font-style: italic;
margin-top: 20px;
font-size: 1.1em;
line-height: 1.5em;
}
.personImg1 {
width:100%;
height:100%;
background-size: cover;
background-image: url(../img/person1.jpeg);
}
.personContainer {
float:right;
}
<div class="authorBox">
<h5 class="author">First Last</h5>
<h5 class="authorRole">Job role goes here</h5>
<p class="authorQuote">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut eu erat at nisl laoreet ultrices"</p>
<div class="personContainer">
<div class="personImg1"></div>
</div>
</div>
First of all a div with no height and width won't be seen, so you div with the background has to have a defined width/height so you can see it.
and you put in the right by positioning it absolute and right:0 or a small amount just to push it from the edge.
*,
*:after,
*:before {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.authorBox {
background: #222222;
width: 100%;
padding: 1.5em 2em;
position: relative;
border-left: 15px solid #d53362;
box-sizing: border-box;
}
h5.author {
color: #fff;
font-weight: 600;
font-size: 1.5em;
}
h5.authorRole {
color: #d53362;
font-weight: 600;
font-size: 1.3em;
}
p.authorQuote {
color: #444;
font-style: italic;
margin-top: 20px;
font-size: 1.1em;
line-height: 1.5em;
}
.personContainer {
height: 100px;
width: 300px;
position: absolute;
right: 10px;
top: 1.5em;
}
.personImg1 {
width: 100%;
height: 100%;
background-size: 100% 100%;
background-image: url('http://via.placeholder.com/350x150');
}
<div class="authorBox">
<h5 class="author">First Last</h5>
<h5 class="authorRole">Job role goes here</h5>
<p class="authorQuote">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut eu erat at nisl laoreet ultrices"
</p>
<div class="personContainer">
<div class="personImg1"></div>
</div>
</div>
Your .personImg1 has width:100%; and height:100%;, which means it gets the full width and height of its parent container - i.e. relative settings.
But the parent container's only CSS property is .personContainer { float:right; } – there are no width or height settings for it, resulting in zero height both for this container, the .personImg1 DIV and therefore also the background-image of .personImg1. So you need to assign some width and height to .personContainer
Actually you might want to consider to just use a regular img tag instead of that .personImg1 DIV and its background-image...
Are you locating your image properly from your folders?
Also, you can try this
.personImg1 {
display:block;
position:absolute;
background:url("../img/person1.jpeg");
background-size: 100% 100%;
background-repeat:no-repeat;
width:100%;
height:100%;
float:right;
bottom:0;
right:0;
}
Try this solution using flex box.
.authorBox {
background: #222222;
width: 100%;
padding: 1.5em 2em;
position: relative;
border-left: 15px solid #d53362;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
h5.author {
color: #fff;
font-weight: 600;
font-size: 1.5em;
}
h5.authorRole {
color: #d53362;
font-weight: 600;
font-size: 1.3em;
}
p.authorQuote {
color: #444;
font-style: italic;
margin-top: 20px;
font-size: 1.1em;
line-height: 1.5em;
}
.personImg1 {
width: 100px;
height: 100px;
background-size: cover;
background-image: url(../img/person1.jpeg);
}
<div class="authorBox">
<div class="colContainer">
<h5 class="author">First Last</h5>
<h5 class="authorRole">Job role goes here</h5>
<p class="authorQuote">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut eu erat
at nisl laoreet ultrices"</p>
</div>
<div class="personContainer">
<div class="personImg1"></div>
</div>
</div>

Responsive layout, overflow, x-scroll showing

everyone.
I'm having a problem with responsive layout. On big screen everything looks fine, the problems emerge when I resize the browser. My navigation doesn't stretch in full width, even though Its width is 100%.
html for nav:
<header>
<div class="navigation">
<h3>lorem<span class="bold">ipsum</span></h3>
<div class="logo">
<h3>your<span class="red">logo</span></h3>
</div>
<div class="nav">
<ul>
<li class="active close">Home</li>
<li class="subMenuToggle">About us</li>
<li>Our work</li>
<li>Our process</li>
<li>Our people</li>
<li>Social</li>
<li>Get in touch</li>
<li><span>Hire</span></li>
<li><span>Careers</span></li>
</ul>
</div>
</div>
<div class="subMenu">
<div class="subNav">
<ul>
<li class="active2">WHAT WE DO</li>
<li>PEOPLE</li>
<li>SERVICES</li>
<li>CONTACT</li>
<li>VALUES</li>
</ul>
</div>
</div>
And, SCSS:
.navigation {
width: 100%;
height: 70px;
background: white;
.nav {
float: right;
margin-top: 10px;
box-sizing: border-box;
ul {
margin: 32 0;
li {
display: inline-block;
margin-right: 30px;
text-transform: uppercase;
font-size: 14px;
font-weight: bold;
height: 38px;
font-family: 'Open Sans', sans-serif;
transition: all 200ms ease-in;
span {
color: gray;
}
a {
color: inherit;
display: inline-block;
height: 40px;
text-decoration: none;
}
&:active {
border-bottom: 4px solid rgb(185, 151, 106);
color: rgb(185, 151, 106);
}
}
.active {
border-bottom: 4px solid rgb(185, 151, 106);
color: rgb(185, 151, 106);
}
}
}
Also, images are doing the opposite, they go beyond to view port, so you need to scroll in order to see full width. Since all images are done the same way, he's a one example:
HTML:
<div class="container">
<div class="section1">
<img src="Assets/img/Header/Header.PNG" alt="header1">
<div class="contentBox1">
<p class="kicker2">Sed ut Perspiciatis</p>
<h2>Nemo Enim</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque lobortis feugiat risus nec scelerisque. Sed sagittis magna quis sodales convallis. In convallis nec lacus sed fermentum. Integer ultrices felis ac quam commodo, a viverra enim condimentum. Praesent gravida magna in aliquet luctus.</p>
<button type="button" class="cta1">AT VERO EROS</button>
</div>
<div class="contentBox2">
<h2>QUIS AUTEM VEL<br> EUM DOLOR</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque lobortis feugiat risus nec scelerisque. Sed sagittis magna quis sodales convallis.</p>
</div>
<div class="ImageBox1">
<img src="Assets/img/Header/img1.PNG" alt="img1">
</div>
</div>
</div>
and CSS:
.container {
margin: 0 auto 395px;
width: 1210px;
#include clearfix;
.section1 {
width: 1210px;
position: relative;
img {
width: 100%;
height: 480px;
z-index: -1;
}
.contentBox1 {
position: absolute;
width: 450px;
height: 543px;
background: white;
bottom: -270px;
left: 65px;
z-index: 1;
p.kicker2 {
margin: 80px 0 0 90px;
text-transform: uppercase;
color: $ThemeColor;
font-size: 14px;
font-family: 'Open Sans', sans-serif;
}
h2 {
margin: 18px 0 32px 90px;
text-transform: uppercase;
font-size: 45px;
font-family: 'Droid Serif', serif;
}
p {
margin: 0 50px 0 90px;
font-size: 20px;
font-family: 'Open Sans', sans-serif;
color: grey;
}
.cta1 {
background: white;
color: black;
font-size: 14px;
font-weight: bold;
justify-content: center;
width: 235px;
height: 60px;
border: 2px solid black;
margin: 37px 0 0 90px;
font-family: 'Open Sans', sans-serif;
&:hover {
cursor: pointer;
background: rgb(233, 233, 233);
}
&:active {
position: relative;
top: 1px;
}
}
}
.contentBox2 {
position: absolute;
width: 270px;
height: 274px;
background: rgb(40, 40, 40);
bottom: -270px;
left: 515px;
z-index: 1;
h2 {
color: $ThemeColor;
margin: 40px 0 18px 37px;
font-size: 20px;
font-family: 'Open Sans', sans-serif;
}
p {
color: rgb(153, 153, 153);
margin: 0 56px 0 37px;
font-size: 17px;
font-family: 'Open Sans', sans-serif;
}
}
.ImageBox1 {
img {
position: absolute;
width: 180px;
height: 182px;
bottom: -270px;
left: 965px;
z-index: 6;
}
}
}
It really drives me crazy. Also, why when I make a media query, for example, for (max-width: 700px), it starts to effect page much sooner, like around 1000px? It's like it's not in sync. This whole responsive layout gives me a headache...
Sorry for a long post...
P.S.
If you wanna see whole code, here's a gitHub reppo: https://github.com/Vukasin90/test
#media screen and (max-width: 770px) {
body {
min-width: 770px; }
body .navigation {
width: 100vh; /* <----- here*/
height: 70px;
background: white;
}
I think this might be an issue. Your navigation width has value in viewheight instead of viewwidth is that intentional?