gpt4 book ai didi

HTML、CSS - 样式列表 - 最佳实践

转载 作者:太空宇宙 更新时间:2023-11-04 15:28:08 25 4
gpt4 key购买 nike

我想用 HTML/CSS 设置列表样式,想知道最佳做法是什么。

<ul class="newsItems">
<li>
<h5>July 16, 2012</h5>
<p>News - headline information</p>
</li>
</ul>

我需要显示一个小报纸图标,以及 H5 中的文本和旁边的 P,这些需要内联显示(从左到右)。

最好使用包含 H5/P 元素的 LI 来执行此操作,还是有我不知道的更好的方法来执行此操作?

我的 CSS 目前看起来像这样:-

#News .newsItems {
padding-left:10px;
display:inline;
}

#News .newsItems li {
list-style-image:url(/Images/NewspaperIcon.png);
list-style-position:Inside;
}

#News .newsItems li {
vertical-align:top;
max-width:180px;
}

#News .newsItems li h5 {
vertical-align:top;
}

#News .newsItems li p {
vertical-align:top;
}

预期输出的示例 -

List Items - News

最佳答案

试试这个

CSS

ul.newsItems{
margin:0; padding:0;
}
ul.newsItems li {
height:auto;
display:inline-block;
list-style:none;
padding-left:40px; max-width:180px;
background: url('http://www.parker.edu/uploadedImages/1200_Newsletters/1214_Buttons/Newsletter-Icon.png') left top no-repeat;
}
.newsItems li span{
vertical-align:top; font-weight:bold;
}
.newsItems li p {margin:0; padding:0}

DEMO

关于HTML、CSS - 样式列表 - 最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13740655/

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