本文实例为大家分享了js实现微信聊天界面的具体代码,供大家参考,具体内容如下
效果如图:
代码部分
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>模拟微信聊天</title> <link rel="stylesheet" href="../css/模拟微信聊天.css" rel="external nofollow" > </head> <body> <div class="box"> <div class="phone"> <div class="header"></div> <div class="content"> <ul class="list"> </ul> <div class="content-bottom"> <img src="/UploadFiles/2021-04-02/one.jpeg">*{ margin:0; padding:0; } body{ margin:0; padding:0; } .box{ margin:100px auto; height:900px; width:1200px; background:linear-gradient(to right,violet,pink); } .phone{ top:50px; position:relative; width:500px; height:800px; background:#f6f6f6; left:50%; margin-left:-250px; border-radius: 30px; } .phone .header{ position: absolute; width:135px; height:5px; background:rgba(0,0,0,0.8); -webkit-border-radius: 80px; -moz-border-radius: 80px; border-radius: 80px; left:50%; margin-left:-67.5px; top:40px; } .phone .content{ position: absolute; top:75px; width:460px; height: 640px; background: #fff; left:50%; margin-left:-230px; border-radius: 1px; border:2px solid gray; } .phone .footer{ position: absolute; width:50px; height:50px; background:pink; -webkit-border-radius: 50%; -moz-border-radius: 50%; border-radius: 50%; bottom:15px; left:50%; margin-left:-25px; } .content .list{ height:575px; list-style-type: none; overflow: hidden; } .list li{ margin-top:30px; } .content .list .left img{ display:inline-block; margin: 0; float: left; margin-left:15px; } .content .list .left p{ color:#333333; margin-left:78px; width:320px; padding:20px 10px; font-size:20px; background:pink; border-radius: 6px; text-align: left; } .content .list .right img{ display:inline-block; margin: 0; float:right; margin-right:15px; } .content .list .right p { text-align: right; color: #333333; margin-left: 37px; width: 320px; padding: 20px 10px; font-size: 20px; background: pink; border-radius: 6px; } .content-bottom{ overflow: hidden; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; height: 65px; background:rgba(0,0,0,0.2); padding:10px 30px; position: relative; } .content-bottom .myInput{ display: inline-block; height:30px; width:250px; font-size:20px; border-radius:5px; border:1px solid #999999; text-indent:10px; outline:none; position:absolute; top:50%; margin-top: -15px; margin-left:20px; } .content-bottom .out{ height:32px; width: 60px; display: inline-block; position: absolute; right:30px; top:50%; border:1px solid #999999; margin-top: -16px; font-size:17px; outline: none; background:none; cursor:pointer; } .content-bottom .out:hover{ background-color: pink; }var out = document.querySelector(".out");//获取发送按钮 var myInput = document.querySelector(".myInput"); var pic = document.getElementById("pic");//获取图片 var onOff = true; var list = document.querySelector(".list");//获取ul pic.onclick=function(){ if(onOff){ pic.src = "../image/two.jpeg"; onOff = false; }else { pic.src = "../image/one.jpeg"; onOff = true; } }; out.onclick=function () { var value = myInput.value;//获取文字内容 if(value == ""){ alert("请输入内容"); }else{ if(onOff){ list.innerHTML += "<li class='left'><img src='../image/one.jpeg'/><p>" +value+ "</p></li>"; }else{ list.innerHTML += "<li class='right'><img src='../image/two.jpeg'/><p>" +value+ "</p></li>"; } } myInput.blur(myInput.value='');//失去焦点,文本框清空 };学习收获:加深对if语句的理解
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年09月21日
2024年09月21日
- [ABC]安娜-胆麦发烧女声[6N纯银镀膜][2016[低速原抓WAV+CUE]
- 任天堂今晚举行直面会!第三方及独立游戏展示
- 《哆啦A梦的铜锣烧店物语》发售!开罗公式+哆啦A梦
- 任天堂公布《塞尔达传说》系列时间线:野炊与王泪独立在外
- 五条人.2012-一些风景2CD【刀马旦】【WAV+CUE】
- 陈奕迅.2013-Easons.Life演唱会2CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 许美静.1995-遗憾(新马版)【上华】【WAV+CUE】
- 《叶倩文 歌声情缘》[WAV+CUE][410MB]
- 《张国荣 首首动听经典不容错过 追忆的风 2CD》[WAV+CUE][870MB]
- 《腾格尔 容中尔甲 亚东 高原三星 男人篇 3CD》[WAV/分轨][1GB]
- 命运圣契公测实测可用兑换码大全 命运圣契最新兑换码分享
- 黑神话悟空上品疾蝠精魄获取方法一览|上品疾蝠精魄收集攻略
- 《七龙珠电光炸裂!ZERO》GT角色预告片曝光,15位新角色登场
- [ABC]安娜-胆麦发烧女声[6N纯银镀膜][2016[低速原抓WAV+CUE]
- NewViennaOctetViennaWindSoloists-TheDeccaRecordings(2024)18CD[24-48][FLAC]-7