css制作名单
CSS 制作名单
使用 CSS 制作名单可以通过列表元素(<ul> 或 <ol>)结合样式调整来实现美观的排版效果。

基本 HTML 结构
<ul class="name-list">
<li>张三</li>
<li>李四</li>
<li>王五</li>
</ul>
样式设计
.name-list {
list-style-type: none; /* 移除默认列表符号 */
padding: 0;
margin: 0;
}
.name-list li {
padding: 8px 16px;
border-bottom: 1px solid #eee; /* 添加分隔线 */
font-family: Arial, sans-serif;
}
.name-list li:hover {
background-color: #f5f5f5; /* 悬停效果 */
}
进阶美化
.name-list {
width: 200px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* 添加阴影 */
border-radius: 4px; /* 圆角边框 */
}
.name-list li:first-child {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.name-list li:last-child {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom: none;
}
响应式设计
@media (max-width: 600px) {
.name-list {
width: 100%;
}
}
动画效果
.name-list li {
transition: background-color 0.3s ease;
}
通过以上 CSS 代码可以创建出美观且交互性强的名单列表,可根据实际需求调整颜色、间距等样式属性。






