1

I'm doing a one page site for a little consulting team, and in the section were the team appears, I can't make to align the justified content with an image that I would like to add in top of the text.

Here is what I have

HTML

<section>
    <h2 class="altura">Equipo</h2>
    <div class="container">
        <div class="teamg">
            <img class="fotoequipo" src="img/brad1.jpg">
            <h3>Ps. Brad Pitt</h3>
            <h4>Associate</h4>
            <p>Lorem ipsum.</p>
        </div>

        <div class="teamg2">
            <img class ="fotoequipo1" src="img/jen1.jpg">
            <h3>Ps. Jennifer Aniston</h3>
            <h4>Associate</h4>
            <p>Lorem Ipsum.</p>
        </div>
    </div>
</section>

CSS

.altura {
    margin: 3vw 20vw 3vw 20vw;
}
.container {
    display: grid;
    grid-template-columns: 20% 20% 20% 20% 20%;
}

.teamg {
    grid-column-start: 2;
}

.teamg img {
    align-content: center;
    height: 180px;
    width: 180px;
    border-radius: 50%;
    border: 5px solid #2b2c35;
}

.fotoequipo {
    align-items: center;
    height: 180px;
    border-radius: 50%;
    border: 5px solid #2b2c35;
}

.teamg2 {
    grid-column-start: 4;
}

.teamg2 img {
    align-content: center;
    height: 180px;
    width: 180px;
    border-radius: 50%;
    border: 5px solid #2b2c35;
}
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
Javier
  • 29
  • 3

3 Answers3

2

you need to center the text like this:

.teamg {
    grid-column-start: 2;
    text-align: center;
  }

and this:

.teamg2 {
   grid-column-start: 4;
   text-align: center;
}

Here is a link of the output

Buddy
  • 10,874
  • 5
  • 41
  • 58
1

So if I understand correctly, you are not happy with the alignment of the text beneath the images - because it 'seems' un-centered.

It's actually perfectly centered, but the text is right aligned - and the image is full width.

Here's a tidied up version of your css/html - maybe this will help.

.altura {
    margin: 3vw 20vw 3vw 20vw;
}
.container {
    display: grid;
    grid-template-columns: 20% 20% 20% 20% 20%;
}

.teamg {
    grid-column-start: 2;
    box-shadow: 0 0 5px grey;
    padding: 5px;
    min-width: 200px;
    text-align: center;
}

.teamg img {
    align-content: center;
    height: 180px;
    width: 180px;
    border-radius: 50%;
    border: 5px solid #2b2c35;
}

.column4 {
    grid-column-start: 4;
}
<section>
    <h2 class="altura">Equipo</h2>
    <div class="container">
        <div class="teamg">
            <img src="https://via.placeholder.com/180">
            <h3>Ps. Brad Pitt</h3>
            <h4>Associate</h4>
            <p>Lorem ipsum.</p>
        </div>

        <div class="teamg column4">
            <img src="https://via.placeholder.com/180">
            <h3>Ps. Jennifer Aniston</h3>
            <h4>Associate</h4>
            <p>Lorem Ipsum.</p>
        </div>
    </div>
</section>
asimovwasright
  • 838
  • 1
  • 11
  • 28
  • Thanks for the feedback! I never tought that the text was not aligned, now I will be more aware of this :) – Javier Apr 04 '20 at 00:01
-2
<center>
    <img src="path/to/your/image/here"/>
</center>
<style>
img{
    object-fit:center;
}
</style>