HTML5仿手机微信聊天界面
HTML5仿手机微信聊天界面
给大家带来的是HTML5仿手机微信聊天界面,截图效果如下:

源代码如下:
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>HTML5模拟微信聊天界面</title>
- <style>
- /**重置标签默认样式*/
- * {
- margin: 0;
- padding: 0;
- list-style: none;
- font-family: '微软雅黑'
- }
- #container {
- width: 450px;
- height: 780px;
- background: #eee;
- margin: 80px auto 0;
- position: relative;
- box-shadow: 20px 20px 55px #777;
- }
- .header {
- background: #000;
- height: 40px;
- color: #fff;
- line-height: 34px;
- font-size: 20px;
- padding: 0 10px;
- }
- .footer {
- width: 430px;
- height: 50px;
- background: #666;
- position: absolute;
- bottom: 0;
- padding: 10px;
- }
- .footer input {
- width: 275px;
- height: 45px;
- outline: none;
- font-size: 20px;
- text-indent: 10px;
- position: absolute;
- border-radius: 6px;
- right: 80px;
- }
- .footer span {
- display: inline-block;
- width: 62px;
- height: 48px;
- background: #ccc;
- font-weight: 900;
- line-height: 45px;
- cursor: pointer;
- text-align: center;
- position: absolute;
- right: 10px;
- border-radius: 6px;
- }
- .footer span:hover {
- color: #fff;
- background: #999;
- }
- #user_face_icon {
- display: inline-block;
- background: red;
- width: 60px;
- height: 60px;
- border-radius: 30px;
- position: absolute;
- bottom: 6px;
- left: 14px;
- cursor: pointer;
- overflow: hidden;
- }
- img {
- width: 60px;
- height: 60px;
- }
- .content {
- font-size: 20px;
- width: 435px;
- height: 662px;
- overflow: auto;
- padding: 5px;
- }
- .content li {
- margin-top: 10px;
- padding-left: 10px;
- width: 412px;
- display: block;
- clear: both;
- overflow: hidden;
- }
- .content li img {
- float: left;
- }
- .content li span{
- background: #7cfc00;
- padding: 10px;
- border-radius: 10px;
- float: left;
- margin: 6px 10px 0 10px;
- max-width: 310px;
- border: 1px solid #ccc;
- box-shadow: 0 0 3px #ccc;
- }
- .content li img.imgleft {
- float: left;
- }
- .content li img.imgright {
- float: right;
- }
- .content li span.spanleft {
- float: left;
- background: #fff;
- }
- .content li span.spanright {
- float: right;
- background: #7cfc00;
- }
- </style>
- <script>
- window.onload = function(){
- var arrIcon = ['http://www.xttblog.com/icons/favicon.ico','http://www.xttblog.com/wp-content/uploads/2016/03/123.png'];
- var num = 0; //控制头像改变
- var iNow = -1; //用来累加改变左右浮动
- var icon = document.getElementById('user_face_icon').getElementsByTagName('img');
- var btn = document.getElementById('btn');
- var text = document.getElementById('text');
- var content = document.getElementsByTagName('ul')[0];
- var img = content.getElementsByTagName('img');
- var span = content.getElementsByTagName('span');
- icon[0].onclick = function(){
- if(num==0){
- this.src = arrIcon[1];
- num = 1;
- }else if(num==1){
- this.src = arrIcon[0];
- num = 0;
- }
- }
- btn.onclick = function(){
- if(text.value ==''){
- alert('不能发送空消息');
- }else {
- content.innerHTML += '<li><img src="'+arrIcon[num]+'"><span>'+text.value+'</span></li>';
- iNow++;
- if(num==0){
- img[iNow].className += 'imgright';
- span[iNow].className += 'spanright';
- }else {
- img[iNow].className += 'imgleft';
- span[iNow].className += 'spanleft';
- }
- text.value = '';
- // 内容过多时,将滚动条放置到最底端
- contentcontent.scrollTop=content.scrollHeight;
- }
- }
- }
- </script>
- </head>
- <body>
- <div id="container">
- <div class="header">
- <span style="float: left;">业余草:模拟微信聊天界面</span>
- <span style="float: right;">14:21</span>
- </div>
- <ul class="content">
- <!-- 欢迎加入qq群:454796847、135430763 -->
- </ul>
- <div class="footer">
- <div id="user_face_icon">
- <img src="http://www.xttblog.com/icons/favicon.ico" alt="">
- </div>
- <input id="text" type="text" placeholder="说点什么吧...">
- <span id="btn">发送</span>
- </div>
- </div>
- </body>
- </html>
以上就是本文的全部内容,是不是很精彩,希望对大家的学习有所帮助。
HTML5仿手机微信聊天界面的更多相关文章
- android 仿微信聊天界面,以及语音录制功能
extends:http://104zz.iteye.com/blog/1709840 本例为模仿微信聊天界面UI设计,文字发送以及语言录制UI. 1先看效果图: 第一:chat.xml设计 ...
- Swift - 自定义单元格实现微信聊天界面
1,下面是一个放微信聊天界面的消息展示列表,实现的功能有: (1)消息可以是文本消息也可以是图片消息 (2)消息背景为气泡状图片,同时消息气泡可根据内容自适应大小 (3)每条消息旁边有头像,在左边表示 ...
- Android:日常学习笔记(8)———开发微信聊天界面
Android:日常学习笔记(8)———开发微信聊天界面 只做Nine-Patch图片 Nine-Patch是一种被特殊处理过的PNG图片,能够指定哪些区域可以被拉升,哪些区域不可以.
- HTML5仿微信聊天界面、微信朋友圈实例
这几天使用H5开发了一个仿微信聊天前端界面,尤其微信底部编辑器那块处理的很好,使用HTML5来开发,虽说功能效果并没有微信那么全,但是也相当不错了,可以发送消息.表情,发送的消息自动回滚定位到底部,另 ...
- vue聊天室|h5+vue仿微信聊天界面|vue仿微信
一.项目简介 基于Vue2.0+Vuex+vue-router+webpack2.0+es6+vuePhotoPreview+wcPop等技术架构开发的仿微信界面聊天室——vueChatRoom,实现 ...
- web版仿微信聊天界面|h5仿微信电脑端案例开发
前几天开发了一款手机端h5仿微信聊天,人唯有不停学习才能进步,这段时间倒腾着整理了下之前项目,又重新在原先的那版基础上开发了一款仿微信聊天电脑端web版本,聊天页面又重新优化了多图预览.视频播放,右键 ...
- jquery 仿手机屏幕切换界面效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- android 仿QQ气泡聊天界面
1.现在的QQ,微信等一些APP的聊天界面都是气泡聊天界面,左边是接收到的消息,右边是发送的消息, 这个效果其实就是一个ListView在加载它的Item的时候,分别用了不同的布局xml文件. 2.效 ...
- JS案例练习-手机微信聊天对话框
先附图 CSS部分: <style> body{} *{;} li{list-style: none;} .container{ width:310px; height:600px; ma ...
随机推荐
- Springboot 拦截器的背后
今天写了个拦截器对一些mapping做了些处理,写完之后突然很想看看拦截器是怎么加进spring里面.对着源码debug了一遍.又有了新的收获. 1.拦截器的实现 1.实现HandlerInterce ...
- NET快速信息化系统开发框架 V3.2 ->WinForm部分全部重构为Dev风格界面
RDIFrameowrk.NET V3.2以前的版本WinForm部分使用的界面控件是DotNetBar,界面也是非常的美女,但相比现在市面上用得非常多功能强大的Dev控件还是略显逊色,V3.2版本花 ...
- Java多线程概念简介 多线程中篇(一)
Java的线程与操作系统的线程 在线程的相关介绍中,有讲到“线程的实现”分为三种:内核支持,用户级以及两者混合.(这只是一种简要的分类) Java线程在JDK1.2之前,是用户线程实现的 而在JD ...
- AppBoxFuture(三): 分而治之
系统数据量达到一定程度后必将采用分库分表的方式来提高系统性能,但传统的分库分表方式也必将带来更高的开发复杂程度.新一代的NewSql及NoSql数据库由于天生的分布式存储基因,既保证了能够横向扩展 ...
- Spring Boot 2.x(五):整合Mybatis-Plus
简介 Mybatis-Plus是在Mybatis的基础上,国人开发的一款持久层框架. 并且荣获了2018年度开源中国最受欢迎的中国软件TOP5 同样以简化开发为宗旨的Spring Boot与Mybat ...
- C指针和数组的关系详解
1.C中数组和指针的关系 对于任意类型的数组arr,对于同类型的指针类型parr(确切一点,可以假设类型为int,即int arr[], *parr).它们之间有如下"内幕": 1 ...
- javascript基础修炼(7)——Promise,异步,可靠性
开发者的javascript造诣取决于对[动态]和[异步]这两个词的理解水平. 一. 别人是开发者,你也是 Promise技术是[javascript异步编程]这个话题中非常重要的,它一度让我感到熟悉 ...
- C#组件系列——又一款日志组件:Elmah的学习和分享
前言:好久没动笔了,都有点生疏,12月都要接近尾声,可是这月连一篇的产出都没有,不能坏了“规矩”,今天还是来写一篇.最近个把月确实很忙,不过每天早上还是会抽空来园子里逛逛.一如既往,园子里每年这个时候 ...
- 第45章 工具 - Identity Server 4 中文文档(v1.0.0)
该IdentityServerTools是为IdentityServer编写扩展代码时,你可能需要有效的内部工具的集合.要使用它,请将其注入代码,例如控制器: public MyController( ...
- .net -笔记 简单的操作符重载
这个操作符重载很有意思 class Program { static void Main(string[] args) { Person person1 = new Person() { Name = ...