当前位置:Gxlcms > JavaScript > js实现的可折叠留言板(附源码下载)_javascript技巧

js实现的可折叠留言板(附源码下载)_javascript技巧

时间:2021-07-01 10:21:17 帮助过:7人阅读

javaScript 代码如下:


css部分代码如下:

* { 
margin: 0; 
padding: 0; 
} 
body { 
margin: 10px auto; 
width: 570px; 
font: 75%/120% Arial, Helvetica, sans-serif; 
} 
p { 
padding: 0 0 1em; 
} 
.message_list { 
list-style: none; 
margin: 0; 
padding: 0; 
width: 383px; 
} 
.message_list li { 
padding: 0; 
margin: 0; 
background: url(images/message-bar.gif) no-repeat; 
} 
.message_head { 
padding: 5px 10px; 
cursor: pointer; 
position: relative; 
} 
.message_head .timestamp { 
color: #666666; 
font-size: 95%; 
position: absolute; 
right: 10px; 
top: 5px; 
} 
.message_head cite { 
font-size: 100%; 
font-weight: bold; 
font-style: normal; 
} 
.message_body { 
padding: 5px 10px 15px; 
} 
.collapse_buttons { 
text-align: right; 
border-top: solid 1px #e4e4e4; 
padding: 5px 0; 
width: 383px; 
} 
.collapse_buttons a { 
margin-left: 15px; 
float: right; 
} 
.show_all_message { 
background: url(images/tall-down-arrow.gif) no-repeat right center; 
padding-right: 12px; 
} 
.show_recent_only { 
display: none; 
background: url(images/tall-up-arrow.gif) no-repeat right center; 
padding-right: 12px; 
} 
.collpase_all_message { 
background: url(images/collapse-all.gif) no-repeat right center; 
padding-right: 12px; 
color: #666666;
}

HTML中添加代码如下:

  1. 张三: 1分钟前

    你好

    这是最后一条消息

  2. 李四: 2分钟前

    你也好

  3. 王五: 1天前

    第一次来

  4. 李四: 2天前

  5. 王五: 3天前

    支持

  6. 李四: 5天前

    大家好

  7. 张三: 6 天前

    大家好

  8. 李四: 7天前

    这里不错哦

  9. 王五: 8 天前

    好地方

显示所有消息(9) 只显示五条消息 收起所有消息


案例下载

人气教程排行