I am trying to make cards where the first row and 2 columns are a gif illustrating the card fitting inside a cell with a border. However, there is nothing displaying and the cell just appears empty.
Here is the code I'm using:
.detailsgrid {
display:grid;
grid-template-columns: 35px 1fr;
grid-template-rows: 200px 40px 1fr 35px;
border: solid 1px;
}
.detailsimg {
grid-row-start: 1;
grid-column-start: 1;
grid-row-end: 2;
grid-column-end: 3;
object-fit: cover;
}
<div class="detailsgrid">
<img class="detailsimg" src="https://picsum.photos/100/100" width= 300px>
</div>
<div class="detailsname">
Honing
</div>
<div class="detailsdescription">Straightening the blade so it stays sharp (no material is taken off the blade). </div>
<i class="far fa-clock detailstimeicon"></i>
<div class="detailstime">
This is how often you should do it
</div>
</div>
I tried putting 200px so the gif has space to display but ideally I'd like the area to be determined by GIF size.
A picture to illustrate what I'm trying to achieve:
How could I do that?
You can do something like this:
.detailsgrid {
display: flex;
border: solid 1px;
flex-direction: column;
margin: 5px;
width: 303px;
}
.detailsname {
display: inline-block;
height: 50px;
width: 300px;
background-color: #1E343A;
color: white;
text-align: center;
padding-top: 15px;
}
.detailsdescription {
border: 1px solid red;
display: inline-block;
height: 50px;
width: 300px;
padding: 5px;
}
.detailstime {
margin: 5px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<div class="detailsgrid">
<div class="details"> <img src="http://placekitten.com/301/301" width=300px>
</div>
<div class="detailsname">
Honing
</div>
<div class="detailsdescription">Straightening the blade so it stays sharp (no material is taken off the blade). </div>
<i class="far fa-clock detailstimeicon"></i>
<div class="detailstime">
This is how often you should do it
</div>
</div>
For the second question on the font-icon
.
.detailsgrid {
display: flex;
border: solid 1px;
flex-direction: column;
margin: 5px;
width: 302px;
}
.detailsname {
display: inline-block;
height: 50px;
width: 300px;
background-color: #1E343A;
color: white;
text-align: center;
padding-top: 15px;
}
.detailsdescription {
display: inline;
height: 50px;
width: 300px;
padding: 5px;
}
.timeBlock {
display: flex;
width: 300px;
border-top: 1px solid black;
height: 50px;
position: relative;
}
.fa-clock-o {
height: 50px;
width: 50px;
padding-top: 7px;
padding-left: 7px;
}
.detailstime {
padding-top: 12px;
height: 50px;
margin-left: 5px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<div class="detailsgrid">
<div class="details"> <img src="http://placekitten.com/301/301" width=300px>
</div>
<div class="detailsname">
Honing
</div>
<div class="detailsdescription">Straightening the blade so it stays sharp (no material is taken off the blade). </div>
<div class="timeBlock">
<div class="timeIcon">
<i class="fa fa-clock-o" aria-hidden="true" style="font-size:36px;background-color:#1E343A;color:white;"></i>
</div>
<div class="detailstime">
This is how often you should do it
</div>
</div>
</div>