简体   繁体   English

如何将两张图片与标题并排放置

[英]How do you put two images side by side with captions

I am trying to put two images side by side in Jupyter's markdown.我试图在 Jupyter 的 markdown 中并排放置两个图像。 We can use html but I am unable to put two images side by side with caption .我们可以使用html但我无法将两个图像与标题并排放置。 I tried every option in here but did not work.我在这里尝试了所有选项,但没有奏效。

<figure>
<img src='aaa.png' width="350" height="350" align="center"/>
    <figcaption align = "center"><b>Fig 2.5; Courtesy of Linear Algebra: Theory, Intuition, Code by Mike X Cohen</b></figcaption>
<img src='bbb.png' width="350" height="350" align="center"/>
    <figcaption align = "center"><b>Fig 2.3; Courtesy of Linear Algebra: Theory, Intuition, Code by Mike X Cohen</b></figcaption>
</figure>

Check this out看一下这个

 * { box-sizing: border-box; }.column { float: left; width: 33.33%; padding: 5px; } /* Clearfix (clear floats) */.row::after { content: ""; clear: both; display: table; } /* Responsive layout - makes the three columns stack on top of each other instead of next to each other */ @media screen and (max-width: 500px) {.column { width: 100%; } }
 <div class="row"> <div class="column"> <img src="https://www.w3schools.com/howto/img_snow.jpg" alt="Snow" style="width:100%"> <figcaption>Fig.1 - Trulli</figcaption> </div> <div class="column"> <img src="https://www.w3schools.com/howto/img_forest.jpg" alt="Forest" style="width:100%"> <figcaption>Fig.2 - Puglia</figcaption> </div> <div class="column"> <img src="https://www.w3schools.com/howto/img_mountains.jpg" alt="Mountains" style="width:100%"> </div> <figcaption>Fig.3 - Italy</figcaption> </div>

 figure{text-align: center; max-width: 40%; float:left; margin:0;padding: 10px;} figure img{width: 100%;}
 <figure> <img src='aaa.png'/> <figcaption align = "center"><b>Fig 2.5; Courtesy of Linear Algebra: Theory, Intuition, Code by Mike X Cohen</b></figcaption> </figure> <figure> <img src='bbb.png'/> <figcaption align = "center"><b>Fig 2.3; Courtesy of Linear Algebra: Theory, Intuition, Code by Mike X Cohen</b></figcaption> </figure>

if yes use Flex property如果是,则使用Flex属性

<div class="outerlayer">
<figure>
  <img src="pic_trulli.jpg" alt="Trulli" style="width:100%">
  <figcaption>Fig.1 - Trulli, Puglia, Italy.</figcaption>
</figure>
<figure>
  <img src="pic_trulli.jpg" alt="Trulli" style="width:100%">
  <figcaption>Fig.1 - Trulli, Puglia, Italy.</figcaption>
</figure>
</div

Styling造型

.outerlayer{
display: flex;/* arranges both images side by side*/
column-gap: 10px; /* To give a gap between both*/
}

Hope, you want something like this!希望,你想要这样的东西!

 figure {display: flex;} div {border:2px solid black; width:200px; padding:5px; margin:0 10px; text-align:center;}
 <figure> <div> <img src='https://picsum.photos/200/200'/> <figcaption>Fig 2.5; Courtesy of Linear Algebra: Theory, Intuition, Code by Mike X Cohen</figcaption> </div> <div> <img src='https://picsum.photos/200/200'/> <figcaption> Fig 2.3; Courtesy of Linear Algebra: Theory, Intuition, Code by Mike X Cohen </figcaption> </div> </figure>

Try this code to put image side by side with caption尝试使用此代码将图像与标题并排放置

 <style> figure{ display: inline-block; } </style> <figure> <img src='image.jpg' alt='image 1' /> <figcaption>Caption goes here</figcaption> </figure> <figure> <img src='image.jpg' alt='image 1' /> <figcaption>Caption goes here</figcaption> </figure>

Here are all basic inline styles to align your images side by side with captions.以下是所有基本的内联 styles 以将您的图像与标题并排对齐。 Hope this works in Jupyter Notebook.希望这适用于 Jupyter Notebook。

 <div class="container" style="display: inline-block;"> <figure> <div style="float: left; padding: 10px;"> <img src='aaa.png' width="350" height="350" align="center"/> <figcaption align="center"><b>Fig 2.5; Courtesy of Linear Algebra: Theory,<br> Intuition, Code by Mike X Cohen</b></figcaption> </div> <div style="float: right; padding: 10px;"> <img src='bbb.png' width="350" height="350" align="center"/> <figcaption align="center"><b>Fig 2.3; Courtesy of Linear Algebra: Theory,<br> Intuition, Code by Mike X Cohen</b></figcaption> </div> </figure> </div>

What actually do you want!!你到底想要什么!! do you want the images side by side你想要并排的图像吗

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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