I am a beginner, I want to ask how to move the user and stars to the bottom?
There is code:
.box-container {
display: grid;
justify-content: center;
grid-template-columns: repeat(auto-fit, minmax(30rem, 1fr));
gap: 9rem;
}
.box-container .box {
text-align: center;
padding: 3rem 5rem;
border-radius: 30px;
box-shadow: 0px 0px 50px 0px rgba(211, 173, 127, 0.2);
background-color: var(--ljub);
}
.box-container .box p {
font-size: 1.6rem;
line-height: 1.8;
color: var(--bela);
padding: 2rem 0;
}
.box-container .box .user {
height: 7rem;
width: 7rem;
border-radius: 50%;
object-fit: cover;
}
.box h3 {
padding: 1rem 0;
font-size: 2rem;
color: var(--bela);
}
.box-container .box .stars i {
font-size: 1.5rem;
color: var(--kafa);
}
<div class="box">
<img src="images/Utisci/quote.png" class="quote" loading="lazy">
<p>TEXT</p>
<img src="images/Utisci/women.png" class="user" loading="lazy">
<h3>NAME</h3>
<div class="stars">
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star-half-alt"></i>
</div>
</div>
If you see any other problem in the code or approach, it will help me a lot!
2
Answers
What you want to do to solve this problem is use flexbox.
First, let’s recognize what you want. You want the quote mark and the text at the top of the container boxes, and you want the avatar image and the name and the stars at the bottom. To do this, first you need to slightly modify your markup to add wrapping div elements.
What you want is for the quote mark and the text to be grouped together, and the avatar picture, the name, and the stars to be grouped together. To do that we wrap them in a div. If are going to possibly want to add styling like margins or padding or something on the wrapper elements, give them class names. If you do not need to add styling to them, you can forgo giving them classes.
Now that these elements are grouped, what you want to do is apply flexbox properties to the box so that the first group sits at the top and the second group sits at the bottom.
First we turn on flexbox properties with
display: flex
. Then we set the direction that the elements will flow, the default isrow
but we want to set it tocolumn
. We don’t need the elements to wrap so we turnflex-wrap
tonowrap
. Then we set how the elements will be defined along the cross-axis of their direction withalign-items
. Since we set theflex-direction
tocolumn
this will set the items in the horizontal center of the box. Then we usejustify-content
to define how the flex child elements will be set along the axis of the direction. Since the direction is column, this is how the items will arrange themselves vertically. We usespace-between
to say that they will have no space on the top or bottom, on the outside of the child elements, and put all available space in between them.If you do this, what you should see is that the quote mark and the review text sit at the top of the box and the name and avatar and the stars will sit at the bottom. The space between them will flex based on how much vertical space the review takes up.
To learn more about flexbox, refer to the flexbox link at the top of this answer or to this cheat sheet guide from CSS-Tricks
You can use this according to given css. Add display flex, and flex direction:column. Also add flex:1 to make it take the full space