Prevent sibling from being pushed using flex - html

I have an image, and I display a text to the right and bottom of it , as can be seen in the first snippet(view snippet in full window). Now I want to add another text, and that it will be to the top right of the image, above the other text, but it pushes the bottom text to the right. I want both texts to be relative to the image, but the last paragraph seems to be relative to the sibling.
(**Sorry about the many html tags, I'm using a css framework also)
.justify-content-end {
align-self: flex-end;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.css" rel="stylesheet"/>
<div class="level">
<div class="level-left">
<div class="level-item">
<figure class="image is-128x128">
<img src="https://bulma.io/images/placeholders/128x128.png">
</figure>
</div>
<div class="level-item justify-content-end">
<p>Hello World</p>
</div>
</div>
</div>
And this is the snippet depicting the problem:
.justify-content-start {
align-self: flex-start;
}
.justify-content-end {
align-self: flex-end;
}
#click {
text-align: center;
width: 128px;
cursor: pointer;
border: 1px solid red;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.css" rel="stylesheet" />
<div class="level">
<div class="level-left">
<div class="level-item">
<figure class="image is-128x128">
<img src="https://bulma.io/images/placeholders/128x128.png">
</figure>
</div>
<div class="level-item justify-content-start">
<label class="label">
<p id="click">Click Me!</p>
</label>
</div>
<div class="level-item justify-content-end">
<p>Hello World</p>
</div>
</div>
</div>

Here is my solution
Had to change your structure
<div class=" par">
<label class="label">
<p id="click">Click Me!</p>
</label>
<p>Name Placeholder</p>
</div>
Then
added this to css
.main .stretch{
align-items: stretch;
}
.par{
display:flex;
flex-direction:column;
justify-content:space-between;
}
.justify-content-start {
align-self: flex-start;
}
.justify-content-end {
align-self: flex-end;
}
.main .stretch {
align-items: stretch;
text-align: center;
}
#click {
text-align: center;
width: 128px;
cursor: pointer;
border: 1px solid red;
margin: auto;
}
.par {
display: flex;
flex-direction: column;
justify-content: space-between;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.css" rel="stylesheet" />
<div class="level main">
<div class="level-left stretch">
<div class="level-item">
<figure class="image is-128x128">
<img src="https://bulma.io/images/placeholders/128x128.png">
</figure>
</div>
<div class=" par">
<label class="label">
<p id="click">Click Me!</p>
</label>
<p>Name Placeholder</p>
</div>
</div>
</div>

I usually dislike position:absolute; but it looks like it could be a fair use here .
.justify-content-start {
align-self: flex-start;
min-height: 1.4em; /* keep room for the absolute child */
}
.justify-content-end {
align-self: flex-end;
}
#click {
text-align: center;
width: 128px;
cursor: pointer;
border: 1px solid red;
}
#media (min-width: 768px) {
#click {
position: absolute;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.css" rel="stylesheet" />
<div class="level">
<div class="level-left">
<div class="level-item">
<figure class="image is-128x128">
<img src="https://bulma.io/images/placeholders/128x128.png">
</figure>
</div>
<div class="level-item justify-content-start">
<label class="label">
<p id="click">Click Me!</p>
</label>
</div>
<div class="level-item justify-content-end">
<p>Hello World</p>
</div>
</div>
</div>

Related

How do i add a title on top of a thumbnail?

It's not my proudest moment to say that I am struggling with this since yesterday, I managed to make my gallery thumbnails look almost like the model in the picture that I uploaded, but I can't add the "image title" section. I managed at some point to put a title and the gray background, but when I hovered on it, only the image moved and not the title. Please help me so I can get rid of this problem once and forever (Thank you for your time):
<head>
<style>
.container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
gap: 20px;
background: rgb(255, 255, 255);
padding: 15px;
}
.box > img {
width: 80%;
display: block;
background-color: cornflowerblue;
border-radius: 12%;
}
.container img:hover {
transform: scale(1.04);
}
</style>
</head>
<body>
<div class="container">
<div class="box">
<img src="placeholder-image.png">
<span>daa</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>Image</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>rrrr</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
</div>
</body>
If you want the hover styling to apply to the title text and the image, just use transform on the .box container hover state instead of only the image with .container img:hover. This way both the <img> and the <span> text will "move as one" since they are both children of the .box parent container. Try this out.
.box {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
}
.box .title {
background: #ddd;
padding: .5rem 1rem;
text-align: center;
width: -webkit-fill-available;
border-bottom-left-radius: .5rem;
border-bottom-right-radius: .5rem;
}
<style>
.container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
gap: 20px;
background: rgb(255, 255, 255);
padding: 15px;
}
img {
max-width: 100%;
}
.box > img {
width: 100%;
display: block;
background-color: cornflowerblue;
border-top-right-radius: 1rem;
border-top-left-radius: 1rem;
/* border-radius: 12%;*/
}
.box:hover {
transform: scale(1.04);
}
</style>
</head>
<body>
<div class="container">
<div class="box">
<img src="https://static.thenounproject.com/png/17840-200.png" alt="some alt text">
<div class="title">
<span>Image Title</span>
</div>
</div>
<div class="box">
<img src="https://static.thenounproject.com/png/17840-200.png" alt="some alt text">
<div class="title">
<span>Image Title</span>
</div>
</div>
<div class="box">
<img src="https://static.thenounproject.com/png/17840-200.png" alt="some alt text">
<div class="title">
<span>Image Title</span>
</div>
</div>
<div class="box">
<img src="https://static.thenounproject.com/png/17840-200.png" alt="some alt text">
<div class="title">
<span>Image Title</span>
</div>
</div>
<div class="box">
<img src="https://static.thenounproject.com/png/17840-200.png" alt="some alt text">
<div class="title">
<span>Image Title</span>
</div>
</div>
</div>
</body>

Break line using Flex keeping elements centered

This is another CSS Flex question, I'm sorry but I've been struggling a lot using Flex, I'm trying to make a kind of slider, in which it will have a left and right arrow and elements in between, like so:
The problem I'm facing is that in certain number of elements I need to break a line, keeping the alignment center both vertically and horizontally, like this: (paint pro editing)
I can't find a way to do this, I'm lost.
This is my actual code for the first image:
HMTL:
<div class="main allin">
<div class="left-arrow">
<i class="material-icons">keyboard_arrow_left</i>
</div>
<div class="flex-con ">
<div class="item-1">
<img src="https://via.placeholder.com/250" />
</div>
<div class="item-2">
<img src="https://via.placeholder.com/250" />
</div>
<div class="item-3">
<img src="https://via.placeholder.com/250" />
</div>
</div>
<div class="right-arrow">
<i class="material-icons">keyboard_arrow_right</i>
</div>
</div>
<div class="main break">
<div class="left-arrow">
<i class="material-icons">keyboard_arrow_left</i>
</div>
CSS:
.main{
display:flex;
justify-content: center;
align-items: center;
}
.flex-con{
display:flex;
align-items: center;
}
.flex-con div{
padding:20px;
}
And this is a CodePen
How can I achieve this? thanks.
Put all your item-x elements within the same flex-con wrapper.
Then, simply add the following properties:
flex-wrap: wrap; // to wrap its children into multiple lines
justify-content: center; // to center horizontally
.main {
display: flex;
justify-content: center;
align-items: center;
}
.flex-con {
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: center;
}
.flex-con div {
padding: 20px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/material-design-icons/3.0.1/iconfont/material-icons.min.css" />
<div class="main break">
<div class="left-arrow">
<i class="material-icons">keyboard_arrow_left</i>
</div>
<div class="flex-con ">
<div class="item-1">
<img src="https://via.placeholder.com/250" />
</div>
<div class="item-2">
<img src="https://via.placeholder.com/250" />
</div>
<div class="item-3">
<img src="https://via.placeholder.com/250" />
</div>
<div class="item-4">
<img src="https://via.placeholder.com/250" />
</div>
<div class="item-5">
<img src="https://via.placeholder.com/250" />
</div>
</div>
<div class="right-arrow">
<i class="material-icons">keyboard_arrow_right</i>
</div>
</div>
Click Full page for better demonstration.

Flex card with two rows

I have one card which I am using for images. I want to have two rows in my card for images. Concept behind this is, I am getting different product's images which i am showing properly in one line. On next line, i want to show all images from very first product. But i am not align it properly.
Currenlty, I am getting all the images in one row. I want to show all the images from class contain on next line.
Can someone help me with this CSS stuff? Below is my code.
HTML :
.image-card {
width: 100%;
display: flex;
overflow-x: scroll;
flex-direction: row;
}
.contain {
display: flex;
flex-direction: row;
}
.child {
display: flex;
flex-direction: row;
height: 100px;
}
.child>img {
width: 100px;
height: 100px;
}
img {
width: 100px;
height: 150px;
}
<md-card class="image-card">
<div *ngFor="let url of this.urls">
<img [src]="url" (click)="openDialog(url)">
<div class="button-row">
<a md-raised-button (click)="goToProduct(url.slice(59, 64))">
{{ url.slice(59, 66) }}
</a>
</div>
</div>
<div class="contain">
<div class="child">
<img [src]="this.secondImage">
<img [src]="this.thirdImage">
<img [src]="this.fourthImage">
<img [src]="this.logo">
<img [src]="this.brandImage">
</div>
</div>
</md-card>
Use flex as suggested below
.image-card {
width: 100%;
display: flex;
overflow-x: scroll;
flex-direction: column;
}
.image-card .abc {
width: 100%;
max-height: 225px;
overflow-x: auto;
margin-top: 10px;
}
.contain {
display: flex;
flex-direction: row;
}
.child {
display: flex;
flex-direction: row;
height: 100px;
}
.child>img {
width: 100px;
height: 100px;
}
img {
width: 100px;
height: 150px;
}
<md-card>
<div class="image-card">
<div *ngFor="let url of this.urls" class="abc">
<div>
<img [src]="url" (click)="openDialog(url)">
<div class="button-row">
<a md-raised-button (click)="goToProduct(url.slice(59, 64))">
{{ url.slice(59, 66) }}
</a>
</div>
</div>
<div class="contain">
<div class="child">
<img [src]="this.secondImage">
<img [src]="this.thirdImage">
<img [src]="this.fourthImage">
<img [src]="this.logo">
<img [src]="this.brandImage">
</div>
</div>
</div>
<div *ngFor="let url of this.urls" class="abc">
<div>
<img [src]="url" (click)="openDialog(url)">
<div class="button-row">
<a md-raised-button (click)="goToProduct(url.slice(59, 64))">
{{ url.slice(59, 66) }}
</a>
</div>
</div>
<div class="contain">
<div class="child">
<img [src]="this.secondImage">
<img [src]="this.thirdImage">
<img [src]="this.fourthImage">
<img [src]="this.logo">
<img [src]="this.brandImage">
</div>
</div>
</div>
<div *ngFor="let url of this.urls" class="abc">
<div>
<img [src]="url" (click)="openDialog(url)">
<div class="button-row">
<a md-raised-button (click)="goToProduct(url.slice(59, 64))">
{{ url.slice(59, 66) }}
</a>
</div>
</div>
<div class="contain">
<div class="child">
<img [src]="this.secondImage">
<img [src]="this.thirdImage">
<img [src]="this.fourthImage">
<img [src]="this.logo">
<img [src]="this.brandImage">
</div>
</div>
</div>
</div>
</md-card>
Wrap ngFor with div and apply class="image-card" to it
.image-card {
width: 100%;
display: flex;
overflow-x: scroll;
flex-direction: row;
}
.contain {
display: flex;
flex-direction: row;
}
.child {
display: flex;
flex-direction: row;
height: 100px;
}
.child>img {
width: 100px;
height: 100px;
}
img {
width: 100px;
height: 150px;
}
<md-card class="">
<div class="image-card">
<div *ngFor="let url of this.urls">
<img [src]="url" (click)="openDialog(url)">
<div class="button-row">
<a md-raised-button (click)="goToProduct(url.slice(59, 64))">
{{ url.slice(59, 66) }}
</a>
</div>
</div>
</div>
<div class="contain">
<div class="child">
<img [src]="this.secondImage">
<img [src]="this.thirdImage">
<img [src]="this.fourthImage">
<img [src]="this.logo">
<img [src]="this.brandImage">
</div>
</div>
</md-card>

How to get the horizontal-card-footer div right below other div and not at right

I want to have a structure like this:
But its not working, the image, date, title and subtitle are ok, but then do you know how to put the Image title right below the image and the view and save links below the other texts with the same margin-left of 1rem?
I have here the Example: http://jsfiddle.net/tyyj57gs/6/, the issue should be because the horizontal-card div have display flex but Im not having sucess solving that issue.
Html:
<div class="container pb-4">
<div class="row">
<div class="col-lg-3">
<div class="horizontal-card">
<img src="http://via.placeholder.com/200x100"/>
<div class="horizontal-card-body">
<span class="card-text">Date</span>
<h4 class="card-title">Title</h4>
<span class="card-text">Subtitle</span>
</div>
<div class="horizontal-card-footer">
<span>Image Title</span>
<a class="card-text status">#View</a>
<a class="card-text status">#Save</a>
</div>
</div>
</div>
CSS
.horizontal-card{
display: flex;
border:1px solid gray;
margin-bottom:1rem;
img{
width: 200px;
height: 100px;
border-bottom: 2px solid red;
}
.horizontal-card-body{
display: flex;
flex-direction: column;
margin-left:1rem;
}
}
I did this by using display:inline-block instead of the flex box you had. The sections are broken into two rows. Add style as you wish.
HTML:
<div class="card">
<div class="row">
<div class="innerLeft">
<img src="http://via.placeholder.com/200x100"/>
</div>
<div class="innerRight">
<div class="horizontal-card-footer">
<span class="card-text">Date</span>
<h4 class="card-title">Title</h4>
<span class="card-text">Subtitle</span>
</div>
</div>
</div>
<div class="row">
<div class="innerLeft">
<p>Image Title</p>
</div>
<div class="innerRight">
<a class="card-text status">#View</a>
<a class="card-text status">#Save</a>
</div>
</div>
</div>
CSS:
.card {
display:block;
width:100%;
max-width:800px;
}
img {
width: 100%;
height: auto;
border-bottom: 2px solid orange;
}
.innerLeft {
display:inline-block;
margin-right:-4px;
vertical-align:top;
width:30%;
text-align:center;
padding:5px;
}
.innerRight {
display:inline-block;
vertical-align:top;
width:70%;
text-align:left;
padding:5px;
}
.card-text {
display:inline-block;
}
FIDDLE : http://jsfiddle.net/tyyj57gs/9/
You can create the layout you want using flexbox.
In the snippet below I have restructured your .horizontal-card into .card-left and .card-right.
.horizontal-card {
display: flex;
border: 1px solid gray;
margin-bottom: 1rem;
}
.card-left,
.card-right {
display: flex;
flex-direction: column;
}
.card-right {
width: 100%;
}
.card-left span {
background: orange;
flex: 1;
display: flex;
justify-content: center;
align-items: center;
}
.horizontal-card-body,
.horizontal-card-footer {
padding-left: 1em;
}
img {
width: 200px;
height: 100px;
}
.horizontal-card-footer {
/* Add to ensure the footer is pinned to the bottom of the card */
margin-top: auto;
border-top: 1px solid grey;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet">
<div class="container pb-4">
<div class="row">
<div class="col-lg-3">
<div class="horizontal-card">
<div class="card-left">
<img src="http://via.placeholder.com/200x100" />
<span>Image Title</span>
</div>
<div class="card-right">
<div class="horizontal-card-body">
<span class="card-text">Date</span>
<h4 class="card-title">Title</h4>
<span class="card-text">Subtitle</span>
</div>
<div class="horizontal-card-footer">
<a class="card-text status">#View</a>
<a class="card-text status">#Save</a>
</div>
</div>
</div>
</div>
<div class="container pb-4">
<div class="row">
<div class="col-lg-3">
<div class="horizontal-card">
<div class="card-left">
<img src="http://via.placeholder.com/200x100" />
<span>Image Title</span>
</div>
<div class="card-right">
<div class="horizontal-card-body">
<span class="card-text">Date</span>
<h4 class="card-title">Title</h4>
<span class="card-text">I am a card with a longer subtitle. I am a card with a longer subtitle. I am a card with a longer subtitle. I am a card with a longer subtitle. </span>
</div>
<div class="horizontal-card-footer">
<a class="card-text status">#View</a>
<a class="card-text status">#Save</a>
</div>
</div>
</div>
</div>
<div class="container pb-4">
<div class="row">
<div class="col-lg-3">
<div class="horizontal-card">
<div class="card-left">
<img src="http://via.placeholder.com/200x100" />
<span>Image Title</span>
</div>
<div class="card-right">
<div class="horizontal-card-body">
<span class="card-text">Date</span>
<h4 class="card-title">Title</h4>
<span class="card-text"></span>
</div>
<div class="horizontal-card-footer">
<a class="card-text status">#View</a>
<a class="card-text status">#Save</a>
</div>
</div>
</div>
</div>
Here is my version of the image. Let me know if there are any issues, I have used position absolute for the footer's position.
For the SCSS version of the CSS refer the fiddle, else refer the snippet below!
JSFiddle Demo
.horizontal-card {
position: relative;
display: flex;
border: 1px solid gray;
margin-bottom: 1rem;
}
.horizontal-card img {
width: 200px;
height: 130px;
border-bottom: 30px solid orange;
}
.horizontal-card .horizontal-card-body {
display: flex;
flex-direction: column;
margin-left: 1rem;
}
.horizontal-card .horizontal-card-footer {
position: absolute;
left: 0px;
right: 0px;
bottom: 0px;
height: 30px;
display: flex;
align-items: center;
}
.horizontal-card .horizontal-card-footer span {
width: 200px;
display: inline-block;
}
.horizontal-card .horizontal-card-footer a {
margin-left: 10px;
}
<div class="container pb-4">
<div class="row">
<div class="col-lg-3">
<div class="horizontal-card">
<img src="http://via.placeholder.com/200x100" />
<div class="horizontal-card-body">
<span class="card-text">Date</span>
<h4 class="card-title">Title</h4>
<span class="card-text">Subtitle</span>
</div>
<div class="horizontal-card-footer">
<span>Image Title</span>
<a class="card-text status">#View</a>
<a class="card-text status">#Save</a>
</div>
</div>
</div>

Flex grid not aligning

I have a grid I have built out of flex boxes. Some of the grid is made of squares, with two rectangles. I can't seem to get the boxes to align correctly, using flexbox with flex-grow, or manually setting the box heights. The goal is to have them all line up with equal margins between the entire grid. Here is the grid code:
.project-grid { height: 1400px; padding: 80px 20px; }
.project-grid .column { width:33.33%; margin-left:10px; flex-direction:column; margin-top:-10px; }
.project-grid .column:first-child { margin-left:0; }
.project-grid .column .box {
margin-top:10px;
background-color:blue;
height: 400px;
background-size:cover;
background-repeat: no-repeat;}
.project-grid .column .box.tall { height:800px; }
.project-grid .column a .box > p {
font-family: $lato;
color: $white;
font-size: 24px;}
.flex { display:flex;}
<div class="project-grid flex">
<div class="flex column">
<a href="/hospitality">
<div class="box" style="background-image: url('');" <a href="/projects">
<p>Hospitality</p>
</div>
</a>
<a href="/rennovation-repurpose">
<div class="box tall" style="background-image: url('');">
<p>Rennovation/ Repurpose</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/automotive">
<div class="box" style="background-image: url('');">
<p>Automotive</p>
</div>
</a>
<a href="/serenbe">
<div class="box" style="background-image: url('');">
<p>Serenbe</p>
</div>
</a>
<a href="/retail-office">
<div class="box" style="background-image: url('') ;">
<p>Retail/ Office</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/multi-family-mixed-use">
<div class="box tall" style="background-image: url('');">
<p>Multi-Family/ Mixed Use</p>
</div>
</a>
<a href="/education-places-of-worship">
<div class="box" style="background-image: url('');">
<p>Education/ Places of Worship</p>
</div>
</a>
</div>
</div>
CSS
For easy viewing, here is a codepen I've made: https://codepen.io/bsquared/pen/zdPqPJ
As commented, if you involved <a> in your flex layout and also to draw the background, you can achieve the visual you look for.
a {
/*with no fix height so it can be spread evenly if needed*/
background: blue;
/* draw bg here it will include children area and further if needed to even the visual */
margin: 10px;
/* set margins here */
color: white;
}
/* flex layout and sizing */
.flex,
a {
display: flex;
}
.column,
a {
flex-direction: column;
flex: 1;/* make fill entire space left if any */
}
.box {
height: 400px;
}
.tall {
height: 800px;
}
<div class="project-grid flex">
<div class="flex column">
<a href="/hospitality">
<div class="box" style="background-image: url('');"><!-- background-image is to be send & set to the parent A -->
<p>Hospitality</p>
</div>
</a>
<a href="/rennovation-repurpose">
<div class="box tall" style="background-image: url('');">
<p>Rennovation/ Repurpose</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/automotive">
<div class="box" style="background-image: url('');">
<p>Automotive</p>
</div>
</a>
<a href="/serenbe">
<div class="box" style="background-image: url('');">
<p>Serenbe</p>
</div>
</a>
<a href="/retail-office">
<div class="box" style="background-image: url('') ;">
<p>Retail/ Office</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/multi-family-mixed-use">
<div class="box tall" style="background-image: url('');">
<p>Multi-Family/ Mixed Use</p>
</div>
</a>
<a href="/education-places-of-worship">
<div class="box" style="background-image: url('');">
<p>Education/ Places of Worship</p>
</div>
</a>
</div>
</div>
If you want to keep heights, then you need to mind the amounts of margins all together with eights of elements in each column :
example
.project-grid { height: 1400px; padding: 80px 20px; }
.project-grid .column { width:33.33%; margin-left:10px; flex-direction:column; margin-top:-10px; }
.project-grid .column:first-child { margin-left:0; }
.project-grid .column .box {
margin-top:10px;
background-color:blue;
height: 400px;
background-size:cover;
background-repeat: no-repeat;}
.project-grid .column .box.tall { height:824px; }
.project-grid .column a .box > p {
font-family: $lato;
color: $white;
font-size: 24px;}
.flex { display:flex;}
<div class="project-grid flex">
<div class="flex column">
<a href="/hospitality">
<div class="box" style="background-image: url('');" >
<p>Hospitality</p>
</div>
</a>
<a href="/rennovation-repurpose">
<div class="box tall" style="background-image: url('');">
<p>Rennovation/ Repurpose</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/automotive">
<div class="box" style="background-image: url('');">
<p>Automotive</p>
</div>
</a>
<a href="/serenbe">
<div class="box" style="background-image: url('');">
<p>Serenbe</p>
</div>
</a>
<a href="/retail-office">
<div class="box" style="background-image: url('') ;">
<p>Retail/ Office</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/multi-family-mixed-use">
<div class="box tall" style="background-image: url('');">
<p>Multi-Family/ Mixed Use</p>
</div>
</a>
<a href="/education-places-of-worship">
<div class="box" style="background-image: url('');">
<p>Education/ Places of Worship</p>
</div>
</a>
</div>
</div>
CSS
The p tags, which has margins top and bottom by defaults, are pushing the boxes up. You have to use overflow: auto; on the parent div to prevent it from happening.
.project-grid .column .box {
// ...
overflow: auto;
}
Full working code:
.project-grid {
height: 1400px;
padding: 80px 20px;
}
.project-grid .column {
width: 33.33%;
margin-left: 10px;
flex-direction: column;
margin-top: -10px;
}
.project-grid .column:first-child {
margin-left: 0;
}
.project-grid .column .box {
margin-top: 10px;
background-color: blue;
height: 400px;
background-size: cover;
background-repeat: no-repeat;
overflow: auto;
}
.project-grid .column .box.tall {
height: 800px;
}
.project-grid .column a .box>p {
font-family: $lato;
color: $white;
font-size: 24px;
}
.flex {
display: flex;
}
<div class="project-grid flex">
<div class="flex column">
<a href="/hospitality">
<div class="box" style="background-image: url('');" <a href="/projects">
<p>Hospitality</p>
</div>
</a>
<a href="/rennovation-repurpose">
<div class="box tall" style="background-image: url('');">
<p>Rennovation/ Repurpose</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/automotive">
<div class="box" style="background-image: url('');">
<p>Automotive</p>
</div>
</a>
<a href="/serenbe">
<div class="box" style="background-image: url('');">
<p>Serenbe</p>
</div>
</a>
<a href="/retail-office">
<div class="box" style="background-image: url('') ;">
<p>Retail/ Office</p>
</div>
</a>
</div>
<div class="flex column">
<a href="/multi-family-mixed-use">
<div class="box tall" style="background-image: url('');">
<p>Multi-Family/ Mixed Use</p>
</div>
</a>
<a href="/education-places-of-worship">
<div class="box" style="background-image: url('');">
<p>Education/ Places of Worship</p>
</div>
</a>
</div>
</div>
CSS