• 聊天对话框(ctrl+enter发送)


    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <title>聊天对话框</title>
    <style type="text/css">
    *{font-size: 14px; padding:0; margin:0;}
    .main{
        position: relative;
        margin: 20px auto;
        border: 1px solid steelblue;
         430px;
        height: 400px;
    }
    .msgInput{
        display: block;
         406px;
        height: 60px;
        margin: 10px auto;
        
    }
    .sendbtn{
        position: absolute;
         100px;
        height: 29px;
        bottom: 5px;
        right: 10px;
    }
    .content{
        list-style: none;
         410px;
        height: 280px;
        margin: 5px auto;
        border: 1px dotted #D1D3D6;
        overflow-y: scroll;
    }
    .msgContent{
        auto;
        max- 250px;
        height: auto;
        word-break: break-all;
        margin: 5px;
        padding: 3px;
        border-radius: 5px;
    }

    .content .left{
        float: left;
        text-align: left;
        background-color: lightgrey;
        clear: both;
    }
    .content .right{
        float: right;
        text-align: right;
        background-color: yellowgreen;
        clear: both;
    }


    </style>

    </head>

    <body>
        <div id="main" class="main">
            <ul id="content" class="content">
                <li class="msgContent left">hello?</li>
                <li class="msgContent left">hello</li>
                <li class="msgContent right">hi</li>
                <li class="msgContent left">hehe</li>
                <li class="msgContent left">goodbye</li>
                <li class="msgContent right">。。。。</li>
                <li class="msgContent right">sdfasdsadfassdfsdfsdfdsfsdfsdfsdfdfasdffasdfasfdasd fasd fasd fasdfasdfasdf</li>
            </ul>
            <textarea id="msg_input" class="msgInput"></textarea>
            <button id="sendbtn" class="sendbtn">发送</button>
        </div>
    </body>
    </html>
    <script src="../../public.js"></script>
    <script>
        /*
         发送时,动态创建li 并设置li的样式msgContent right
         */
        document.onkeyup = function(e){
            var e = e || event;
            if( e.keyCode == 13 && e.ctrlKey ){
                var oli = document.createElement("li");
                oli.innerHTML = $id("msg_input").value;
                $id("content").appendChild( oli );
                oli.className = "msgContent right";
                $id("msg_input").value = "";
                oli.scrollIntoView();
            }
        }
    </script>
  • 相关阅读:
    react-native运行iOS真机、模拟器命令
    如何在RN插件iOS部分添加framework文件
    fatal error: module map file '/Users/z/Library/Developer/Xcode/DerivedData/sometest-cnjreghvqrsixrehofwrnercfpei/Build/Products/Debug-iphoneos/YogaKit/YogaKit.modulemap' not found 1 error generated.
    ERROR | attributes: Missing required attribute `homepage`.
    数据交互一
    JSP__第1章 动态网页开发基础
    第9章 表单校验
    第8章 使用JQuery操作DOM
    第7章 jQuery中的事件与动画
    第6章 jQuery选择器
  • 原文地址:https://www.cnblogs.com/tis100204/p/10319252.html
Copyright © 2020-2023  润新知