Elements not scaling properly when I zoom in and out - html

I'm working on a freecodecamp project and I can't seem to get any of the content to look normal when I zoom in or view it on my phone.
The "BTS" title is supposed to be on the center of the image but the text moves around and the image doesn't fill up the page all the way whenever I zoom in. Same goes for the circular images on the bottom. I'm trying to create two rows: 4 images on the first and 3 on the second row.
I have no idea what went wrong with my code.
What I included was only the parts that were messing up. The entire page is here
#img-div {
position: relative;
max-width: 100%;
height: auto;
}
#title {
position: absolute;
width: 100%;
top: 30%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-family: "Bodoni Moda", serif;
font-size: 200px;
text-align: center;
}
#members {
width: 100%;
background: white;
display: flex;
flex-wrap: wrap;
}
#members2 {
width: 100%;
background: white;
display: flex;
flex-wrap: wrap;
}
.smaller-image {
width: 200px;
}
.border {
border-width: 0px;
border-radius: 50%;
<div class="container" id="bts-wsj">
<img id="img-div" src="https://i.imgur.com/Th9Y0WO.jpg" alt="BTS-WSJ" style="width: 100%;">
<h1 id="title">BTS</h1>
</div>
<div class="container" id="members">
<a href="#"><img class="smaller-image border" src="https://i.imgur.com/HuZWnjV.jpg" alt="jimin">
<p>Jimin</p>
<a href="#"><img class="smaller-image border" src="https://i.imgur.com/yk5C7kz.jpg" alt="jungkook">
<p>Jungkook</p>
<a href="#"><img class="smaller-image border" src="https://i.imgur.com/JBEGNJw.jpg" alt="jin">
<p>Jin</p>
<a href="#"><img class="smaller-image border" src="https://i.imgur.com/7SJwU5t.jpg" alt="rm">
<p>RM</p>
<div class="container" id="members2">
<a href="#"><img class="smaller-image border" src="https://i.imgur.com/pOFFDdi.jpg" alt="j-hope" id="hobi">
<p>J-Hope</p>
<a href="#"><img class="smaller-image border" src="https://i.imgur.com/tjMeZ9d.jpg" alt="v" id="v">
<p>V</p>
<a href="#"><img class="smaller-image border" src="https://i.imgur.com/MNB1YBS.jpg" alt="suga" id="suga">
<p>Suga</p>
</div>

In your Html code, complete div and a tag. in BTS title to set mobile view use media query CSS so when you show your site in mobile view set as proper. Use this code to set your circular images in a row.
body {
margin: 0;
}
#img-div {
position: relative;
max-width: 100%;
height: auto;
}
#bts-wsj {
position: relative;
}
#title {
position: absolute;
width: 100%;
top: 30%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-family: "Bodoni Moda", serif;
font-size: 200px;
text-align: center;
}
#members,
#members2 {
width: 100%;
background: white;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
text-align: center;
}
#members a,
#members2 a {
padding: 20px;
}
.smaller-image {
width: 200px;
}
.border {
border-width: 0px;
border-radius: 50%;
}
#media only screen and (max-width: 1024px) {
#title {
font-size: 150px;
}
}
#media only screen and (max-width: 768px) {
#title {
font-size: 100px;
}
}
#media only screen and (max-width: 480px) {
#title {
font-size: 50px;
}
}
<div class="container" id="bts-wsj">
<img id="img-div" src="https://i.imgur.com/Th9Y0WO.jpg" alt="BTS-WSJ" style="width: 100%;">
<h1 id="title">BTS</h1>
</div>
<div class="container" id="members">
<a href="#">
<img class="smaller-image border" src="https://i.imgur.com/HuZWnjV.jpg" alt="jimin">
<p>Jimin</p>
</a>
<a href="#">
<img class="smaller-image border" src="https://i.imgur.com/yk5C7kz.jpg" alt="jungkook">
<p>Jungkook</p>
</a>
<a href="#">
<img class="smaller-image border" src="https://i.imgur.com/JBEGNJw.jpg" alt="jin">
<p>Jin</p>
</a>
<a href="#">
<img class="smaller-image border" src="https://i.imgur.com/7SJwU5t.jpg" alt="rm">
<p>RM</p>
</a>
</div>
<div class="container" id="members2">
<a href="#">
<img class="smaller-image border" src="https://i.imgur.com/pOFFDdi.jpg" alt="j-hope" id="hobi">
<p>J-Hope</p>
</a>
<a href="#">
<img class="smaller-image border" src="https://i.imgur.com/tjMeZ9d.jpg" alt="v" id="v">
<p>V</p>
</a>
<a href="#">
<img class="smaller-image border" src="https://i.imgur.com/MNB1YBS.jpg" alt="suga" id="suga">
<p>Suga</p>
</a>
</div>

Related

3 links in sidebar moved to the right with dispaly flex and I don't know why

I am trying to create a sidebar for a website with 10 sidebar links. most of the links work with the css but 3 of these links moved to the right. all with a different margin. It is so strange. the problem comes with aside .sidebar a {..} when I used display flex in it 3 of the items in the sidebar moved. can anyone help?
* {
margin: 0;
padding: 0;
outline: 0;
appearance: none;
border: 0;
box-sizing: border-box;
}
body {
width: 100vw;
height: 100vh;
overflow-x: hidden;
}
.container {
display: grid;
width: 96%;
margin: 0 auto;
gap: 1.8rem;
grid-template-columns: 14rem auto 23rem;
}
aside {
height: 100vh;
}
aside .top {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 1.4rem;
}
aside .logo {
display: flex;
gap: 0.8rem;
}
aside .logo img {
width: 2rem;
height: 2rem;
}
aside .close {
display: none;
}
/* sidebar */
aside .sidebar {
display: flex;
flex-direction: column;
height: 86vh;
position: relative;
top: 3rem;
}
aside .sidebar a {
display: flex;
margin-left: 2rem;
gap: 1rem;
align-items: center;
position: relative;
height: 3.7rem;
}
aside .sidebar a:last-child {
position: absolute;
bottom: 2rem;
width: 100%;
}
<div class="container">
<aside>
<div class="top">
<div class="logo">
<img src="logo.png" alt="">
<h2>NA <span class ="danger">AM</span></h2>
</div>
<div class="close" id="close-btn">
<span class="matial-icons-sharp">close</span>
</div>
</div>
<div class="sidebar">
<a href="#" class ="active">
<span class="material-icons-sharp">grid_view</span>
<h3>Dashboard</h3>
</a>
<a href="#" >
<span class="material-icons-sharp">person outline</span>
<h3>Klanten</h3>
</a>
<a href="#">
<span class="material-icons-sharp">receipt long</span>
<h3>Bestellingen</h3>
</a>
<a href="#">
<span class="material-icons-sharp">insights</span>
<h3>Analytics</h3>
</a>
<a href="#">
<span class="material-icons-sharp">mail outline</span>
<h3>Berichten</h3>
<span class="message-count">99</span>
</a>
<a href="#">
<span class="material-icons-sharp">inventory</span>
<h3>Producten</h3>
</a>
<a href="#">
<span class="material-icons-sharp">report_gmailerrorred</span>
<h3>Klachten</h3>
</a>
<a href="#">
<span class="material-icons-sharp">settings</span>
<h3>Instellingen</h3>
</a>
<a href="#">
<span class="material-icons-sharp">add</span>
<h3>Product toevoegen</h3>
</a>
<a href="#">
<span class="material-icons-sharp">logout</span>
<h3>Uitloggen</h3>
</a>
</div>
</aside>
</div>
Your declaration for grid-template-columns did not leave enough room for the sidebar. Therefore there were overflow issues because of the grid specificity and especially cause there are no widths defined on any of the sidebar elements.
The grid before:
The grid after:
I also set your display: flex; directly on your a using aside>.sidebar>a. You did not include the child combinator > so it was setting those styles on all of those classes, not just the a. Lastly, you should have widths defined for your flex-items, or else the browser will assume their width based on content and you will end up with un-aligned content. I also cleaned up other aspects of the HTML and CSS. Please see the snippet below for those changes.
* {
margin: 0;
padding: 0;
outline: 0;
appearance: none;
border: 0;
box-sizing: border-box;
}
body {
width: 100vw;
height: 100vh;
overflow-x: hidden;
}
.container {
display: grid;
width: 96%;
margin: 0 auto;
gap: 1.8rem;
grid-template-columns: 23rem auto 23rem;
}
aside {
height: 100vh;
width: 100%;
}
aside .top {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 1.4rem;
}
aside .logo {
display: flex;
gap: 0.8rem;
}
aside .logo img {
width: 2rem;
height: 2rem;
}
aside .close {
display: none;
}
/* sidebar */
aside .sidebar {
display: flex;
flex-direction: column;
height: 100vh;
position: relative;
top: 3rem;
}
aside>.sidebar>a {
display: flex;
margin-left: 2rem;
gap: 1rem;
align-items: center;
position: relative;
height: 3.7rem;
}
span,
h3 {
width: 100%;
min-width: 120px;
white-space: nowrap;
}
<div class="container">
<aside>
<div class="top">
<div class="logo">
<img src="logo.png" alt="">
<h2>NA <span class="danger">AM</span></h2>
</div>
<div class="close" id="close-btn">
<span class="matial-icons-sharp">close</span>
</div>
</div>
<div class="sidebar">
<a href="#" class="active">
<span class="material-icons-sharp">grid_view</span>
<h3>Dashboard</h3>
</a>
<a href="#">
<span class="material-icons-sharp">person outline</span>
<h3>Klanten</h3>
</a>
<a href="#">
<span class="material-icons-sharp">receipt long</span>
<h3>Bestellingen</h3>
</a>
<a href="#">
<span class="material-icons-sharp">insights</span>
<h3>Analytics</h3>
</a>
<a href="#">
<span class="material-icons-sharp">mail outline</span>
<h3>Berichten<span class="message-count"> 99</span></h3>
</a>
<a href="#">
<span class="material-icons-sharp">inventory</span>
<h3>Producten</h3>
</a>
<a href="#">
<span class="material-icons-sharp">report_gmailerrorred</span>
<h3>Klachten</h3>
</a>
<a href="#">
<span class="material-icons-sharp">settings</span>
<h3>Instellingen</h3>
</a>
<a href="#">
<span class="material-icons-sharp">add</span>
<h3>Product toevoegen</h3>
</a>
<a href="#">
<span class="material-icons-sharp">logout</span>
<h3>Uitloggen</h3>
</a>
</div>
</aside>
</div>

How to resize an image to fit its container with CSS?

I am currently doing the Freecodecamp course, but I got a little stuck on one of the projects. This is the current state of my project: https://codepen.io/otapadar/full/JjRaoex (I am trying to copy this website: https://codepen.io/freeCodeCamp/full/zNBOYG). The second section (My Projects) has images within a grid. I am trying to resize the images, such that each image covers about 80-90% of the parent element, just like the site I am trying to copy.
When you look at my website, you see that the images are not resizing. I have tried fixing this by using the following property on my images: object-fit: cover. This doesn't fix it, sadly.
Any help on fixing this would be greatly appreciated. Thanks in advance!
HTML:
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
<nav id="navbar">
<ul>
<li><a class="nav-link" href="#welcome-section">About</a></li>
<li><a class="nav-link" href="#projects">Work</a></li>
<li><a class="nav-link" href="#contact">Contact</a></li>
</ul>
</nav>
<main>
<section id="welcome-section">
<h1>Hey, I am Brad</h1>
<p>Web Developer</p>
</section>
<section id="projects">
<h2 class="projects-header">My Projects</h2>
<container class="project-grid">
<a class="project-tile" target="_blank">
<img class="project-image" src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/tribute.jpg">
<p class="project-title">Tribute Page</p>
</a>
<a class="project-tile" target="_blank">
<img class="project-image" src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/random-quote-machine.png">
<p class="project-title">Random Quote Machine</p>
</a>
<a class="project-tile" target="_blank">
<img class="project-image" src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/calc.png">
<p class="project-title">JavaScript Calculator</p>
</a>
<a class="project-tile" target="_blank">
<img class="project-image" src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/map.jpg">
<p class="project-title">Map Data</p>
</a>
<a class="project-tile" target="_blank">
<img class="project-image" src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/wiki.png">
<p class="project-title">Wikipedia Viewer</p>
</a>
<a class="project-tile" target="_blank">
<img class="project-image" src="https://raw.githubusercontent.com/freeCodeCamp/cdn/master/build/testable-projects-fcc/images/tic-tac-toe.png">
<p class="project-title">Tic Tac Toe</p>
</a>
</container>
<a class="button" href="https://codepen.io/otapadar" target="_blank">Show All</a>
</section>
<section id="contact">
<h1>Let's Work Together</h1>
<p>How do you take your coffee?</p>
<container class="social-icons">
<a class="profile-link" target="_blank"></a>
<a class="profile-link" target="_blank"></a>
<a class="profile-link" target="_blank"></a>
<a class="profile-link" target="_blank"></a>
<a class="profile-link" target="_blank"></a>
</container>
</section>
</main>
CSS
#import url('https://fonts.googleapis.com/css2?family=Raleway&display=swap');
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body {
font-family: 'Raleway';
scroll-behavior: smooth;
}
#navbar {
position: fixed;
display: flex;
justify-content: flex-end;
top: 0;
left: 0;
right: 0;
width: 100%;
background-color: #be3144;
}
#navbar ul {
display: flex;
list-style: none;
margin-right: 2rem;
}
a {
text-decoration: none;
color: #f0f0f0;
}
.nav-link {
display: block;
padding: 1.5rem;
font-size: 1.3rem;
font-weight: bold;
}
#welcome-section {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #000;
background-image: linear-gradient(62deg, #3a3d40 0%, #181719 100%)
}
#welcome-section > h1 {
font-size: 4rem;
color: #f0f0f0;
font-weight: 700;
margin-bottom: 1.5rem;
}
#welcome-section > p {
color: #be3144;
font-size: 2rem;
}
#projects {
background-color: #45567d;
padding: 6rem 2rem;
text-align: center;
}
.projects-header {
font-size: 3rem;
color: #f0f0f0;
margin: 0 auto 2rem auto;
}
.project-grid {
display: grid;
width: 100%;
grid-gap: 1rem;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
margin-bottom: 4rem;
}
.project-tile {
background-color: #303841;
}
.project-image {
height: calc(100%-6rem);
width: 100%;
object-fit: cover;
}
.project-title {
font-size: 1.5rem;
padding: 1.5rem 0.5rem;
font-weight: bold;
}
.button {
padding: 0.5rem 1rem;
font-size: 1.5rem;
background-color: #303841;
}
The problem in your css is this line height: calc(100%-6rem); just add spaces around the operator to be height: calc(100% - 6rem);
you should take white space after and befor minis like that
height:calc(100% - 6rem)
add max-width:100%; to project-image class in css and also you can set a custom width or height in img element
project-image{
height: 300px;
width: 600px;
max-width:100%;
object-fit: cover;
}

Bootstrap 4 bottom fixed but top relative

I using backend language php (laravel) and front end html + css;
I make reaction box. Bottom have image for reaction. Top the upper part increases according to the ratio.
I want like this;
https://i.hizliresim.com/YdbYqz.png
But actual;
https://i.hizliresim.com/JV20ao.png
My codes;
https://jsfiddle.net/63yusufsari63/wfh5zexm/
.reaction-box {
text-align: center;
padding: 10px;
}
.reaction-box a {
text-decoration: none;
font-weight: bold;
color: #fc5bb6;
}
.reaction-box a:hover {
opacity: 0.6;
}
.reaction-in-box {
float: left;
width: auto;
}
.reaction-range {
margin: 1px 4px;
background-color: #fc5bb6;
}
.reaction-description {
background-color: #f4f6f6;
padding: 5px;
}
.reaction-description img {
display: block;
width: 50px !important;
height: 50px !important;
margin: 0 auto 5px auto;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha256-YLGeXaapI0/5IgZopewRJcFXomhRMlYYjugPLSyNjTY=" crossorigin="anonymous" />
<a href="#" title="name" class="reaction-in-box text-center">
<span>Rate</span>
<div class="reaction-range" style="height: 50px; bottom: 0;"></div>
<div class="reaction-description">
<img src="https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" class="img-fluid" alt="Name">
Name
</div>
</a>
<a href="#" title="name" class="reaction-in-box text-center">
<span>Rate</span>
<div class="reaction-range" style="height: 20px; bottom: 0;"></div>
<div class="reaction-description">
<img src="https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" class="img-fluid" alt="Name">
Name
</div>
</a>
<a href="#" title="name" class="reaction-in-box text-center">
<span>Rate</span>
<div class="reaction-range" style="height: 40px; bottom: 0;"></div>
<div class="reaction-description">
<img src="https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" class="img-fluid" alt="Name">
Name
</div>
</a>

How to increase Image Height while maintaining image aspect ratio

I would like to increase the height of my images to 400px. However the images don't fill the div while maintaining the aspect ratio.
I previously added height:100% to my images while adding a fixed height of 400px to my parent div, then adding object-fit: cover to the images. However, on page resize, the images do not maintain their ratio and instead squash / collapse.
Any help would be great. Thank you.
#test {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#test h2 {
font-family: 'Poppins';
text-transform: uppercase;
font-weight: 600;
font-size: 1.3em;
color: #333;
margin-bottom: 20px;
}
#picwrapper {
width: 85%;
}
#media only screen and (max-width: 986px) {
#picwrapper {
flex-direction: column;
}
}
#picwrapper {
display: flex;
flex-wrap: wrap;
}
.third {
width: 33.3333333333%;
position: relative;
}
#media only screen and (max-width: 986px) {
.third {
width: 100%;
}
}
.third img {
max-width: 100%;
height: auto;
display: block;
padding-top: 10%;
/* 4:3 Aspect Ratio */
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background: linear-gradient(rgba(25, 25, 25, 0.9), rgba(25, 25, 25, 0.9));
}
.overlay-text {
font-family: 'Poppins';
font-weight: 500;
}
.third:hover .overlay {
opacity: 1;
}
.overlay-text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
<section id="test">
<div id="picwrapper">
<div class="third">
<img src="https://cdn.zmescience.com/wp-
content/uploads/2018/11/Magnificent_CME_Erupts_on_the_Sun_-_August_31.jpg">
<a href="AUDI/audi.html">
<div class="overlay">
<h1 class="overlay-text">Parkash Sandhu</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://solarsystem.nasa.gov/system/news_items/main_images/853_ph3_waxing_gibbous_2k.jpg">
<a href="#">
<div class="overlay">
<h1 class="overlay-text">Flo Music</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://cdn.zmescience.com/wp-content/uploads/2018/11/Magnificent_CME_Erupts_on_the_Sun_-_August_31.jpg">
<a href="#">
<div class="overlay">
<h1 class="overlay-text">British Athletics</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://solarsystem.nasa.gov/system/news_items/main_images/853_ph3_waxing_gibbous_2k.jpg">
<a href="AUDI/audi.html">
<div class="overlay">
<h1 class="overlay-text">Audi</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://cdn.zmescience.com/wp-
content/uploads/2018/11/Magnificent_CME_Erupts_on_the_Sun_-
_August_31.jpg">
<a href="Virgin Atlantic">
<div class="overlay">
<h1 class="overlay-text">Virgin Atlantic</h1>
</div>
</a>
</div>
</div>
</section>
In what follows, I'm making some assumptions about what you're after.
I'm assuming that you want the images to maintain their aspect ratio (4:3) at all times, but still scale larger and smaller proportionally as the screen grows/shrinks.
Below, you'll find a different implementation of your code, but one that I think captures what you're going for. At least, maybe it'll get you going in the right direction.
(BTW, Credit to Andy Bell for this aspect ratio technique. See here: https://andy-bell.design/wrote/creating-an-aspect-ratio-css-utility/)
[class*="aspect-ratio-"] {
display: block;
position: relative;
width: 100%;
}
[class*="aspect-ratio-"] > * {
display: block;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.aspect-ratio-tv {
padding-top: 75%; /* 4:3 */
}
.gallery {
display: flex;
flex-wrap: wrap;
list-style: none;
padding: 0;
margin: 0;
}
.gallery {
width: 100%;
}
.gallery li {
flex-basis: 100%;
}
#media screen and (min-width: 580px) {
.gallery li {
flex-basis: 50%;
}
}
#media screen and (min-width: 960px) {
.gallery li {
flex-basis: 33.33333%;
}
}
.gallery img {
object-fit: cover;
}
.overlay {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: 0.5s ease;
background: linear-gradient(rgba(25, 25, 25, 0.9), rgba(25, 25, 25, 0.9));
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
}
.overlay-text {
color: white;
font-size: 20px;
text-decoration: none;
}
.overlay:hover {
opacity: 1;
text-decoration: none;
}
<ul class="gallery">
<li>
<div class="aspect-ratio-tv">
<img src="https://source.unsplash.com/phvbkGThElM/800x600" alt="A neon ferris wheel" loading="lazy" />
<a href="#0" class="overlay">
<h1 class="overlay-text">
TEST HEADING
</h1>
</a>
</div>
</li>
<li>
<div class="aspect-ratio-tv">
<img src="https://source.unsplash.com/H_mTtLykvKs/800x682" alt="A dimly lit drum kit" loading="lazy" />
<a href="#0" class="overlay">
<h1 class="overlay-text">
TEST HEADING
</h1>
</a>
</div>
</li>
<li>
<div class="aspect-ratio-tv">
<img src="https://source.unsplash.com/Hc42xXu_WOg/800x567" alt="Blueberries, close up" loading="lazy" />
<a href="#0" class="overlay">
<h1 class="overlay-text">
TEST HEADING
</h1>
</a>
</div>
</li>
<li>
<div class="aspect-ratio-tv">
<img src="https://source.unsplash.com/MfynxC5_tiU/800x999" alt="High angle waterfall" loading="lazy" />
<a href="#0" class="overlay">
<h1 class="overlay-text">
TEST HEADING
</h1>
</a>
</div>
</li>
<li>
<div class="aspect-ratio-tv">
<img src="https://source.unsplash.com/7ZTx1iA7a7Q/800x397" alt="Sunset coastal scence" loading="lazy" />
<a href="#0" class="overlay">
<h1 class="overlay-text">
TEST HEADING
</h1>
</a>
</div>
</li>
<li>
<div class="aspect-ratio-tv">
<img src="https://source.unsplash.com/pRvy1j4aINE/800x785" alt="High angle shot of a recording studio" loading="lazy" />
<a href="#0" class="overlay">
<h1 class="overlay-text">
TEST HEADING
</h1>
</a>
</div>
</li>
</ul>
See here for a pen: https://codepen.io/anon/pen/oOeBOj
Dont specify a width, just height.
.moon
{
height: 100%;
}
Specifying a width and height will squash the images; just specify the height.
img {
height: 50%; /*Change this to what you want.*/
}
#test {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#test h2 {
font-family: 'Poppins';
text-transform: uppercase;
font-weight: 600;
font-size: 1.3em;
color: #333;
margin-bottom: 20px;
}
#media only screen and (max-width: 986px) {
#picwrapper {
flex-direction: column;
}
}
#picwrapper {
display: flex;
flex-wrap: wrap;
}
.third {
width: 33.3333333333%;
position: relative;
}
#media only screen and (max-width: 986px) {
.third {
width: 100%;
}
}
.third img {
height: auto;
display: block;
padding-top: 10%;
/* 4:3 Aspect Ratio */
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background: linear-gradient(rgba(25, 25, 25, 0.9), rgba(25, 25, 25, 0.9));
}
.overlay-text {
font-family: 'Poppins';
font-weight: 500;
}
.third:hover .overlay {
opacity: 1;
}
.overlay-text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
<section id="test">
<div id="picwrapper">
<div class="third">
<img src="https://cdn.zmescience.com/wp-
content/uploads/2018/11/Magnificent_CME_Erupts_on_the_Sun_-_August_31.jpg">
<a href="AUDI/audi.html">
<div class="overlay">
<h1 class="overlay-text">Parkash Sandhu</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://solarsystem.nasa.gov/system/news_items/main_images/853_ph3_waxing_gibbous_2k.jpg">
<a href="#">
<div class="overlay">
<h1 class="overlay-text">Flo Music</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://cdn.zmescience.com/wp-content/uploads/2018/11/Magnificent_CME_Erupts_on_the_Sun_-_August_31.jpg">
<a href="#">
<div class="overlay">
<h1 class="overlay-text">British Athletics</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://solarsystem.nasa.gov/system/news_items/main_images/853_ph3_waxing_gibbous_2k.jpg">
<a href="AUDI/audi.html">
<div class="overlay">
<h1 class="overlay-text">Audi</h1>
</div>
</a>
</div>
<div class="third">
<img src="https://cdn.zmescience.com/wp-
content/uploads/2018/11/Magnificent_CME_Erupts_on_the_Sun_-
_August_31.jpg">
<a href="Virgin Atlantic">
<div class="overlay">
<h1 class="overlay-text">Virgin Atlantic</h1>
</div>
</a>
</div>
</div>
</section>

Two of my four links on my contact div does not work

On my contact gif I have used the social media symbols as a link to my social media sites, however, the Twitter and the GitHub link is not working and I cannot figure out why. The Facebook and the CodePen link does work. Also is there a better way correctly line and organize the Here is the links so that they can stay more consistent? site if you want to take a look for yourself misaelalopez.com. Thank you for your help!
#contact
{
background-image: url(https://lh3.googleusercontent.com/-2wI0PCtgivjkGQruaV-_2JYgbuD-yNFkRLN_DGAPXHxFq5gac-lnc5IheHflI6V_Z9AtgJjyfF-LBGa4tt_W6XB2Xs26xEyAH46S7kJlgiyHeIbi-ZM62zJuHcjJuZNnhO9lMGt6jw);
height: 250px;
padding: 300px;
margin: 0 auto;
background-size: cover;
}
#contact h1
{
color: white;
position: relative;
text-align: center;
}
#contact h2
{
color: white;
position: relative;
text-align: center;
}
.facebook
{
position: relative;
float: left;
}
.twitter
{
position: relative;
left: 50px;
float: left;
}
.instagram
{
position: relative;
left: 100px;
float: left;
}
.gitHub
{
position: relative;
left: 150px;
float: left;
}
.codePen
{
position: relative;
left: 200px;
}
<div id="contact">
<div class="Content">
<div class="facebook">
<a target="_blank" href="https://facebook.com/misael.a.lopez"><img src="http://www.freeiconspng.com/uploads/facebook-transparent-12.png"></a>
</div>
<div class="twitter">
<a target="_blank" href="https://twitter.com/cables25"><img src="https://s3.amazonaws.com/piktochartv2-dev/v2/uploads/a8f46883-78d7-4dfc-b0b3-be090e70e2b3/27c835d6dd2cbb4b696abd3e7ac9c0370bbedefe_original.png"></a>
</div>
<div class="instagram">
<a target= "_blank" href= "https://www.instagram.com/misael2590/?hl=en"><img src= "http://bbcpersian7.com/images/instagram-clipart-png-transparent-background-3.jpg" alt="Instagram"></a>
</div>
<div class="gitHub">
<a target= "_blank" href="https://github.com/Misael2590"><img src="https://cdn4.iconfinder.com/data/icons/iconsimple-logotypes/512/github-256.png" alt="GitHub"></a>
</div>
<div class="codePen">
<a target= "_blank" href="https://codepen.io/misael25900/"><img src= "http://blog.codepen.io/wp-content/uploads/2012/06/Button-Fill-Black-Large.png" alt="CodePen"></a>
</div>
<br>
<h1>Reach out to me!</h1>
<h2>Email me at Misael25900#gmail.com</h2>
</div>
</div>
Try this..
#contact
{
background-image: url(https://lh3.googleusercontent.com/-2wI0PCtgivjkGQruaV-_2JYgbuD-yNFkRLN_DGAPXHxFq5gac-lnc5IheHflI6V_Z9AtgJjyfF-LBGa4tt_W6XB2Xs26xEyAH46S7kJlgiyHeIbi-ZM62zJuHcjJuZNnhO9lMGt6jw);
height: 250px;
padding: 300px;
margin: 0 auto;
background-size: cover;
}
#contact h1
{
color: white;
position: relative;
text-align: center;
}
#contact h2
{
color: white;
position: relative;
text-align: center;
}
.facebook
{
position: relative;
float: left;
}
.twitter
{
position: relative;
left: 50px;
float: left;
}
.instagram
{
position: relative;
left: 100px;
float: left;
}
.gitHub
{
position: relative;
left: 150px;
float: left;
}
.codePen
{
position: relative;
left: 200px;
float: left;
}
<div id="contact">
<div class="Content">
<div class="facebook">
<a target="_blank" href="https://facebook.com/misael.a.lopez"><img src="http://www.freeiconspng.com/uploads/facebook-transparent-12.png" width="20px" height="20px"></a>
</div>
<div class="twitter">
<a target="_blank" href="https://twitter.com/cables25"><img src="https://s3.amazonaws.com/piktochartv2-dev/v2/uploads/a8f46883-78d7-4dfc-b0b3-be090e70e2b3/27c835d6dd2cbb4b696abd3e7ac9c0370bbedefe_original.png" width="20px" height="20px"></a>
</div>
<div class="instagram">
<a target= "_blank" href= "https://www.instagram.com/misael2590/?hl=en"><img src= "http://bbcpersian7.com/images/instagram-clipart-png-transparent-background-3.jpg" alt="Instagram" width="20px" height="20px"></a>
</div>
<div class="gitHub">
<a target= "_blank" href="https://github.com/Misael2590"><img src="https://cdn4.iconfinder.com/data/icons/iconsimple-logotypes/512/github-256.png" alt="GitHub" width="20px" height="20px"></a>
</div>
<div class="codePen">
<a target= "_blank" href="https://codepen.io/misael25900/"><img src= "http://blog.codepen.io/wp-content/uploads/2012/06/Button-Fill-Black-Large.png" alt="CodePen" width="20px" height="20px"></a>
</div>
<br>
<h1>Reach out to me!</h1>
<h2>Email me at Misael25900#gmail.com</h2>
</div>
</div>
The links ' don't work ' because you arrange the divs in a wrong way. They overlap each other. So the codepen div is overlapping the twitter,instagram,github links. Because it's positioned on top of them > you set left:200px which moves the codepen div 200px from left but because it doesn't have floaT:left like the others, it has by default width:100% , where 100% is the width of the entire #contact .content
If you set float:left to the divs, this is not the way to arrange them. You need to set them a width. Having 5 divs, that's 100%/5 = 20% . And because you want some margins between them ( spaces ) , you can use calc() as shown below.
Also that padding:300px on #contact is a very bad idea. I don't know what you were trying to achieve with that. Anyway, i changed that also
( Changed a bit your html also because using float gets the elements out of their default float in the document )
All CSS styles are at the top of the code, in HTML i added a .footer-content div wrapping around the footer text
#contact .Content {
float:left;
width:100%;
}
#contact .Content > div {
float: left;
width: calc(20% - 15px);
margin: 0 7.5px;
}
.footer-content {
float: left;
width: 100%;
}
img {
max-width: 100%
}
#contact {
background-image: url(https://lh3.googleusercontent.com/-2wI0PCtgivjkGQruaV-_2JYgbuD-yNFkRLN_DGAPXHxFq5gac-lnc5IheHflI6V_Z9AtgJjyfF-LBGa4tt_W6XB2Xs26xEyAH46S7kJlgiyHeIbi-ZM62zJuHcjJuZNnhO9lMGt6jw);
height: 250px;
padding:300px 30px;
width:100%;
margin: 0 auto;
background-size: cover;
}
#contact h1 {
color: white;
position: relative;
text-align: center;
}
#contact h2 {
color: white;
position: relative;
text-align: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<div id="contact">
<div class="Content">
<div class="facebook">
<a target="_blank" href="https://facebook.com/misael.a.lopez"><img src="http://www.freeiconspng.com/uploads/facebook-transparent-12.png"></a>
</div>
<div class="twitter">
<a target="_blank" href="https://twitter.com/cables25"><img src="https://s3.amazonaws.com/piktochartv2-dev/v2/uploads/a8f46883-78d7-4dfc-b0b3-be090e70e2b3/27c835d6dd2cbb4b696abd3e7ac9c0370bbedefe_original.png"></a>
</div>
<div class="instagram">
<a target="_blank" href="https://www.instagram.com/misael2590/?hl=en"><img src="http://bbcpersian7.com/images/instagram-clipart-png-transparent-background-3.jpg" alt="Instagram"></a>
</div>
<div class="gitHub">
<a target="_blank" href="https://github.com/Misael2590"><img src="https://cdn4.iconfinder.com/data/icons/iconsimple-logotypes/512/github-256.png" alt="GitHub"></a>
</div>
<div class="codePen">
<a target="_blank" href="https://codepen.io/misael25900/"><img src="http://blog.codepen.io/wp-content/uploads/2012/06/Button-Fill-Black-Large.png" alt="CodePen"></a>
</div>
</div>
<div class="footer-content">
<h1>Reach out to me!</h1>
<h2>Email me at Misael25900#gmail.com</h2>
</div>
</div>