在网上搜索了几个星期但找不到满足我所有需求的答案(只是部分),非常欢迎帮助。
我想要和已经完成的事情:
<figure class="left">
)现在我想添加这些要求:
<figure class="left" style="width:200px">
那样添加图片的原始宽度,但只有在没有别的办法的情况下才会这样。我离开的地方:
figure {
display: inline
}
figcaption {
display: block
}
figure.left {
float: left
}
figure.right {
float: right
}
<p>This is a part of the text of the article and at this point a image is inserted at the left side
<figure class="left" style="width:250px">
<img src="image.png" alt="img txt">
<figcaption>image caption and a lot of text</figcaption>
</figure>
and the article text goes on and on so that it will wrap around the image</p>
(我省略了填充/边距,以使其看起来更好。)
答案 0 :(得分:2)
尝试以下css并在调整浏览器大小时查看图片上的文字换行:
.left {
float: left;
border: 5px solid #BDBDBD;
background: #E0E0E0;
padding: 5px;
margin: 0px;
}
figcaption {
text-align: center;
}
答案 1 :(得分:1)
也许这对你来说太难了,但我找到了答案:
figure {
display: table;
}
figcaption {
display: table-caption;
caption-side: bottom;
}
我不认为这是HTML5或CSS3禁止的,它似乎对我有用。
不考虑响应式设计要求 - 我觉得这是一个单独的问题,我没有一个很好的CSS答案。
答案 2 :(得分:0)
这可能有助于某人解决它。我也在寻找一种方法来显示图像右侧的标题,其高度与图像相同。
figure, .figure {
display: inline-table;
}
figcaption {
display: table-caption;
caption-side: bottom;
background-color: red;
}
img {
width: 100%;
}
.image {
width: auto;
}
figure div {
display: inline-table;
background-color: aqua;
}
.caption {
display: table-caption;
caption-side: top;
background-color: red;
margin: 0;
}
&#13;
<figure>
<h2 class="caption">caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption </h2>
<img src="http://mintnet.net/images/thumbs/small-mossy.jpg">
<figcaption>caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption </figcaption>
</figure>
<figure>
<figcaption>caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption </figcaption>
<img src="http://mintnet.net/images/thumbs/small-mossy.jpg">
</figure>
<figure>
<div class="caption">caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption caption </div>
<div><img class="image" src="http://mintnet.net/images/thumbs/small-mossy.jpg">
</div>
</figure>
&#13;