简体   繁体   中英

Text not displaying after image

I am trying to make a food app. This is the section of its Home page

<div class="Offer">
        <h1>What We Can Offer</h1>
        <p>from our hearts</p>
        <div class="circle">
          <img class="img-round" alt="" src={require("./images/round/green-plate.jpg")} />
          <p>Healthy</p>
        </div>
        <div class="circle">
          <img class="img-round" alt="" src={require("./images/Food/popsicle.jpg")} />
          <p>Sweet</p>
        </div>
        <div class="circle">
          <img class="img-round" alt="" src={require("./images/Home/man-dough.jpg")} />
          <p>Classic</p>
        </div>
</div>

But all the text in p tags in not appearing.

this I the css

.circle {
  display: inline-block;
  position: relative;
  width: 300px;
  height: 300px;
  overflow: hidden;
  border-radius: 50%;
  margin-left: 125px;
}

circle p{
    font-size: 30px;
    color:black
}


.circle img{
   width: auto;
  height: 100%;
  margin-left: -50px;
}



I want that this text appears after the image

it is looking like this: 在此处输入图像描述

Your <p> elements inside the <div class="circle"> elements are hidden by overflow: hidden . You need to make them siblings. You can simply place them in a wrapper div.

 .circle-wrapper { display: inline-block; }.circle { width: 300px; height: 300px; overflow: hidden; border-radius: 50%; }.circle img{ width: auto; height: 100%; }.circle-wrapper p { font-size: 30px; color:black }
 <div class="Offer"> <h1>What We Can Offer</h1> <p>from our hearts</p> <div class="circle-wrapper"> <div class="circle"> <img class="img-round" alt="" src="https://via.placeholder.com/300" /> </div> <p>Healthy</p> </div> <div class="circle-wrapper"> <div class="circle"> <img class="img-round" alt="" src="https://via.placeholder.com/300" /> </div> <p>Sweet</p> </div> <div class="circle-wrapper"> <div class="circle"> <img class="img-round" alt="" src="https://via.placeholder.com/300" /> </div> <p>Classic</p> </div> </div>

your image height should be less than 100% and then your

text align must be center

 .circle img { width: auto; height: 85%; margin-left: -50px; }.circle p{ text-align:center }

 <div class="Offer"> <h1>What We Can Offer</h1> <p>from our hearts</p> <div class="circle"> <img class="img-round" alt="" src={require("./images/round/green-plate.jpg")} /> <p>Healthy</p> </div> <div class="circle"> <img class="img-round" alt="" src={require("./images/Food/popsicle.jpg")} /> <p>Sweet</p> </div> <div class="circle"> <img class="img-round" alt="" src={require("./images/Home/man-dough.jpg")} /> <p>Classic</p> </div> </div>

That's because the circle's border hides your p text.

You can solve it in few ways:

  • Reduce border-radius percentage
  • Cancel overflow: hidden property
  • text-align: center the p itself - which is the preferable option.

To ease your understanding on how the circle come into an effects, color its background (later just revert this). This way, you can see easily what the problem is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM