【问题标题】:Aligning figcaption and figure tags on the same line在同一行对齐 figcaption 和 figure 标签
【发布时间】:2021-05-10 12:50:17
【问题描述】:

就像标题所说的那样,我添加了 figcaption 和 figure 标签来为我的图片添加标题。字幕显示,但每张图片都显示在新行上。在添加 figure 和 figcation 标签之前,我将它们弯曲并将它们放在行方向上,它们在同一条线上。任何人都可以提供见解。顺便说一下,我正在为此使用 repl.it IDE。我尝试添加图像但告诉我错误

.img{
        display: flex;
        flex-direction: row;
        float: left;
        background-color: #626B63;
      }
//code for my image.

//code for the image captions
<figure>
    <img src="https://thepienews.com/wp-content/uploads/2017/12/Screen-Shot-2017-12-05-at-15.40.31-860x375.png"  width= "200" height="200" style="padding: 3ch;">
 <figcaption>Bookings</figcaption>
    </figure>
<figure>
    <img src= "https://www.debatingeurope.eu/wp-content/uploads/2013/01/degrees.png"  width= "200" height="200" style="padding: 3ch; ">
     <figcaption>Bookings</figcaption>
    </figure>
<figure>
     <img src="https://cdn3.vectorstock.com/i/1000x1000/62/77/ticket-travel-airline-dollar-money-vector-12556277.jpg" width= "200" height="200" style="padding: 3ch; " >
     <figcaption>Bookings</figcaption>
    </figure>

.img {
  display: flex;
  flex-direction: row;
  float: left;
  background-color: #626B63;
}
<!-- code for my image. -->

<!-- code for the image captions -->
<figure>
  <img src="https://thepienews.com/wp-content/uploads/2017/12/Screen-Shot-2017-12-05-at-15.40.31-860x375.png" width="200" height="200" style="padding: 3ch;">
  <figcaption>Bookings</figcaption>
</figure>
<figure>
  <img src="https://www.debatingeurope.eu/wp-content/uploads/2013/01/degrees.png" width="200" height="200" style="padding: 3ch; ">
  <figcaption>Bookings</figcaption>
</figure>
<figure>
  <img src="https://cdn3.vectorstock.com/i/1000x1000/62/77/ticket-travel-airline-dollar-money-vector-12556277.jpg" width="200" height="200" style="padding: 3ch; ">
  <figcaption>Bookings</figcaption>
</figure>

【问题讨论】:

    标签: html css image tags figure


    【解决方案1】:

    在这里,我添加了一个带有 flex 的父容器以并排对齐 See more about flex。 Bcoz,图形标签是一个块元素,所以需要全宽。

    并为具有一些默认边距的图形标签设置margin: 0

    .container {
      display: flex;
      flex-wrap: wrap
    }
    .container figure {
      margin: 0;
      text-align: center
    }
    .img{
      display: flex;
      flex-direction: row;
      float: left;
      background-color: #626B63;
    }
    <div class="container">
    <figure>
        <img src="https://thepienews.com/wp-content/uploads/2017/12/Screen-Shot-2017-12-05-at-15.40.31-860x375.png"  width= "200" height="200" style="padding: 3ch;">
     <figcaption>Bookings</figcaption>
        </figure>
    <figure>
        <img src= "https://thepienews.com/wp-content/uploads/2017/12/Screen-Shot-2017-12-05-at-15.40.31-860x375.png"  width= "200" height="200" style="padding: 3ch; ">
         <figcaption>Bookings</figcaption>
        </figure>
    <figure>
         <img src="https://thepienews.com/wp-content/uploads/2017/12/Screen-Shot-2017-12-05-at-15.40.31-860x375.png" width= "200" height="200" style="padding: 3ch; " >
         <figcaption>Bookings</figcaption>
    </figure>
    </div>

    【讨论】:

    • 所以我试了一下。最后一张图片一直在第二张下面。那就是它移动到另一行,直接在第二行之下。
    • 不低于第二个。它应该在第一张图片下显示为我的 sn-p。不是吗?只需运行我的 sn-p 并检查
    • 是的,它在你的 sn-p 上,但当我在我的文件上运行它时却没有。我猜其他地方有错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-28
    • 2022-11-08
    • 2017-12-15
    • 2012-07-12
    • 2014-08-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多