New dev, and my figcaption bug, and i dont know why

53 Views Asked by At

sorry in advance for my english,

I have to reproduce this original

But I do this : my solution

Here it's my code :

div.psp div.picture-left img {
    
    width: 45%;
    margin-right: 1em;
    float:left;

}



div.psp div.picture-left figure figcaption {
    font-size: .7em;
}
<h2>Put some pictures</h2>
        <div class="psp">
            <div class="picture-left">
                <figure>
                    <img src="images/cat.jpg" title="A nice and cute cat" alt="white and gray cat looking at you, with his yellow and green eyes" />
                    <figcaption>A cat, just to keep the context of the website.</figcaption>
                </figure>
            </div>
            <div class="tleft">
                <p>
                    We're not looking at a novel by Stephenie Meyer, this is a <span class="mfw">motherfuckingwebsite</span>.
                    Add some relevant pictures to give a little bit of context, or to cheer up the reader.
                    Do you really like to waste the power of technology that we have nowadays? Come on, you're using a
                    web browser on a computer, you're not reading a book on a Kindle.
                </p>

                <p>The website shouldn't be overfilled with pictures, but it should make the user happy while reading your nonsense words.</p>

                <p>You see the picture of this cute cate? He's happy, and you should be too.</p>
            </div>
        </div>

I dont know why my figcaption move like that.

I thank you in advance.

2

There are 2 best solutions below

0
On BEST ANSWER

change your IMG Style Like this

div.psp div.picture-left img {
    
    width: 100%;
    margin-right: 1em;
    float:left;

}

then add css class .picture-left like this

.picture-left {
width:45%;
}

then add CSS class .psp like this


.psp{
    display: flex;
}

try this if you have any doubt comment me

and don't use bad words on public platform posts✌

div.psp div.picture-left img {
    
    width: 100%;
    margin-right: 1em;
    float:left;

}

.picture-left {
width:45%;
}
.psp{
    display: flex;
}

div.psp div.picture-left figure figcaption {
    font-size: .7em;
}
<h2>Put some pictures</h2>
<div class="psp">
<div class="picture-left">
  <figure>
<img src="https://images.pexels.com/photos/104827/cat-pet-animal-domestic-104827.jpeg" title="A nice and cute cat" alt="white and gray cat looking at you, with his yellow and green eyes" />
<figcaption>A cat, just to keep the context of the website.</figcaption>
</figure>
</div>
<div class="picture-left">
<p>
We're not looking at a novel by Stephenie Meyer, this is a <span class="mfw">motherfuckingwebsite</span>.
                    Add some relevant pictures to give a little bit of context, or to cheer up the reader.
                    Do you really like to waste the power of technology that we have nowadays? Come on, you're using a
                    web browser on a computer, you're not reading a book on a Kindle.
                </p>

                <p>The website shouldn't be overfilled with pictures, but it should make the user happy while reading your nonsense words.</p>

                <p>You see the picture of this cute cate? He's happy, and you should be too.</p>
            </div>
            </div>

4
On

It happned because you floated the image to left.

Thats why it is going on the side.

Just don't select the img tag, Like this:

div.psp div.picture-left { /* <---- Just remove the img */
    
    width: 45%;
    margin-right: 1em;
    float:left;

}



div.psp div.picture-left figure figcaption {
    font-size: .7em;
}