How can I make the width of my
match the width of the >

前端 未结 5 1187
庸人自扰
庸人自扰 2020-12-07 22:16

Say, I got this code:

\"An
5条回答
  •  被撕碎了的回忆
    2020-12-07 23:02

    Unfortunately, setting the width of the figure instead of using max-width: 100% means that it won't shrink on narrow (mobile) devices. That is, the images will not be responsive. I resorted to inserting
    to break up long captions, but I didn't like it. But this obscure CSS feature seems to work for me:

    figcaption { display: run-in; width: 150px }

    This keeps the image responsive, even though the caption isn't. You can pick your own caption width. I also added margin: auto; text-align: center; to center the caption on a mobile device.

提交回复
热议问题