This question already has answers here:
How can I wrap text around a non rectangular image?
                                
                                    (4个答案)
                                
                        
                                2年前关闭。
            
                    
我在图像上添加了边框以替换丢失的文件。在“日托”下,圆形<img>.curve)不允许文本环绕。据我所知,我在CSS中有正确的代码。问题是什么?



@charset "UTF-8";

/* CSS Document */

.banner img {
  width: 100%;
  height: 300px;
  border-style: solid;
}

.badge img {
  float: left;
  width: 250px;
  border-style: solid;
  height: 150px;
}

.mission {
  padding-top: 25px;
}

body {
  margin: 0;
}

.wrapper {
  margin: auto;
  width: 1000px;
}

nav {
  background-color: #537B80;
  color: white;
  text-align: center;
}

nav a {
  padding: 15px 40px 15px 40px;
  display: inline-block;
}

img {
  display: block;
  margin: auto;
}

header p {
  width: 55%;
  float: left;
  margin: 30px 30px 0 75px;
  text-align: center;
  font-size: 20px;
}

.daycare {
  clear: both;
}

.daycare h1 {
  float: right;
  color: #537B80;
}

.daycare hr {
  float: left;
  border-width: 4px;
  border-style: solid;
  color: #dde678;
  width: 83%;
  margin-top: 36px;
}

.curve {
  width: 300px;
  height: 300px;
  float: left;
  shape-outside: circle();
  border-radius: 50%;
  margin: 15px 0 0 0;
  border-style: solid;
}

.daycare p {
  text-align: left;
  margin: 10px 0 0 7px;
  width: 65%;
  float: left;
}

<div class="wrapper">

  <header>
    <div class="banner"><img src="img/Banner.png"></div>

    <nav>
      <a>Day Care</a><a>Grooming</a><a>Spa</a><a>Self Wash</a>
    </nav>

    <div class="mission">
      <p>Every dog is unique - especially your dog! Visit Lucky's today for open play dog daycare, overnight boarding or spa services and experience personalized care and exceptional customer service. Our convenient live webcams offer a peek into your dog's
        day and peace of mind that they're having the time of their life with their canine friends and our well-trained, loving staff.</p>
      <div class="badge"> <img src="img/Badge.png"></div>
    </div>

    <div class="daycare">
      <hr>
      <h1>Day Care</h1>
      <img src="img/daycare.png" alt="daycare" class="curve">
      <p>7am: Happy dogs begin to arrive for a full day of play and fun</p>
      <p>7-12pm: Open play time: romping, sniffing and lounging</p>
      <p>12-2pm: A well-deserved nap</p>
      <p>2-7pm: Back out for more play before being picked up by Mom or Dad</p>
      <p>Dogs left home alone during the day may experience separation anxiety or display undesirable behavioral issues such as chewing and excessive barking. These can occur when a dog lacks sufficient exercise and socialization. Dog daycare is your answer!
        Drop your dog off at Luckys and they'll spend the day socializing with other dogs, interacting with our well-trained staff and burning off energy. At the end of the day, you'll pick-up a happy and delightfully tired pup. Some dogs visit every
        day, others just a couple of times a month. Every dog is unique and we're happy to discuss the best play schedule to suit your dog's needs, as well as your busy schedule, budget and life-style.</p>
    </div>

  </header>

</div>





View on CodePen

最佳答案

从段落中删除浮点数。



.curve {
  width: 300px;
  height: 300px;
  float: left;
  shape-outside: circle();
  border-radius: 50%;
  margin: 15px;
  border-style: solid;
}

.daycare p {
  text-align: left;
  margin: 10px 0 0 7px;
}

<div class="daycare">
  <img src="http://www.placebacon.net/300/300" alt="daycare" class="curve">
  <p>7am: Happy dogs begin to arrive for a full day of play and fun</p>
  <p>7-12pm: Open play time: romping, sniffing and lounging</p>
  <p>12-2pm: A well-deserved nap</p>
  <p>2-7pm: Back out for more play before being picked up by Mom or Dad</p>
  <p>Dogs left home alone during the day may experience separation anxiety or display undesirable behavioral issues such as chewing and excessive barking. These can occur when a dog lacks sufficient exercise and socialization. Dog daycare is your answer!
    Drop your dog off at Luckys and they'll spend the day socializing with other dogs, interacting with our well-trained staff and burning off energy. At the end of the day, you'll pick-up a happy and delightfully tired pup. Some dogs visit every day,
    others just a couple of times a month. Every dog is unique and we're happy to discuss the best play schedule to suit your dog's needs, as well as your busy schedule, budget and life-style.</p>
</div>

关于html - 无法获取文字以环绕圆形图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49538577/

10-11 23:25