No matter what I do (for a few hours now) I cannot align <div class="kafelek"> next to each other; the code currently looks like this:
body {
background-color: #003C3D;
}
.header {
text-align: center;
align-content: center;
padding: 20px;
font-family: 'Open Sans';
font-size: 24px;
color: #C3CECB;
}
#headerlogo {
width: 400px;
height: auto;
object-fit: cover;
position: absolute;
top: 20px;
left: 50%;
transform: translateX(-50%);
animation: slide-in 1s ease-in-out forwards;
}
#keyframes slide-in {
from {
top: -100px;
}
to {
top: 20px;
}
}
.pre1 {
width: 50%;
text-align: center;
align-content: center;
font-family: 'Open Sans';
font-size: 24px;
color: #C3CECB;
float: left;
}
.pre2 {
width: 50%;
text-align: center;
align-content: center;
font-family: 'Open Sans';
font-size: 24px;
color: #C3CECB;
float: right;
}
.alignkafel1,
.alignkafel2 {
display: flex;
flex-wrap: wrap;
}
.row {
display: flex;
}
.kolumna {
display: inline-block;
width: 48%;
font-family: 'Open Sans';
color: #C3CECB;
text-align: center;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.kolumna:first-child {
margin-right: 0px;
}
.kolumna:last-child {
margin-left: 0px;
}
.row:after {
content: "";
display: table;
clear: both;
}
#media screen and (max-width: 800px) {
.kolumna {
width: 100%;
align-content: center;
}
}
kolumna2 {
display: inline-block;
width: 48%;
font-family: 'Open Sans';
color: #C3CECB;
text-align: center;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.kolumna2:first-child {
margin-right: 0px;
}
.kolumna2:last-child {
margin-left: 0px;
}
#media screen and (max-width: 800px) {
.kolumna2 {
width: 100%;
align-content: center;
}
}
.kafelek {
background-color: #006D57;
border-radius: 10px;
text-align: center;
height: 100px;
font-family: 'Open Sans';
font-size: 20px;
color: #C3CECB;
margin: 5px;
margin-top: 50px;
margin-right: 50px;
margin-bottom: 1px;
margin-left: 30px;
display: flex;
align-items: center;
justify-content: center;
}
#media screen and (max-width: 800px) {
.kafelek {
display: flex;
justify-content: center;
}
}
.kafelek:hover {
border: 2px solid #7EDF00;
transition: 0.3s;
cursor: pointer;
}
<div class="header">
<img src="" img id="headerlogo" />
<br /> <br /> Centrum zgłoszeniowe AOK
</div>
<div class="pre1"> Delivery Support </div>
<div class="pre2"> Middle Mile</div>
<div class="alignkafel1">
<div class="kafelek">Koszta Dodatkowe</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
</div>
<div class="alignkafel2">
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
</div>
I've been trying with multiple options but everything gets messed up in the end.
It looks like this:
Messed up website
And I want each of the 8 .kafelek (which are the buttons) to be perfectly aligned in 1 row with each other and also properly centered to align with .pre1 and .pre2
Please help ;-;
The container for the buttons has a width of 0 which prevents the flexbox from working properly. Adding a width fixes the problem.
.alignkafel1,
.alignkafel2 {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width: 60%;
margin: 0 auto;
}
I have added a width of 60% to align the buttons roughly to the pre above. Currently the pre have float property set. Ideally, you want a parent container to enforce the boundaries of your page content and refrain from using float css property.
In alignkafel1&2 set align-items and justify content properties to control the alignment of your buttons which are the flex items.
I removed .alignkafel1 and .alignkafel2 classes and replaced them with a single .alignkafel class with CSS Flex. The flex-direction: row property is used for .alignkafel class to give the desired layout. I additionally removed the unused CSS classes from the code.
You can see the following example:
body {
background-color: #003C3D;
}
.header {
text-align: center;
align-content: center;
padding: 20px;
font-family: 'Open Sans';
font-size: 24px;
color: #C3CECB;
}
#headerlogo {
width: 400px;
height: auto;
object-fit: cover;
position: absolute;
top: 20px;
left: 50%;
transform: translateX(-50%);
animation: slide-in 1s ease-in-out forwards;
}
#keyframes slide-in {
from {
top: -100px;
}
to {
top: 20px;
}
}
.pre1 {
width: 50%;
text-align: center;
align-content: center;
font-family: 'Open Sans';
font-size: 24px;
color: #C3CECB;
float: left;
}
.pre2 {
width: 50%;
text-align: center;
align-content: center;
font-family: 'Open Sans';
font-size: 24px;
color: #C3CECB;
float: right;
}
.row {
display: flex;
}
.row:after {
content: "";
display: table;
clear: both;
}
.kafelek {
background-color: #006D57;
border-radius: 10px;
text-align: center;
height: 100px;
font-family: 'Open Sans';
font-size: 20px;
color: #C3CECB;
margin-top: 50px;
margin-bottom: 1px;
margin-right: 10px;
margin-left: 10px;
display: flex;
align-items: center;
justify-content: center;
}
.kafelek:nth-child(4) {
margin-right: 100px !important;
}
.kafelek:nth-child(5) {
margin-left: 100px !important;
}
.kafelek:hover {
border: 2px solid #7EDF00;
transition: 0.3s;
cursor: pointer;
}
.alignkafel {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
<div class="header">
<img src="" img id="headerlogo" />
<br /> <br /> Centrum zgłoszeniowe AOK
</div>
<div class="pre1"> Delivery Support </div>
<div class="pre2"> Middle Mile</div>
<div class="alignkafel">
<div class="kafelek">Koszta Dodatkowe</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
</div>
i fixed your code, just paste it in your html and css file and everything will work fine. :D
<div class="header">
<img src="" img id="headerlogo" />
<br /> <br /> Centrum zgłoszeniowe AOK
</div>
<div class="pre1">
<p>Delivery Support </p>
<div class="alignkafel">
<div class="kafelek">Koszta Dodatkowe</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
</div>
</div>
<div class="pre2">
</p>Middle Mile</p>
<div class="alignkafel">
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
<div class="kafelek">COMING SOON</div>
</div>
</div>
body {
background-color: #003C3D;
}
.header {
text-align: center;
align-content: center;
padding: 20px;
font-family: 'Open Sans';
font-size: 24px;
color: #C3CECB;
}
#headerlogo {
width: 400px;
height: auto;
object-fit: cover;
position: absolute;
top: 20px;
left: 50%;
transform: translateX(-50%);
animation: slide-in 1s ease-in-out forwards;
}
#keyframes slide-in {
from {
top: -100px;
}
to {
top: 20px;
}
}
.pre1 {
width: 50%;
text-align: center;
align-content: center;
font-family: 'Open Sans';
font-size: 24px;
color: #C3CECB;
float: left;
}
.pre2 {
width: 50%;
text-align: center;
align-content: center;
font-family: 'Open Sans';
font-size: 24px;
color: #C3CECB;
float: right;
}
.alignkafel {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
flex-direction: column;
}
.row {
display: flex;
}
.kolumna {
display: inline-block;
width: 48%;
font-family: 'Open Sans';
color: #C3CECB;
text-align: center;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.kolumna:first-child {
margin-right: 0px;
}
.kolumna:last-child {
margin-left: 0px;
}
.row:after {
content: "";
display: table;
clear: both;
}
#media screen and (max-width: 800px) {
.kolumna {
width: 100%;
align-content: center;
}
}
.kolumna2 {
display: inline-block;
width: 48%;
font-family: 'Open Sans';
color: #C3CECB;
text-align: center;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.kolumna2:first-child {
margin-right: 0px;
}
.kolumna2:last-child {
margin-left: 0px;
}
#media screen and (max-width: 800px) {
.kolumna2 {
width: 100%;
align-content: center;
}
}
.kafelek {
background-color: #006D57;
border-radius: 10px;
text-align: center;
height: 100px;
font-family: 'Open Sans';
font-size: 20px;
color: #C3CECB;
margin: 5px;
margin-top: 50px;
margin-right: 50px;
margin-bottom: 1px;
margin-left: 50px;
display: flex;
align-items: center;
justify-content: center;
}
#media screen and (max-width: 800px) {
.kafelek {
display: flex;
justify-content: center;
}
}
.kafelek:hover {
border: 2px solid #7EDF00;
transition: 0.3s;
cursor: pointer;
}
Related
So, I'm making a web portfolio as my project and I managed to find a problem. When I use min-height in my "About me" section, the section doesn't seem to adjust its height according to the content. It might be because I use float in my navbar, but I'm not too sure. I would appreciate if someone can help me. Thanks in advance.
This is my HTML and CSS code:
/* global */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Montserrat", sans-serif;
scroll-behavior: smooth;
}
a {
text-decoration: none;
}
/* animations */
#keyframes bounce {
0% {
transform: translateY(0px);
}
50% {
transform: translateY(15px);
}
100% {
transform: translateY(0px);
}
}
#keyframes appear {
0% {
opacity: 0;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#keyframes popup {
0% {
transform: translateY(200px);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}
/* Navbar */
header {
width: 100%;
height: 64px;
text-align: center;
background-color: #1a374d;
display: flex;
justify-content: space-between;
padding: 0 80px;
font-weight: bold;
position: fixed;
z-index: 1;
}
header li {
list-style: none;
font-weight: bold;
}
header a {
color: #b1d0e0;
}
header .brandLong {
width: auto;
height: 64px;
float: left;
display: flex;
align-items: center;
justify-content: center;
color: #b1d0e0;
}
header .brandShort {
width: auto;
height: 64px;
float: left;
display: none;
align-items: center;
justify-content: center;
color: #b1d0e0;
}
header .menu {
width: 50%;
min-width: 350px;
height: 100%;
float: right;
}
header .menu ul {
width: 100%;
height: inherit;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
}
header .menu li {
height: inherit;
display: flex;
align-items: center;
justify-content: center;
}
header .menu ul a {
width: 25%;
height: inherit;
display: inline-block;
transition: 0.3s;
font-weight: 400;
}
header .menu ul a:hover {
background-color: #b1d0e0;
color: #1a374d;
transition: 0.3s;
font-weight: 400;
}
header #menuToggle {
display: none;
}
header .menu-icon {
display: none;
}
/* Home Section */
.home {
min-height: 100vh;
}
.home .container {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-content: center;
}
.home .container img {
height: 100%;
animation: popup 0.8s ease-in-out;
}
.home .container .text {
display: flex;
flex-direction: column;
width: 50%;
height: 100%;
justify-content: center;
animation: appear 1.6s;
}
.home .container .text h1 {
font-size: 72px;
font-weight: bold;
line-height: auto;
}
.home .container .text h1 span {
color: #1a374d;
}
.home .container .text p {
font-size: 24px;
margin-top: 20px;
letter-spacing: 2px;
line-height: 35px;
}
.home .container .arrow {
font-size: 24px;
animation: bounce 2s ease-in-out infinite, appear 1.6s;
position: absolute;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
top: 77%;
margin: 0 0 0 35%;
width: 50%;
font-weight: bold;
}
.home .container .arrow a {
color: #1a374d;
}
.home .container .arrow a i {
font-size: 48px;
margin-top: 5px;
}
/* About */
.about {
min-height: 100vh;
background-color: #406882;
color: white;
padding: 0 80px;
}
.about .container {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
justify-items: center;
align-items: center;
}
.about .container h1 {
font-size: 64px;
text-align: center;
margin: 150px 0 100px 0;
}
.about .container h2 {
font-size: 40px;
}
.about .container h3 {
font-weight: 400;
margin-bottom: 50px;
font-size: 24px;
}
.about .container .aboutContainer {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.about .container .aboutContainer .desc1 {
width: 25%;
text-align: justify;
padding: 30px;
display: flex;
flex-direction: column;
height: 100%;
justify-content: space-evenly;
}
.about .container .aboutContainer .desc1 .top {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.about .container .aboutContainer .desc1 .top p {
line-height: 28px;
margin-top: 12px;
font-size: 20px;
font-weight: normal;
}
.about .container .aboutContainer .desc1 .bottom {
display: flex;
flex-direction: column;
align-items: center;
}
.about .container .aboutContainer .desc2 {
width: 30%;
background-image: url(asset/me2.jpg);
background-position: center;
background-size: cover;
background-repeat: no-repeat;
height: 700px;
border-radius: 40px;
margin: 20px;
}
.about .container .aboutContainer .desc2 img {
height: 100%;
}
.about .container .aboutContainer .desc3 {
width: 25%;
padding-left: 50px;
}
.about .container .aboutContainer .desc3 h2 {
margin-bottom: 12px;
}
.about .container .aboutContainer .desc3 ul li {
font-size: 20px;
margin-bottom: 8px;
margin-left: 20px;
}
/* social media */
.socialMedia {
display: flex;
margin-top: 12px;
justify-content: space-evenly;
width: 80%;
}
.socialMedia .instagram {
background-color: white;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
color: #dd2a7b;
border-radius: 50%;
transition: 0.5s;
font-size: 24px;
}
.socialMedia .email {
background-color: white;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
color: #ea4335;
border-radius: 50%;
transition: 0.5s;
font-size: 24px;
}
.socialMedia .email:hover {
background-color: #ea4335;
color: white;
transition: 0.5s;
}
.socialMedia .instagram:hover {
background-color: #dd2a7b;
color: white;
transition: 0.5s;
}
.socialMedia .linkedin {
background-color: white;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
color: #0077b5;
border-radius: 50%;
transition: 0.5s;
font-size: 24px;
}
.socialMedia .linkedin:hover {
background-color: #0077b5;
color: white;
transition: 0.5s;
}
.socialMedia .spotify {
background-color: white;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
color: #1ed761;
border-radius: 50%;
transition: 0.5s;
font-size: 24px;
}
.socialMedia .spotify:hover {
background-color: #1ed761;
color: white;
transition: 0.5s;
}
.socialMedia .github {
background-color: white;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
color: #171515;
border-radius: 50%;
transition: 0.5s;
font-size: 24px;
}
.socialMedia .github:hover {
background-color: #171515;
color: white;
transition: 0.5s;
}
/* Education background */
.about .container .edu {
margin: 50px 0 100px 0;
}
.about .container .edu h2 {
margin-bottom: 24px;
}
.about .container .edu table {
font-size: 24px;
border-collapse: collapse;
}
.about .container .edu table td {
padding: 15px;
padding-right: 100px;
}
.about .container .edu table thead {
background-color: #6998ab;
font-weight: 600;
}
.about .container .edu table tbody {
background-color: #b1d0e0;
}
.about .container .edu table tbody tr:nth-child(2) {
background-color: #a0c4d6;
}
/* Media Query */
#media screen and (max-width: 1200px) {
.home .container img {
display: none;
}
.home .container .text {
text-align: center;
display: flex;
flex-direction: column;
width: 80%;
height: 100%;
justify-content: center;
animation: appear 1.6s;
}
.home .container .arrow {
width: 100%;
margin: 0;
}
}
#media screen and (max-width: 768px) {
/* NavBar */
header {
display: block;
padding: 0;
}
.brandLong {
display: none;
}
.brandShort {
display: flex;
margin-left: 80px;
}
.menu {
width: 100%;
height: auto;
}
.menu ul {
display: block;
max-height: 0;
overflow: hidden;
transition: max-height 0.3s;
}
.menu ul a {
text-align: left;
width: 100%;
height: 50px;
background-color: #1a374d;
}
.menu-icon {
width: 200px;
height: inherit;
display: block;
position: absolute;
top: 18px;
right: 0;
color: #b1d0e0;
}
#menuToggle:checked~ul {
max-height: 350px;
}
.menu-icon i {
font-size: 1.7em;
}
.home .container .text h1 {
font-size: 48px;
}
}
#media screen and (max-width: 480px) {
.brandShort {
display: flex;
margin-left: 40px;
}
.menu-icon {
width: 100px;
}
.home .container .text h1 {
font-size: 36px;
}
.home .container .arrow a {
display: none;
}
}
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght#0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="landingPage.css">
<title>Christopher's Portfolio</title>
</head>
<body>
<!-- Nav Bar -->
<header>
<a href="#homeSection">
<figure class="brandLong">Christopher Nathanael Tessy</figure>
</a>
<a href="#homeSection">
<figure class="brandShort">Christopher N. T.</figure>
</a>
<nav class="menu">
<input type="checkbox" id="menuToggle">
<label for="menuToggle" class="menu-icon"><i class="fa fa-bars"></i></label>
<ul>
<a href="#homeSection">
<li>Home</li>
</a>
<a href="#aboutSection">
<li>About Me</li>
</a>
<a href="#">
<li>Portfolio</li>
</a>
<a href="#">
<li>Contact</li>
</a>
</ul>
</nav>
</header>
<!-- Home Section -->
<section class="home" id="homeSection">
<div class="container">
<img src="asset/me1.png" alt="Christopher NT">
<div class="text">
<h1>
Hey there! I'm <span>Christopher Nathanael Tessy</span>
</h1>
<p>Welcome to my personal web portfolio where I will showcase my best of the best works</p>
</div>
<div class="arrow">
About me
<i class="fas fa-angle-double-down"></i>
</div>
</div>
</section>
<!-- About Me Section -->
<section class="about" id="aboutSection">
<div class="container">
<h1>About Me</h1>
<h2>Christopher Nathanael Tessy</h2>
<h3>Front-End Web Developer</h3>
<div class="aboutContainer">
<div class="desc1">
<div class="top">
<h2>Who am I?</h2>
<p>My name is Christopher Nathanael Tessy. I am a dedicated and hardworking computer science student with a strong passion in front-end web development equipped with strong designing abilities with proven successes in designing posters, banners,
backdrops, social media, and merchandise for multiple years. Committed to working as a collaborative and positive team member. Bilingual, communicative, and ready to join my next team.
</p>
</div>
<div class="bottom">
<h2>Social Media</h2>
<div class="socialMedia">
<a href="mailto:christopher.nathanael1217#gmail.com">
<div class="email">
<span class="far fa-envelope"></span>
</div>
</a>
<a href="https://www.instagram.com/christophertessy_/">
<div class="instagram">
<span class="fab fa-instagram"></span>
</div>
</a>
<a href="https://www.linkedin.com/in/christopher-nathanael-tessy-b30339220/">
<div class="linkedin">
<span class="fab fa-linkedin-in"></span>
</div>
</a>
<a href="https://open.spotify.com/user/21z7frm7cr3jctz2c6zv6nafa?si=bd8ea929cc274a96">
<div class="spotify">
<span class="fab fa-spotify"></span>
</div>
</a>
<a href="https://github.com/TessyJr">
<div class=" github">
<span class="fab fa-github"></span>
</div>
</a>
</div>
</div>
</div>
<div class="desc2">
</div>
<div class="desc3">
<h2>Software and Programming Languages</h2>
<p>
<ul>
<li>Photoshop</li>
<li>Visual Studio Code</li>
<li>Figma</li>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
<li>C++</li>
</ul>
</p>
</div>
</div>
<div class="edu">
<h2>Education Background</h2>
<table>
<thead>
<tr>
<td>Year</td>
<td>Level of Education</td>
<td>Description</td>
</tr>
</thead>
<tbody>
<tr>
<td>2009-2015</td>
<td>Primary School</td>
<td>Sekolah Bina Gita Gemilang</td>
</tr>
<tr>
<td>2015-2021</td>
<td>High School</td>
<td>Penabur Secondary Kelapa Gading</td>
</tr>
<tr>
<td>2021-2025</td>
<td>University</td>
<td>Bina Nusantara University</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
</body>
</html>
This is the problem I'm facing:
The background color doesn't cover the bottom area
Remove the height property
.about .container {
width: 100%;
display: flex;
flex-direction: column;
justify-items: center;
align-items: center;
}
min-height: 100vh to the body element should do the trick. Here, 100vh means that the initial body height will take 100% of the viewport height,
its better to use :
height : 100vh;
The logo element in this page is not centering vertically within the <header> container. The problem is more pronounced on mobile than on desktop. The second element (#forum-link) is aligning correctly.
The flexbox align-items:center rule seems to work for one child div but not the other. Why is that the case and how do you fix it?
html {
max-width: 780px;
margin: 0 auto;
}
body {
background-image: url('https://img.freepik.com/free-vector/retro-styled-pattern-background_1048-6593.jpg');
background-size: 116px;
background-repeat: repeat-x;
}
header {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
height:116px;
}
#logo {
margin-left: 15px;
}
#forum-link {
max-width: 110px;
margin-right: 35px;
}
#forum-link a {
color: white;
text-decoration: none;
font-weight: bold;
font-size: x-large;
}
#media only screen and (orientation: portrait) {
html {
margin: 0;
height: 100%;
}
body {
margin: 0;
height: 100%;
display: flex;
flex-flow: column;
}
header {
display: block;
width: 100%;
position: relative;
height: auto;
margin-bottom: 50px;
}
#logo {
margin: initial;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link {
margin: initial;
max-width: initial;
background: #323232;
height: 27px;
position: absolute;
bottom: -50px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link a {
font-weight: bold;
font-size: .9em;
}
#forum-link a:hover {
text-decoration: underline;
}
<body>
<header>
<div id="logo"><img src="http://placekitten.com/g/354/85" srcset="http://placekitten.com/g/354/85, http://placekitten.com/g/354/85 2x" width="354" height="85"></div>
<div id="forum-link">Join our Forums!</div>
</header>
</body>
EDIT: Clarified the question
Umm, I think this is what you're after: logo and link is vertically centred on the bg? Only updated for non-mobile solution.
Also, as I said in my comment, repeated here for comprehensiveness: your image isn't vertically centring because it's the height of its parents: the #logo and header.
The link has a smaller height than the header, so it's vertically centring.
If you're referring to the 5px or so of space, just throw a display: block on your #logo's image to remove that spacing. It will still be the height of its parents though.
My solution basically gives your body a height, flex it and your header aligns itself vertically centred.
html {
max-width: 780px;
margin: 0 auto;
}
body {
background-image: url('https://img.freepik.com/free-vector/retro-styled-pattern-background_1048-6593.jpg');
background-size: 116px;
background-repeat: repeat-x;
height: 116px;
margin: 0;
display: flex;
}
header {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
margin-bottom: 0;
width: 100%;
}
#logo {
margin-left: 15px;
}
#logo img {
display: block;
}
#forum-link {
max-width: 110px;
margin-right: 35px;
}
#forum-link a {
color: white;
text-decoration: none;
font-weight: bold;
font-size: x-large;
}
#media only screen and (orientation: portrait) {
html {
margin: 0;
height: 100%;
}
body {
margin: 0;
height: 100%;
display: flex;
flex-flow: column;
}
header {
display: block;
width: 100%;
position: relative;
height: auto;
margin-bottom: 50px;
}
#logo {
margin: initial;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link {
margin: initial;
max-width: initial;
background: #323232;
height: 27px;
position: absolute;
bottom: -50px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link a {
font-weight: bold;
font-size: .9em;
}
#forum-link a:hover {
text-decoration: underline;
}
<body>
<header>
<div id="logo"><img src="http://placekitten.com/g/354/85" srcset="http://placekitten.com/g/354/85, http://placekitten.com/g/354/85 2x" width="354" height="85"></div>
<div id="forum-link">Join our Forums!</div>
</header>
</body>
Just add margin: 0 in body :
html {
max-width: 780px;
margin: 0 auto;
}
body {
background-image: url('https://img.freepik.com/free-vector/retro-styled-pattern-background_1048-6593.jpg');
background-size: 116px;
background-repeat: repeat-x;
margin: 0;
}
header {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
height:116px;
}
#logo {
margin-left: 15px;
}
#forum-link {
max-width: 110px;
margin-right: 35px;
}
#forum-link a {
color: white;
text-decoration: none;
font-weight: bold;
font-size: x-large;
}
#media only screen and (orientation: portrait) {
html {
margin: 0;
height: 100%;
}
body {
margin: 0;
height: 100%;
display: flex;
flex-flow: column;
}
header {
display: block;
width: 100%;
position: relative;
height: auto;
margin-bottom: 50px;
}
#logo {
margin: initial;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link {
margin: initial;
max-width: initial;
background: #323232;
height: 27px;
position: absolute;
bottom: -50px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link a {
font-weight: bold;
font-size: .9em;
}
#forum-link a:hover {
text-decoration: underline;
}
<body>
<header>
<div id="logo"><img src="http://placekitten.com/g/354/85" srcset="http://placekitten.com/g/354/85, http://placekitten.com/g/354/85 2x" width="354" height="85"></div>
<div id="forum-link">Join our Forums!</div>
</header>
</body>
You need to specify the width of your parents for it to center vertically. And then add text-align: center;. Change the styles of your #logo and #forum-link as below.
#logo {
flex: 1;
width: 50%;
text-align: center;
}
#forum-link {
max-width: 110px;
flex: 1;
width: 50%;
text-align: center;
}
I removed your margins because the preview here is very small and you wont notice that the elements were centered vertically. Feel free to put it back in your source code. Check code below
html {
max-width: 780px;
margin: 0 auto;
}
body {
background-image: url('https://img.freepik.com/free-vector/retro-styled-pattern-background_1048-6593.jpg');
background-size: 116px;
background-repeat: repeat-x;
}
header {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
margin-bottom: 23px;
}
#logo {
flex: 1;
width: 50%;
text-align: center;
}
#forum-link {
max-width: 110px;
flex: 1;
width: 50%;
text-align: center;
}
#forum-link a {
color: white;
text-decoration: none;
font-weight: bold;
font-size: x-large;
}
#media only screen and (orientation: portrait) {
html {
margin: 0;
height: 100%;
}
body {
margin: 0;
height: 100%;
display: flex;
flex-flow: column;
}
header {
display: block;
width: 100%;
position: relative;
height: auto;
margin-bottom: 50px;
}
#logo {
margin: initial;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link {
margin: initial;
max-width: initial;
background: #323232;
height: 27px;
position: absolute;
bottom: -50px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link a {
font-weight: bold;
font-size: .9em;
}
#forum-link a:hover {
text-decoration: underline;
}
<body>
<header>
<div id="logo"><img src="http://placekitten.com/g/354/85" srcset="http://placekitten.com/g/354/85, http://placekitten.com/g/354/85 2x" width="354" height="85"></div>
<div id="forum-link">Join our Forums!</div>
</header>
</body>
I added #media screen and (max-width: 1000px) rule to my code with modifications it would make. I wanted to make boxes stack up on width: 1000px; and I did succeed to do that, however, now when the boxes stack up, there is an extra space to the right of my webpage.
It appears that my boxes somehow conflict with one of the lines of the header style. Tried removing margins and did not pay off. I want that space removed that those boxes add.
Also, it is possible that the header does not have to do anything here and only the boxes are stretching out the website.
body {
margin: 0;
}
.header {
width: 100%;
height: 100vh;
background-color: #262626;
display: table-cell;
vertical-align: middle;
}
.header h1 {
line-height: 50%;
color: white;
text-align: center;
font-size: 5em;
}
.content {
margin-top: 10%;
}
.subcontent div a {
user-select: none;
font-size: 30px;
display: table-cell;
vertical-align: middle;
text-decoration: none;
text-align: center;
color: black;
font-weight: normal;
border: 2px solid #3B3B3B;
font-family: "ALK Rounded Mtav Med", sans-serif;
transition-duration: 0.3s;
}
.subcontent {
display: flex;
justify-content: center;
}
.subcontent div {
display: table;
margin: 15px;
height: 500px;
width: 100%;
transition-duration: 0.15s;
}
#media screen and (max-width: 1000px) {
.subcontent {
display: block;
}
.subcontent div {
height: 300px;
margin-top: 15px;
margin-bottom: 15px;
}
}
<body>
<div style="display: table; width: 100%;">
<div class="header">
<h1>ვისწავლოთ</h1>
<h1>იაპონური</h1>
</div>
</div>
<div class="content">
<div class="subcontent">
<div>
ანბანი
</div>
<div>
გრამატიკა
</div>
</div>
<div class="subcontent">
<div>
ლექსიკონი
</div>
<div>
დიალოგები
</div>
</div>
</div>
</body>
Don't change display:flex to display:block. Instead you can simply change flex-diretion to column and make width:auto to avoid the overflow due to the margin added to the width:100%.
body {
margin: 0;
}
.header {
width: 100%;
height: 100vh;
background-color: #262626;
display: table-cell;
vertical-align: middle;
}
.header h1 {
line-height: 50%;
color: white;
text-align: center;
font-size: 5em;
}
.content {
margin-top: 10%;
}
.subcontent div a {
user-select: none;
font-size: 30px;
display: table-cell;
vertical-align: middle;
text-decoration: none;
text-align: center;
color: black;
font-weight: normal;
border: 2px solid #3B3B3B;
font-family: "ALK Rounded Mtav Med", sans-serif;
transition-duration: 0.3s;
}
.subcontent {
display: flex;
justify-content: center;
}
.subcontent div {
display: table;
margin: 15px;
height: 500px;
width: 100%;
transition-duration: 0.15s;
}
#media screen and (max-width: 1000px) {
.subcontent {
flex-direction:column;
}
.subcontent div {
height: 300px;
width:auto;
margin-top: 15px;
margin-bottom: 15px;
}
}
<body>
<div style="display: table; width: 100%;">
<div class="header">
<h1>ვისწავლოთ</h1>
<h1>იაპონური</h1>
</div>
</div>
<div class="content">
<div class="subcontent">
<div>
ანბანი
</div>
<div>
გრამატიკა
</div>
</div>
<div class="subcontent">
<div>
ლექსიკონი
</div>
<div>
დიალოგები
</div>
</div>
</div>
</body>
It's because of the margin: 15px on the .subcontent which makes a margin of 15px all around the .subcontent
body {
margin: 0;
}
.header {
width: 100%;
height: 100vh;
background-color: #262626;
display: table-cell;
vertical-align: middle;
}
.header h1 {
line-height: 50%;
color: white;
text-align: center;
font-size: 5em;
}
.content {
margin-top: 10%;
}
.subcontent div a {
user-select: none;
font-size: 30px;
display: table-cell;
vertical-align: middle;
text-decoration: none;
text-align: center;
color: black;
font-weight: normal;
border: 2px solid #3B3B3B;
font-family: "ALK Rounded Mtav Med", sans-serif;
transition-duration: 0.3s;
}
.subcontent {
display: flex;
justify-content: center;
}
.subcontent div {
display: table;
/* margin: 15px; This is the villain */
height: 500px;
width: 100%;
transition-duration: 0.15s;
}
#media screen and (max-width: 1000px) {
.subcontent {
display: block;
}
.subcontent div {
height: 300px;
margin-top: 15px;
margin-bottom: 15px;
}
}
<body>
<div style="display: table; width: 100%;">
<div class="header">
<h1>ვისწავლოთ</h1>
<h1>იაპონური</h1>
</div>
</div>
<div class="content">
<div class="subcontent">
<div>
ანბანი
</div>
<div>
გრამატიკა
</div>
</div>
<div class="subcontent">
<div>
ლექსიკონი
</div>
<div>
დიალოგები
</div>
</div>
</div>
</body>
Fiddle here
I am running into some issues with resizing of the window (shrinking). When I shrink it down, the background colors no longer stay at the edge of the viewport, and content goes beyond it.
I thought that setting the width on the entire body to 100% would fix that, but it didn't?
Here is a JSFiddle of my current code, for the index page and the stylesheet:
* {
margin: 0;
padding: 0;
}
body {
font-family: Segoe UI, helvetica, arial;
display: flex;
flex-direction: column;
min-height: 100vh;
font-size: 18px;
width: 100%;
}
a {
color: hsl(344, 69%, 70%);
font-weight: bold;
}
a:hover {
text-decoration: none;
color: #67c3b2;
}
.menu-container {
background-color: rgba(150, 150, 150, 0.2);
padding: 20px 0;
display: flex;
justify-content: center;
text-transform: uppercase;
width: 100%;
}
.menu {
width: 90%;
display: flex;
top: 10px;
justify-content: space-between;
font-size: 16px;
overflow: hidden;
position: relative;
left: 10px;
}
.header-container {
background-color: rgba(150, 150, 150, 0.2);
display: flex;
justify-content: center;
height: 30px;
width: 100%;
position: relative;
}
.logo {
position: relative;
bottom: 37px;
z-index: 1;
}
.flex-container {
display: flex;
justify-content: center;
}
.flex-container p {
position: relative;
margin-left: 40px;
margin-right: 40px;
font-weight: bold;
top: 40px;
margin-top: 40px;
text-align: center;
}
.main {
display: flex;
color: #464646;
background: linear-gradient(to right, #77C9D4, #57BC90);
flex: 1;
}
.cakelist {
position: relative;
bottom: 50px;
display: flex;
font-weight: bold;
list-style-position: inside;
margin-top: 130px;
}
.cakelist ol,
table {
margin-left: 25px;
}
.cakelist h2 {
margin-left: 25px;
margin-top: 20px;
}
.carousel {
color: #464646;
top: 80px;
position: relative;
display: flex;
justify-content: center;
border: 3px outset gray;
align-items: center;
padding: 60px 60px 60px 60px;
}
.buttons {
position: relative;
width: 1600px;
margin-right: 25px;
justify-content: space-around;
display: flex;
top: 160px;
text-align: center;
}
.button a:hover {
opacity: 0.2;
}
.buttons p {
margin-top: 20px;
}
.buttons img {
padding-top: 25px;
height: 200px;
}
.gallery {
position: relative;
top: 80px;
}
.pricing {
display: flex;
position: relative;
top: 80px;
justify-content: center;
flex-direction: column;
padding-bottom: 140px;
}
.pricing p,
h1 {
margin-left: 250px;
text-align: left;
margin-top: 5px;
}
.pricing span {
opacity: 0;
user-select: none;
}
.order {
position: relative;
border-radius: 5px;
background: hsl(344, 69%, 70%);
top: 20px;
margin-top: 60px;
padding: 5px;
}
#order-link {
color: white;
text-decoration: none;
}
.order-button {
width: 180px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
.footer-container {
display: flex;
justify-content: flex-end;
align-items: center;
background: #9A9A9A;
height: 90px;
max-height: 90px;
}
.footer-logo {
height: 80px;
position: relative;
right: 10px;
}
.subscribe {
border-radius: 25px;
background: hsl(344, 69%, 70%);
padding: 5px 20px 5px 20px;
width: 80px;
}
#subscribe-link {
position: relative;
color: white;
text-decoration: none;
right: 40px;
}
<div class="menu-container">
<div class="menu">
<div class="flex-item">About Us</div>
<div class="flex-item">Cakes</div>
<div class="flex-item">Cupcakes</div>
<div class="flex-item">Gallery</div>
<div class="flex-item">Prices/Order</div>
<div class="flex-item">Search</div>
</div>
</div>
<header class="header-container">
<img src="TCCLogo.png" class="logo" />
</header>
<div class="flex-container main">
<div class="container">
<div class="carousel">
Here is where I will have the quick gallery/carousel when I get to JS.
</div>
<div class="buttons">
<div class="button">
<img src="cake.png" />
<p>Check out our delicious cake options!</p>
</div>
<div class="button">
<img src="cupcake.png" />
<p>Check out our delicious cupcake options!</p>
</div>
<div class="button">
<img src="prices.png" />
<p>Check out our competitive pricing!</p>
</div>
</div>
</div>
</div>
<footer class="footer-container">
<a id="subscribe-link" target="_blank" href="#">
<div class="subscribe">
<p>Subscribe</p>
</div>
</a>
<img src="TCCLogo.png" class="footer-logo" />
</footer>
I have tried going through my stylesheet, changing the widths on anything I have set with pixels to percentages, but it didn't seem to fix it. The only thing that -sort of- worked was changing the body position to fixed, but then none of the content was view-able if it got shrunk down, all it fixed was keeping the background/header/footer colors the same.
I imagine maybe my coding is a bit messy - I tried my best to be extensible, but being 100% new at this made it difficult.
Your problem is that you have width:1600px in .buttons just remove it and also add box-sizing:border-box to all (pseudo-)elements
EDIT:
you also need to add max-width:100% to .container and flex-wrap:wrap in .buttons
*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box
}
body {
font-family: Segoe UI, helvetica, arial;
display: flex;
flex-direction: column;
min-height: 100vh;
font-size: 18px;
}
a {
color: hsl(344, 69%, 70%);
font-weight: bold;
}
a:hover {
text-decoration: none;
color: #67c3b2;
}
.menu-container {
background-color: rgba(150, 150, 150, 0.2);
padding: 20px 0;
display: flex;
justify-content: center;
text-transform: uppercase;
width: 100%;
}
.menu {
width: 90%;
display: flex;
top: 10px;
justify-content: space-between;
font-size: 16px;
overflow: hidden;
position: relative;
left: 10px;
}
.header-container {
background-color: rgba(150, 150, 150, 0.2);
display: flex;
justify-content: center;
height: 30px;
width: 100%;
position: relative;
}
.logo {
position: relative;
bottom: 37px;
z-index: 1;
}
.flex-container {
display: flex;
justify-content: center;
}
.flex-container p {
position: relative;
margin-left: 40px;
margin-right: 40px;
font-weight: bold;
top: 40px;
margin-top: 40px;
text-align: center;
}
.main {
display: flex;
color: #464646;
background: linear-gradient(to right, #77C9D4, #57BC90);
flex: 1;
}
.cakelist {
position: relative;
bottom: 50px;
display: flex;
font-weight: bold;
list-style-position: inside;
margin-top: 130px;
}
.cakelist ol,
table {
margin-left: 25px;
}
.cakelist h2 {
margin-left: 25px;
margin-top: 20px;
}
.container {
max-width: 100%
}
.carousel {
color: #464646;
top: 80px;
position: relative;
display: flex;
justify-content: center;
border: 3px outset gray;
align-items: center;
padding: 60px;
}
.buttons {
position: relative;
margin-right: 25px;
justify-content: space-around;
display: flex;
flex-wrap: wrap;
top: 160px;
text-align: center;
}
.button a:hover {
opacity: 0.2;
}
.buttons p {
margin-top: 20px;
}
.buttons img {
padding-top: 25px;
height: 200px;
}
.gallery {
position: relative;
top: 80px;
}
.pricing {
display: flex;
position: relative;
top: 80px;
justify-content: center;
flex-direction: column;
padding-bottom: 140px;
}
.pricing p,
h1 {
margin-left: 250px;
text-align: left;
margin-top: 5px;
}
.pricing span {
opacity: 0;
user-select: none;
}
.order {
position: relative;
border-radius: 5px;
background: hsl(344, 69%, 70%);
top: 20px;
margin-top: 60px;
padding: 5px;
}
#order-link {
color: white;
text-decoration: none;
}
.order-button {
width: 180px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
.footer-container {
display: flex;
justify-content: flex-end;
align-items: center;
background: #9A9A9A;
height: 90px;
max-height: 90px;
}
.footer-logo {
height: 80px;
position: relative;
right: 10px;
}
.subscribe {
border-radius: 25px;
background: hsl(344, 69%, 70%);
padding: 5px 20px 5px 20px;
width: 80px;
}
#subscribe-link {
position: relative;
color: white;
text-decoration: none;
right: 40px;
}
<div class="menu-container">
<div class="menu">
<div class="flex-item">About Us</div>
<div class="flex-item">Cakes</div>
<div class="flex-item">Cupcakes</div>
<div class="flex-item">Gallery</div>
<div class="flex-item">Prices/Order</div>
<div class="flex-item">Search</div>
</div>
</div>
<header class="header-container">
<img src="TCCLogo.png" class="logo" />
</header>
<div class="flex-container main">
<div class="container">
<div class="carousel">
Here is where I will have the quick gallery/carousel when I get to JS.
</div>
<div class="buttons">
<div class="button">
<img src="cake.png" />
<p>Check out our delicious cake options!</p>
</div>
<div class="button">
<img src="cupcake.png" />
<p>Check out our delicious cupcake options!</p>
</div>
<div class="button">
<img src="prices.png" />
<p>Check out our competitive pricing!</p>
</div>
</div>
</div>
</div>
<footer class="footer-container">
<a id="subscribe-link" target="_blank" href="#">
<div class="subscribe">
<p>Subscribe</p>
</div>
</a>
<img src="TCCLogo.png" class="footer-logo" />
</footer>
I have made it proper as you needed. And it's working for me.
Please add below css
.container, .buttons {
max-width: 100%;
}
I'm trying to center this icon inside its div but can't seem to do that.
I tried top: 50% but that doesnt work.
The class is ion-images and I know I can send a margin-top to it but I want to know how to properly set it in the middle.
body {
margin: 0;
}
.clearfix::after {
content: "";
display: table;
clear: both;
}
/*-------------------HEADER*----------------*/
header {
position: relative;
width: 100%;
height: 100vh;
}
.header-bg {
position: absolute;
width: 100%;
height: 100%;
background-image: url(main-bg.jpg);
background-size: cover;
background-position: center;
}
.header-wrapper {
position: absolute;
width: 100%;
height: 100%;
bottom: 0;
display: flex;
flex-flow: row wrap;
justify-content: center;
align-items: center;
}
.title-wrapper {
position: relative;
width: 320px;
height: auto;
margin: 0 auto;
top: -10%;
}
.title-wrapper h1 {
text-align: center;
color: white;
letter-spacing: 5.45px;
margin-bottom: -10px;
font-size: 62px;
font-family: 'Raleway', sans-serif;
border-top: 3px solid white;
font-weight: 500;
}
.title-wrapper h3 {
text-align: center;
color: #35E2FF;
letter-spacing: 3.45px;
font-family: 'Raleway', sans-serif;
font-size: 15px;
}
.title-wrapper h2 {
color: white;
font-size: 50px;
margin-top: 80px;
font-family: 'Raleway', sans-serif;
}
.title-wrapper h4 {
color: white;
font-family: 'Raleway', sans-serif;
font-weight: 400;
text-align: center;
font-size: 25px;
margin-bottom: 50px;
}
#download {
text-align: center;
;
}
#demo:link {
text-decoration: none;
color: white;
border: 2px solid white;
text-align: center;
padding: 20px 40px;
text-transform: uppercase;
font-size: 25px;
font-family: 'Raleway', sans-serif;
transition: all 200ms ease-in-out;
-webkit-transition: all 200ms ease-in-out;
-moz-transition: all 200ms ease-in-out;
-o-transition: all 200ms ease-in-out;
}
#demo:hover {
background-color: #35E2FF;
}
/*------------------------------DESCRIPTION---------------*/
#description-wrapper {
position: relative;
width: 100%;
top: 0;
}
.desc-card {
position: relative;
width: 50%;
height: 450px;
margin: 0;
}
.desc-card.left {
float: left;
left: 0;
background-color: #000;
}
.desc-card.right {
float: right;
right: 0;
background-color: #282828;
}
#features-content {
position: absolute;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
#features-content h3 {
color: white;
font-family: 'Raleway', sans-serif;
letter-spacing: 3.5px;
font-weight: 500;
font-size: 32px;
}
#features-content p {
color: white;
font-family: 'Raleway', sans-serif;
font-weight: 300;
letter-spacing: 3.5px;
}
#features-img {
position: absolute;
width: 100%;
height: 100%;
display: flex;
flex-flow: row wrap;
justify-content: center;
align-items: center;
flex-direction: column;
}
.square {
width: 50%;
height: 50%;
}
.square.first {} .square.second {
background-color: #4A4A4A;
}
.square.third {
background-color: #4A4A4A;
}
.img-cont {
position: relative;
width: 100%;
height: 100%;
}
.ion-images {
/*THIS IS WHAT IM TRYING TO CENTER */
color: #35E2FF;
text-align: center;
font-size: 115px;
}
#under-img {
font-size: 25px;
color: #35E2FF;
margin-top: -10px;
font-family: 'Raleway', sans-serif;
font-weight: 300;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<link href="https://fonts.googleapis.com/css?family=Raleway:300,400,500" rel="stylesheet">
<!----HEADER------>
<header>
<div class="header-bg"></div>
<div class="header-wrapper">
<div class="title-wrapper">
<h1>ATLAS</h1>
<h3>BETA</h3>
<h4>Create Professional Digital Design in any Operating System</h4>
<div id="download">Download Now
</div>
</div>
</div>
</header>
<div id="description-wrapper" class="clearfix">
<div class="desc-card left" id="features">
<div id="features-content">
<h3>The All In One Tool for Creative Designers In Any Operating System</h3>
<p>ATLAS provides users the best software to do what they do best. Design</p>
</div>
</div>
<div class="desc-card right" id="features-des">
<div id="features-img">
<div class="square first">
<div class="img-cont">
<div class="ion-images">
<!--Trying to center this--->
<p id="under-img">Photo Editing</p>
</div>
</div>
</div>
<div class="square second">
</div>
<div class="square third">
</div>
<div class="square fourth">
</div>
</div>
</div>
</div>
Try
.ion-images{ /*THIS IS WHAT IM TRYING TO CENTER */
color: #35E2FF;
text-align: center;
font-size: 115px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Reference
If you can use Flex, try whit this.
.ion-images {
height: 100%;
flex-direction: column;
display: flex;
align-items: center;
justify-content: center;
}
Hope can i help you. Regards.