制作评论留言‘css’
基础CSS样式设计
为评论留言区域添加基础样式,设置背景色、边框和内边距:
.comment-box {
background-color: #f9f9f9;
border: 1px solid #ddd;
border-radius: 5px;
padding: 15px;
margin-bottom: 20px;
}
用户信息样式
设计用户头像和用户名的显示样式:
.user-info {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.user-avatar {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 10px;
}
.username {
font-weight: bold;
color: #333;
}
评论内容样式
设置评论正文的字体和行距:

.comment-content {
font-size: 14px;
line-height: 1.5;
color: #555;
margin-bottom: 10px;
}
时间戳样式
为评论时间添加细小的灰色文字样式:
.comment-time {
font-size: 12px;
color: #999;
margin-bottom: 5px;
}
互动按钮样式
设计点赞和回复按钮的样式:

.comment-actions {
display: flex;
}
.action-btn {
background: none;
border: none;
color: #666;
cursor: pointer;
font-size: 12px;
margin-right: 15px;
padding: 5px 10px;
}
.action-btn:hover {
color: #333;
background-color: #eee;
border-radius: 3px;
}
响应式设计
添加媒体查询确保在不同设备上良好显示:
@media (max-width: 768px) {
.comment-box {
padding: 10px;
}
.user-avatar {
width: 30px;
height: 30px;
}
}
动画效果
为交互元素添加简单的悬停动画:
.action-btn {
transition: all 0.3s ease;
}
.user-avatar {
transition: transform 0.3s ease;
}
.user-avatar:hover {
transform: scale(1.1);
}






