gpt4 book ai didi

html - 内联图像,每个图像下方都带有标题?

转载 作者:太空宇宙 更新时间:2023-11-03 21:47:34 25 4
gpt4 key购买 nike

如何使用 HTML/CSS 在同一行显示多个图像,并在每个图像下方居中放置标题?

这是我目前拥有的:

HTML:

<div class="iconbox">
<div id="tut-icon"><p><img src="images/tuticon.png" alt="Written Tutorials" />Some text</p></div>
<div id="vid-icon"><p><img src="images/vidicon.png" alt="Video Tutorials" />Some text</p></div>
<div id="add-icon"><p><img src="images/addtuticon.png" alt="Add Tutorials" />Some text</p></div>
</div>

CSS:

.iconbox {
height: 128px;
padding: 20px;
display: inline;
}

#tut-icon, #vid-icon, #add-icon {
text-align: center;
width: 128px;
}

#tut-icon img, #vid-icon img, #add-icon img {
display: inline-block;
}

这是代码的 JSFiddle:http://jsfiddle.net/swiftsly/24m7L/

最佳答案

像这样的东西会起作用:

HTML:

<div class="iconbox">
<div id="tut-icon">
<img src="images/tuticon.png" alt="Written Tutorials" />
<p>Some text</p>
</div>
<div id="vid-icon">
<img src="images/vidicon.png" alt="Video Tutorials" />
<p>Some text</p>
</div>
<div id="add-icon">
<img src="images/addtuticon.png" alt="Add Tutorials" />
<p>Some text</p>
</div>
</div>

CSS:

.iconbox {
height: 128px;
padding: 20px;
}
.iconbox > div {
text-align: center;
width: 128px;
display: inline-block;
}
.iconbox p {
margin: 0;
}

DEMO

.iconbox {
height: 128px;
padding: 20px;
}
.iconbox > div {
text-align: center;
width: 128px;
float: left;
}
.iconbox p {
margin: 0;
}

DEMO

(在 float 之后你可能想要应用 clearfix )

关于html - 内联图像,每个图像下方都带有标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19645931/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com