css表头制作
CSS表头制作方法
固定表头(滚动时保持可见)
thead {
position: sticky;
top: 0;
background-color: #f8f9fa;
z-index: 100;
}
带阴影效果的表头
th {
background-color: #4CAF50;
color: white;
padding: 12px;
text-align: left;
box-shadow: 0 2px 2px -1px rgba(0,0,0,0.4);
}
渐变背景表头
th {
background: linear-gradient(to bottom, #f5f5f5, #e8e8e8);
border-bottom: 1px solid #ddd;
padding: 8px 15px;
}
带悬停效果的表头
th:hover {
background-color: #ddd;
transition: background-color 0.3s ease;
}
响应式表头(小屏幕调整)
@media screen and (max-width: 600px) {
th {
padding: 4px 8px;
font-size: 14px;
}
}
带排序箭头的表头
th.sortable {
cursor: pointer;
position: relative;
}
th.sortable:after {
content: "↑↓";
margin-left: 5px;
opacity: 0.3;
}
th.sortable.asc:after {
content: "↑";
opacity: 1;
}
th.sortable.desc:after {
content: "↓";
opacity: 1;
}






