1

I'm working on styling some pictures and texts. However, I got an issue with P elements that are within the div.texte

It looks like whatever I write in the CSS file, it doesn't want to apply. It works on the H2 (which is within the <p> element !) but not on the P elements. I'm really curious to know what mechanisms are involved to get into this situation. I thank you in advance for any help or suggestion

Please find the HTML below:

<!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <link rel="stylesheet" href="styleSheet.css">
            <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
        </head>
        
        <body>

            <div class="textesEtImages">
                <div class="imagePuisTexte">
                    <img src="https://i.pinimg.com/originals/fe/e1/84/fee18481df61ce4220956dc8f44d09e8.jpg">
                    <div class="texte">
                        <p class="texte2">
                            <h2>The Title</h2><br>
                            BLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLA<br>
                            BLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLA<br>
                            BLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLA<br>
                        </p>
                    </div>
                </div>
                <div class="textePuisImage">
                    <div class="texte">
                        <p class="texte2">
                            <h2>The second title</h2><br>
                            BLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLA<br>
                            BLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLA<br>
                            BLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLA<br>
                            BLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLA<br>
                            BLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLA<br>
                        </p>
                    </div>
                    <img src="https://i.pinimg.com/originals/fe/e1/84/fee18481df61ce4220956dc8f44d09e8.jpg">
                </div>
            </div>
            
        </body>
    </html>

And the CSS

.textesEtImages{
    width: 80vw;
    max-width: 100%;
    margin: auto;
    height:100vh;
    background: white;
    position: relative;
    overflow: hidden;
}


div.imagePuisTexte,div.textePuisImage{
    width: 100%;
    height: 50%;
    overflow: hidden;
}

.textesEtImages img, .textesEtImages div.texte{
    width: 49%;
    float: left;
    position: relative;
    top: 50%;
    left: 25%;
    transform: translate(-50%, -50%);
}

.textesEtImages div.texte{
    box-sizing: border-box;
    padding: 2vh 2vw;
    font-family: sans-serif;
}

div.texte p{
    font-size: 14px;
    color: white;
}

div.texte h2{
    font-size: 20px;
    color: red;
}
Phix
  • 9,364
  • 4
  • 35
  • 62

0 Answers0