• 聊天对话框(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>
  • 相关阅读:
    性能计数器
    SpringBoot_数据访问-整合JPA
    SpringBoot_数据访问-整合MyBatis(二)-注解版MyBatis
    SpringBoot_数据访问-整合Druid&配置数据源监控
    SpringBoot_数据访问-JDBC&自动配置原理
    八字克妻口诀
    没想到,我能这么细心地看算法
    辰戌丑未,四库
    The jar of divisors
    分布式系统阅读笔记(十六)-----事务和并发控制
  • 原文地址:https://www.cnblogs.com/tis100204/p/10319252.html
Copyright © 2020-2023  润新知