I am trying to evenly space two HTML elements (div) which both contain a list of <a> tags/links. The container width is 600px and there is a separator in between these two lists.
By running the snippet below you can see how the .dropdownSection elements are evenly sized using flex: 1. However, my problem is the separator (.sectionSeparator ) doesn't look even between the two lists?
What can I do to make it so that everything is evenly spaced, it seems like gap: 30px works well but the separator still isn't even, the second list is too close to the separator.
The reason I have used position: absolute on .dropdownLinks is so that the CSS hover transition does not push and cause other divs to be moved.
Maybe there is another way to structure this but this is my attempt.
Note: The grey boxes are to represent icons that would be there.
#container {
width: 600px;
padding-top: 20px;
}
#listSectionContainer {
display: flex;
justify-content: space-evenly;
padding: 30px;
gap: 30px;
}
.dropdownSection {
display: flex;
flex-direction: column;
justify-content: flex-start;
position: relative;
height: 210px;
flex: 1;
}
.sectionSeparator {
width: 3px;
background-color: rgba(178, 178, 178, 0.35);
border-radius: 8px;
}
.dropdownSectionTitle {
display: flex;
align-items: flex-start;
margin-right: auto;
color: #8B8792;
font-size: 20px;
}
.dropdownSectionTitle i {
height: 20px;
width: 20px;
background: grey;
margin-right: 10px;
}
.dropdownSectionTitle p {
font-weight: bold;
margin: 0;
}
.dropdownLinks {
display: flex;
flex-direction: column;
margin-top: 25px;
font-size: 18px;
padding-left: 28px;
position: absolute;
top: 20px;
}
.dropdownLinks a:not(:last-of-type) {
margin-bottom: 10px;
}
.dropdownLinks a:link {
color: #939393;
text-decoration: none;
transition: all 0.2s linear;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
}
.dropdownLinks a:visited {
color: #939393;
text-decoration: none;
}
.dropdownLinks a:hover {
color: #7B69FE;
padding-left: 5px;
text-decoration: none;
}
.dropdownLinks a:active {
color: #939393;
text-decoration: none;
}
<div id="container">
<div id="listSectionContainer">
<div class="dropdownSection">
<div class="dropdownSectionTitle"><i class="fas fa-book-reader"></i>
<p>Getting Started</p>
</div>
<div class="dropdownLinks">
Introduction
Introduction Two
Introduction Three
Introduction Four
Introduction Five
</div>
</div>
<div class="sectionSeparator"></div>
<div class="dropdownSection">
<div class="dropdownSectionTitle"><i class="fas fa-plug"></i>
<p>Second List</p>
</div>
<div class="dropdownLinks">
Introduction
Introduction Two
Introduction Three
Introduction Four
Introduction Five
</div>
</div>
</div>
</div>
After further investigation, there is nothing wrong in your code.
As you can see in the below snippet. The sections are evenly separated from the vertical line.
I have used a border for both container and the sections to understand that clearly.
#container {
width: 600px;
padding-top: 20px;
}
#listSectionContainer {
display: flex;
justify-content: space-evenly;
padding: 30px;
gap: 30px;
border: 1px solid blue;
}
.dropdownSection {
display: flex;
flex-direction: column;
justify-content: flex-start;
position: relative;
height: 210px;
flex: 1;
border: 1px solid #f00;
}
.sectionSeparator {
width: 3px;
background-color: rgba(178, 178, 178, 0.35);
border-radius: 8px;
}
.dropdownSectionTitle {
display: flex;
align-items: flex-start;
margin-right: auto;
color: #8B8792;
font-size: 20px;
}
.dropdownSectionTitle i {
height: 20px;
width: 20px;
background: grey;
margin-right: 10px;
}
.dropdownSectionTitle p {
font-weight: bold;
margin: 0;
}
.dropdownLinks {
display: flex;
flex-direction: column;
margin-top: 25px;
font-size: 18px;
padding-left: 28px;
position: absolute;
top: 20px;
}
.dropdownLinks a:not(:last-of-type) {
margin-bottom: 10px;
}
.dropdownLinks a:link {
color: #939393;
text-decoration: none;
transition: all 0.2s linear;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
}
.dropdownLinks a:visited {
color: #939393;
text-decoration: none;
}
.dropdownLinks a:hover {
color: #7B69FE;
padding-left: 5px;
text-decoration: none;
}
.dropdownLinks a:active {
color: #939393;
text-decoration: none;
}
<div id="container">
<div id="listSectionContainer">
<div class="dropdownSection">
<div class="dropdownSectionTitle"><i class="fas fa-book-reader"></i>
<p>Getting Started</p>
</div>
<div class="dropdownLinks">
Introduction
Introduction Two
Introduction Three
Introduction Four
Introduction Five
</div>
</div>
<div class="sectionSeparator"></div>
<div class="dropdownSection">
<div class="dropdownSectionTitle"><i class="fas fa-plug"></i>
<p>Second List</p>
</div>
<div class="dropdownLinks">
Introduction
Introduction Two
Introduction Three
Introduction Four
Introduction Five
</div>
</div>
</div>
</div>
Related
It seems very easy to do but I don't find a good solution. I want to have my two like and dislike buttons (that have almost the same properties) on the same line instead of having them on two different lines.
The thing is that there is also an animation that makes their size bigger when the user puts his cursor over them which seems to create some problems with the code I wrote.
div.post{
background-color: #DBDBDB;
}
div.post{
background-color: #DBDBDB;
}
/* dislike button */
.dislike{
width: 35px;
height: 35px;
border-radius: 50px;
background-color: #DB4349;
display: flex;
align-items: center;
justify-content: center;
transition: 0.5s;
overflow: hidden;
text-decoration: none;
}
.dislike:hover{
width: 100px;
transition: 0.5s;
}
.dislikeIcon{
background-size: contain;
padding-top: 3px;
width: 20px;
height: 20px;
}
.dislikeText{
display: none;
margin-left: 10px;
text-decoration: none;
font-family: amble-bold, sans-serif;
color: white;
text-transform: uppercase;
}
.dislike:hover > #dislikeText{
display: flex;
transition: 0.5s;
transition-delay: 1s;
}
/* like button */
.like{
width: 35px;
height: 35px;
border-radius: 50px;
background-color: #34aacf;
display: flex;
align-items: center;
justify-content: center;
transition: 0.5s;
overflow: hidden;
text-decoration: none;
}
.like:hover{
width: 100px;
transition: 0.5s;
}
.likeIcon{
background-size: contain;
padding-top: 3px;
width: 20px;
height: 20px;
}
.likeText{
display: none;
margin-left: 10px;
text-decoration: none;
font-family: amble-bold, sans-serif;
color: white;
text-transform: uppercase;
}
.like:hover > #likeText{
display: flex;
transition: 0.5s;
transition-delay: 1s;
}
<!DOCTYPE html>
<html>
<body>
<div class="post">
<img>
<p>
username
</p>
<p>
this is a placeholder text
</p>
<a class="dislike" href="#disliked">
<img src="dislikeIcon.png" class="dislikeIcon" draggable="false">
<p class="dislikeText" id="dislikeText">dislike</p>
</a>
<a class="like" href="#liked">
<img src="likeIcon.png" class="likeIcon" draggable="false">
<p class="likeText" id="likeText">like</p>
</a>
</div>
</body>
</html>
Just change your like and dislike button classes from display: flex to display: inline-flex; as below.
More on inline vs block elements from Samantha Haming and a nice video explaining the same from Kevin Powell
div.post {
background-color: #DBDBDB;
}
div.post {
background-color: #DBDBDB;
}
/* dislike button */
.dislike {
width: 35px;
height: 35px;
border-radius: 50px;
background-color: #DB4349;
display: inline-flex; /*changed this from display: flex */
align-items: center;
justify-content: center;
transition: 0.5s;
overflow: hidden;
text-decoration: none;
}
.dislike:hover {
width: 100px;
transition: 0.5s;
}
.dislikeIcon {
background-size: contain;
padding-top: 3px;
width: 20px;
height: 20px;
}
.dislikeText {
display: none;
margin-left: 10px;
text-decoration: none;
font-family: amble-bold, sans-serif;
color: white;
text-transform: uppercase;
}
.dislike:hover>#dislikeText {
display: flex;
transition: 0.5s;
transition-delay: 1s;
}
/* like button */
.like {
width: 35px;
height: 35px;
border-radius: 50px;
background-color: #34aacf;
display: inline-flex; /*changed this from display: flex */
align-items: center;
justify-content: center;
transition: 0.5s;
overflow: hidden;
text-decoration: none;
}
.like:hover {
width: 100px;
transition: 0.5s;
}
.likeIcon {
background-size: contain;
padding-top: 3px;
width: 20px;
height: 20px;
}
.likeText {
display: none;
margin-left: 10px;
text-decoration: none;
font-family: amble-bold, sans-serif;
color: white;
text-transform: uppercase;
}
.like:hover>#likeText {
display: flex;
transition: 0.5s;
transition-delay: 1s;
}
<div class="post">
<img>
<p>
username
</p>
<p>
this is a placeholder text
</p>
<a class="dislike" href="#disliked">
<img src="dislikeIcon.png" class="dislikeIcon" draggable="false">
<p class="dislikeText" id="dislikeText">dislike</p>
</a>
<a class="like" href="#liked">
<img src="likeIcon.png" class="likeIcon" draggable="false">
<p class="likeText" id="likeText">like</p>
</a>
</div>
Wrap buttons with div with flexbox. And this solution give you easy way to make gap between buttons
<div class="buttons">
<a class="dislike" href="#disliked">
<img src="dislikeIcon.png" class="dislikeIcon" draggable="false">
<p class="dislikeText" id="dislikeText">dislike</p>
</a>
<a class="like" href="#liked">
<img src="likeIcon.png" class="likeIcon" draggable="false">
<p class="likeText" id="likeText">like</p>
</a>
</div>
.buttons {
display: flex;
gap: 10px
}
https://codepen.io/rachkovartem/pen/gOdppdM
I would like to move the navigation buttons a little bit to the left and separate it from the last button which's Sign Up, at the same time, I need to move the logo a little bit to the right.
body {
margin: 0;
}
header {
background-color: rgb(212, 209, 209);
display: flex;
flex-wrap: wrap;
/* so navbar will go under logo on small smartphones */
align-items: baseline;
padding: 0.5rem;
justify-content: space-between;
}
.logo {
width: 100px;
margin-top: 16px;
cursor: pointer;
}
.nav {
display: flex;
gap: 1rem;
padding: 0;
}
.link {
background: none;
border: none;
text-decoration: none;
color: #777;
font-family: inherit;
font-size: inherit;
cursor: pointer;
padding: 0;
}
.link:hover {
color: black;
}
.dropdown {
position: relative;
}
.dropdown-menu {
position: absolute;
}
#signup {
padding: 10px 25px;
background-color: rgba(0, 136, 169, 1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease 0s;
}
<header>
<img class="logo" src="images/new logo.png" alt="logo">
<nav class="nav">
<div class="dropdown">
<button class="link">Information</button>
<div class="dropdown-menu">Dropdown Content</div>
</div>
Pricing
<button class="link">Login</button>
<button class="link" id="signup">Sign Up</button>
</nav>
</header>
Just add a margin-left to your logo to move it more to the right. If you want more space between the last button and the rest of the content you can also add a margin-left to the .link:last-child If you want elements to space apart then use margin. margin: auto will distribute all remaining space within flexbox and css-grid (just as a side note for the future):
.logo {
margin-left: 25px;
}
.link:last-child {
margin-left: 30px;
}
/* original CSS */
body {
margin: 0;
}
header {
background-color: rgb(212, 209, 209);
display: flex;
flex-wrap: wrap;
/* so navbar will go under logo on small smartphones */
align-items: baseline;
padding: 0.5rem;
justify-content: space-between;
}
.logo {
width: 100px;
margin-top: 16px;
cursor: pointer;
}
.nav {
display: flex;
gap: 1rem;
padding: 0;
}
.link {
background: none;
border: none;
text-decoration: none;
color: #777;
font-family: inherit;
font-size: inherit;
cursor: pointer;
padding: 0;
}
.link:hover {
color: black;
}
.dropdown {
position: relative;
}
.dropdown-menu {
position: absolute;
}
#signup {
padding: 10px 25px;
background-color: rgba(0, 136, 169, 1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease 0s;
}
<header>
<img class="logo" src="images/new logo.png" alt="logo">
<nav class="nav">
<div class="dropdown">
<button class="link">Information</button>
<div class="dropdown-menu">Dropdown Content</div>
</div>
Pricing
<button class="link">Login</button>
<button class="link" id="signup">Sign Up</button>
</nav>
</header>
body {
margin: 0;
}
header {
background-color: rgb(212, 209, 209);
display: flex;
flex-wrap: wrap; /* so navbar will go under logo on small smartphones */
align-items: inherit;
padding: 15px 4%;
justify-content: space-between;
}
.logo {
margin-left: 20px;
cursor: pointer;
}
.nav {
display: flex;
gap: 1rem;
padding: 0;
}
.link {
background: none;
border: none;
text-decoration: none;
color: #777;
font-family: inherit;
font-size: inherit;
cursor: pointer;
padding: 0;
}
.link:hover {
color: black;
}
.link:last-child {
margin: auto;
}
.dropdown {
position: relative;
}
.dropdown-menu {
position: absolute;
}
#signup {
padding: 10px 25px;
background-color: rgba(0,136,169,1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease 0s;
}
If you want to move the logo to the right and signup to the left seperated from other navigation buttons then since its the first and last child, just use:
header:first-child{
float: right;
}
header:last-child{
float: left;
}
To adjust the middle buttons, just give a little bit of margin to position it correctly
give them all a little bit of margin in your css file. That's all I can tell you without seeing your CSS file
I'm trying to make a dropdown menu to my navigation bar but when I hover over the London tab, the dropdown menu is slightly placed to the right. I have no idea as to why this is happening, and I've tried some solutions but they have not been successful.
I dont know how to make the dropdown menu centered so its just below the London tab. Any help or advice would be appriciated!
body {
font-family: Arial;
}
.navbar {
display: flex;
margin-bottom: 0px;
justify-content: center;
gap: 50px;
padding: 1em;
padding-bottom: 4em;
padding-top: 1.5em;
}
.navbar a {
color: white;
padding: 14px 20px;
text-decoration: none;
padding: 2em;
padding-top: 1em;
padding-bottom: 1em;
background-color: #333;
border-radius: 5px;
transition: 0.2s;
}
.navbar a:hover {
background-color: whitesmoke;
color: black;
}
.active-dropdown {
display: flex;
flex-wrap: wrap;
flex-direction: column;
position: relative;
}
.active-dropdown {
color: white;
padding: 14px 20px;
text-decoration: none;
padding: 2em;
padding-top: 1em;
padding-bottom: 1em;
background-color: #04AA6D !important;
border-radius: 5px;
transition: 0.2s;
}
.active-dropdown a{
display: block;
background-color: #11c784 !important;
color: white;
text-decoration: none;
padding: 2em;
padding-top: 1em;
padding-bottom: 1em;
border-radius: 5px;
transition: 0.2s;
}
.active-dropdown > .dropdown-sub{
display: none;
z-index: 1;
flex-direction: column;
position: absolute;
top: 50px;
background: rgb(4, 199, 129);
color: white;
border-radius: 5px;
transition: 0.2s;
width: 100%;
}
.active-dropdown:hover > .dropdown-sub {
display: flex;
}
.dropdown-option a:hover{
background-color: #abcdef !important;
}
.active-dropdown a:hover {
color: white;
transform: scale(1);
}
<!DOCTYPE html>
<html>
<head>
<title>City</title>
<link href="london.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="navbar">
<div class="active-dropdown">
<div class="dropdown-title">London</div>
<div class="dropdown-sub">
<div class="dropdown-option">Overview</div>
<div class="dropdown-option">Wikipedia</div>
<div class="dropdown-option">Pictures</div>
</div>
</div>
<a style="align-self: flex-start" href="#">Paris</a>
<a style="align-self: flex-start" href="#">Tokyo</a>
</div>
The problem is, when position:absolute is used, the default for "right" is not 0.
Source:
What are the default top, left, botton or right values when position:absolute is used?
This should fix the problem:
.active-dropdown > .dropdown-sub {
right: 0px;
}
A very simple solution would be to add this to your code:
.active-dropdown > .dropdown-sub{
display: none;
z-index: 1;
flex-direction: column;
position: absolute;
top: 50px;
background: rgb(4, 199, 129);
color: white;
border-radius: 5px;
transition: 0.2s;
width: 100%;
left: 0px; /* add this */
}
At first, you should add left:0px. I recommend using percentages instead. In the future, you do not need to edit again if the size or padding changes.
.active-dropdown > .dropdown-sub{
display: none;
z-index: 1;
flex-direction: column;
position: absolute;
top: 100%; /* Changed */
left: 0%; /* Changed */
background: rgb(4, 199, 129);
color: white;
border-radius: 5px;
transition: 0.2s;
width: 100%;
}
I've been struggling for hours to center my nav bar.
Here it is :
[[1]: https://i.stack.imgur.com/Wi2RD.png][1]
As you can see, the nav elements are slightly to the left, and not centered to the body. (the body is perfectly centered).
Here's my code :
header {
display: flex;
justify-content: space-between;
align-items: center;
background: linear-gradient(0deg, rgba(164, 174, 228, 0.05), rgba(164, 174, 228, 0.05)), #080B1C;
}
.logohome {
position: relative;
width: 350px;
display: flex;
}
.nav__links a,
.overlay__content a {
font-family: "Montserrat", sans-serif;
font-weight: 500;
color: #edf0f1;
text-decoration: none;
}
.nav__links {
list-style: none;
display: flex;
}
.nav__links li {
margin-right: 18rem;
}
.nav__links li a {
transition: color 0.3s ease 0s;
}
.nav__links li a:hover {
color: #A4AEE4;
}
.NP {
position: absolute;
margin-right: 4.6rem;
right: 0;
color: #24252a;
font-family: "Montserrat";
font-weight: 700;
font-style: normal;
font-size: 20px;
display: flex;
justify-content: center;
align-items: center;
z-index: 1;
}
.profile {
border-radius: 50%;
margin-right: 4rem;
width: 50px;
transition: background-color 0.3s ease 0s;
z-index: 0;
}
.dropbtn {
position: absolute;
margin-left: 4.5rem;
bottom: 2px;
width: 25px;
background-color: transparent;
color: white;
font-size: 16px;
border: none;
cursor: pointer;
}
And the html :
<header>
<img href="google.com" class="logohome" src="images/logo.png"><br><br>
<nav>
<ul class="nav__links">
<li>Mes Favoris </li>
<li>Accueil</li>
<li>Mes Statistiques</li>
<img src="/images/navstate.png" class="navstate">
</ul>
</nav>
<a class="cta" href="#"></a>
<img src="/images/iconeprofile.png" class="profile">
<div class="NP">NP
<div class="dropdown">
</div>
<img src="/images/drop.png" onclick="myFunction()" class="dropbtn">
<div id="myDropdown" class="dropdown-content">
Mon profil
Nous contacter
Déconnexion
</div>
</div>
</header>
what parameters should I change or implement to make it works simply nice? (I don't want to do super responsive bar, but just clean, the purpose is a web app)
This will fix it. All your elements except the last one will have margin-right. Also don't forget to reset ul margin and padding if needed.
.nav__links {
list-style: none;
display: flex;
margin: 0;
padding: 0;
}
.nav__links li:not(:last-child) {
margin-right: 18rem;
}
I have a pestering question I'd like an opinion on. I apologize if this has been answered. I have looked at similar questions, and tried the solutions, but I can't find the one that works for me.
I am working on a personal website right now and I have the home page how I like it, but I am trying to get the experience page to display correctly. Right now, I am trying to have 3-4 "cards" of content. The first two should show up in the main section side by side, and the third (and fourth if necessary) should show up below them as follows"
1 2
3 (centered, ideally the width of the first two items)
OR
1 2
3 4
Currently no matter what I try (clearing, changing the flex direction, etc) I am getting the following with the items squished together.
1 2 3...
I have attached my full styles.css (I apologize for the mess) so someone brighter than me can hopefully help me resolve the problem, and a snippet of my HTML so you can get an idea of how I am using this.
Thank you so much in advance!!!
Styles.css
/* Global Layout Set-up */
{
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
text-align: center;
font-family: 'Roboto', sans-serif;
color: #222;
background: #f7f5f0;
}
/* Link Styles */
a {
text-decoration: none;
color: #0499ff;
}
a:hover {
color: #6633ff;
}
/* Section Styles */
.main-nav {
width: 100%;
background: black;
min-height: 30px;
padding: 10px;
position: fixed;
text-align: center;
margin: auto;
}
.nav {
display: flex;
justify-content: space-around;
font-weight: 700;
list-style-type: none;
margin: 0 auto;
padding: 0;
}
.nav .name {
display: none;
}
.nav li {
padding: 5px 10px 5px 10px;
}
.nav a {
transition: all .5s;
}
.nav a:hover {
color: white
}
header {
text-align: center;
background: url('images/realrocket5.jpg') no-repeat top center ;
background-size: cover;
overflow: hidden;
padding-top: 60px;
}
header {
line-height: 1.5;
}
header .profile-image {
margin-top: 50px;
width: 150px;
height: 150px;
border-radius: 50%;
border: 3px solid black;
transition: all .5s;
}
header .profile-image:hover {
transform: scale(1.2) rotate(360deg);
}
.tag {
background-color: #efefef;
color: black;
padding: 10px;
border-radius: 5px;
display: table;
margin: 10px auto;
}
.location {
background-color: #222;
color: white;
}
.card {
float: left;
max-width: 40%;
margin: 30px;
padding: 20px 40px 20px;
text-align: left;
background: #fff;
border-bottom: 4px solid #ccc;
border-radius: 6px;
}
.card-below{
float: left;
margin: 30px;
padding: 20px 40px 40px;
text-align: left;
}
.card:hover {
border-color: #0399ff;
}
ul.skills {
padding: 0;
text-align: center;
}
.skills li {
border-radius: 6px;
display: inline-block;
background: #ff9904;
color: white;
padding: 5px 10px;
margin: 2px;
}
.skills li:nth-child(odd) {
background: #0399ff;
}
footer {
width: 100%;
min-height: 30px;
padding: 20px 0 40px 20px;
}
footer .copyright {
top: -8px;
margin-right: 20px;
font-size: .75em;
}
footer ul {
list-style-type: none;
margin: 0;
padding: 0;
}
footer ul li {
display: inline-block;
}
a.social {
display: inline-block;
text-indent: -9999px;
margin-left: 5px;
width: 30px;
height: 30px;
background-size: 30px 30px;
opacity: .5;
transition: all .25s;
}
a.twitter {
background-image: url(images/twitter.svg);
}
a.linkedin {
background-image: url(images/linkedin.svg);
}
a.github {
background-image: url(images/github.svg);
}
a.social:hover {
opacity: 1;
}
.clearfix {
clear: both;
}
/* Styles for larger screens */
#media screen and (min-width: 720px) {
.flex {
display: flex;
max-width: 1200px;
justify-content: space-around;
margin: 0 auto;
}
.flex-column {
flex-direction: column;
}
header {
min-height: 450px;
}
.nav {
max-width: 1200px;
}
.nav .name {
display: inline-block;
border: solid #2204ba 3px;
border-radius: 15px;
background-color: #222;
margin-right: auto;
margit-left: left;
text-align: center;
color: #0399ff;
}
.nav .navbar {
display: inline-block;
border: solid #2204ba 3px;
border-radius: 15px;
background-color: #222;
margin-right: 5px;
text-align: center;
color: #0399ff;
}
main {
padding-top: 50px;
}
main p {
line-height: 1.6em;
}
footer {
font-size: 1.3em;
max-width: 1200px;
margin: 40px auto;
}
}
h3 {
color: black;
letter-spacing: 0.5px;
}
.card-title {
text-align: center;
border: solid black 3px;
border-radius: 10px;
background-color: #222;
color: white;
}
HTML
<main class="flex">
<div class="card">
<h2 class="card-title">Card1</h2>
<p>Stuff goes here, up to 500px wide</p>
</div>
<div class="card">
<h2 class="card-title">Card2</h2>
<p>More stuff goes here up to 500px wide</p>
</div>
<div class="card">
<div class="flex-column">
<h2 class="card-title">Card3</h2>
<p>The problem card. This stuff needs to go below card one in its own card.</p>
</div>
</div>
</main>
If I only use two cards per page they appear side by side correctly. When trying to add a third, it just goes beside the last card and I can't for the life of me figure out how to make it go below. Ideally, if using 3 cards the first two would be centered side by side, then the third would be centered below the same width as the first two cards combined. If a 4th card is used, I'd like it to basically be a square. Thank you so much for any input!!!!
.wrap {
width: 500px;
background: gray;
margin: auto;
padding: 10px;
margin-bottom: 20px;
}
.row {
display: flex;
justify-content: center;
}
.box {
padding: 20px;
background: yellow;
min-width: 75px;
flex-grow: 1;
margin: 2px;
text-align: center;
}
<div class="wrap">
<div class="row">
<div class="box">
Box One
</div>
<div class="box">
Box Two
</div>
</div>
<div class="row">
<div class="box">
Box Three
</div>
</div>
</div>
<div class="wrap">
<div class="row">
<div class="box">
Box One
</div>
<div class="box">
Box Two
</div>
</div>
<div class="row">
<div class="box">
Box Three
</div>
<div class="box">
Box Four
</div>
</div>
</div>