当前位置:   article > 正文

聊天界面html+css+javascript_administrator/chat.html

administrator/chat.html

聊天界面html+css+javascript

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    *{
        padding: 0;
        margin: 0;
    }
    .chat_commento{
        width: 450px;
        height: 650px;
        margin: auto;
        border-radius: 10px;
        border: 2px solid #f4f5f7;
    }
    .clearfix::after{
        content: "";
        display: block;
        clear: both;
        width: 0;
        height: 0;
        line-height: 0;
        visibility: hidden;
    }
    /* top */
    .chat_top{
        width: 100%;
        height: 50px;
        border-top-left-radius: 10px;
        border-top-right-radius: 10px;
        padding-left: 20px;
        font-size: 20px;
        line-height: 50px;
        box-sizing: border-box;
        font-weight: 550;
        border-width: 0px;
    }
    /* middle */
    /* 左边 */
    .chat_middle{
        width: 450px;
        height: 455px;
        position: relative;
        box-sizing: border-box;
        overflow: auto;
        border-width: 0px;
    }
    .chat_left{
        width: 100%;
        height: 120px;
        margin-top: 20px;
    }
    .chat_left_item_1{
        width: 50px;
        height: 50px;
        background-color: #4459AB;
        float: left;
        margin-top: 10px;
        margin-left: 10px;
        margin-right: 10px;
        text-align: center;
        line-height: 50px;
        color: white;
        border-radius: 25px;
    }
    .chat_left_item_2{
        width: 55%;
        height: 100px;
        float: left;
        margin-top: 10px;
    }
    .chat_left_item_2 .chat_left_chat{
        float: left;
    }
    .chat_left_item_2 .chat_left_content{
        padding: 15px;
        margin-top: 10px;
        background-color: #f4f5f7;
        display: inline-block;
        border-radius: 10px;
        border-top-left-radius: 0px;
    }
    /* 右边 */
    .chat_right{
        width: 100%;
        height: 120px;
        margin-top: 20px;
    }
    .chat_right_item_1{
        width: 50px;
        height: 50px;
        background-color: #4459AB;
        float: right;
        margin-top: 10px;
        margin-left: 10px;
        margin-right: 10px;
        text-align: center;
        line-height: 50px;
        color: white;
        border-radius: 25px;
    }
    .chat_right_item_2{
        width: 55%;
        height: 100px;
        float: right;
        margin-top: 10px;
    }
    .chat_right_time{
        width: 100%;
        text-align: right;
    }
    .chat_right_content{
        float: right;
        padding: 15px;
        border-radius: 10px;
        margin-top: 10px;
        border-top-right-radius: 0px;
        background-color: #4F7cff;
        color: white;
    }
    /* foot */
    .chat_foot{
        width: 450px;
        height: 130px;
        border-bottom-left-radius: 10px;
        border-bottom-right-radius: 10px;
        position: relative;
    }
    .chat_context{
        width: 100%;
        height: 100%;
        font-size: 17px;
        box-sizing: border-box;
        outline: none;
        border-bottom-left-radius: 10px;
        border-bottom-right-radius: 10px;
        border-width: 0px;
        padding: 16px;
    }
    .chat_commit{
        width: 80px;
        height: 30px;
        color: white;
        background-color: #4F7cff;
        line-height: 30px;
        text-align: center;
        border-radius: 5px;
        position: absolute;
        right: 10px;
        bottom: 20px;
        margin-right: 10px;
    }
    .chat_context{
        resize: none;
    }
    .chat_context::placeholder{
        color: black;
        font-weight: 500k;
    }
    .line{
        width: 100%;
        border-top: 1px;
        border-color: #f4f5f7;
        border-style: solid;
    }
</style>
<body>
    <!-- entry -->
    <div class="chat_commento">
        <!-- top -->
        <div class="chat_top">
            是兄弟就来砍我
        </div>
        <!-- line -->
        <div class="line"></div>
        <!-- middle -->
        <div class="chat_middle" id="chat_middle_item">
             <!-- 左边 -->
            <div class="chat_left clearfix">
                <div class="chat_left_item_1 ">天乐</div>
                <div class="chat_left_item_2">
                    <div class="chat_time">18:57</div>
                    <div class="chat_left_content">
                        今天吃点啥?
                    </div>
                </div>
            </div>
            <!--右边 -->
            <div class="chat_right">
                <div class="chat_right_item_1 ">热巴</div>
                <div class="chat_right_item_2 ">
                    <div class="chat_right_time">18:59</div>
                    <div class="chat_right_content">
                        最近八合里周年庆店,咱们去薅羊毛呀
                    </div>
                </div>
            </div>
            <!-- l_2 -->
            <div class="chat_left clearfix">
                <div class="chat_left_item_1 ">天乐</div>
                <div class="chat_left_item_2">
                    <div class="chat_time">18:57</div>
                    <div class="chat_left_content">
                        行收拾一下走吧,早点去排个号
                    </div>
                </div>
            </div>
        </div>
        <!-- line -->
        <div class="line"></div>
        <!-- foot -->
        <div class="chat_foot">
            <!-- context -->
            <textarea class="chat_context" id="chat_context_item" cols="30" rows="10" placeholder="请输入"></textarea>
            <div class="chat_commit" id="button">发送</div>
        </div>
    </div>
    <script>
        // 成功发送
        var send_message=document.getElementById("chat_middle_item");
        var domBtm=document.getElementById("button");
        // 发送内容
        var message=document.getElementById("chat_context_item");
        domBtm.addEventListener("click",function(){
            var str=message.value;
            var date=new Date();
            var hour=date.getHours();
            var mm=date.getMinutes();
            var time=hour+':'+mm;
            var ans='<div class="chat_right_item_1 clearfix">热巴</div>'+
                '<div class="chat_right_item_2">'+
                    '<div class="chat_right_time clearfix">'+time+'</div>'+
                    '<div class="chat_right_content clearfix">'+str+'</div>'
                    +'</div>';
            var oLi=document.createElement("div");
            oLi.setAttribute("class","chat_right");
            oLi.innerHTML=ans;
            send_message.append(oLi);
            message.value="";
        });
    </script>
</body>
</html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
/*    //vue写法
        var vm=new Vue({
            el:"#chat_comment",
            data(){
                return{
                    chat_context_item:null
                }
            },
            methods:{
                commit: function(){
                    var data=new Date();
                    var hour=data.getHours();
                    var mm=data.getMinutes();
                    var time=hour+':'+mm;
                    var ans='<div class="chat_right_item_1 clearfix">热巴</div>'+
                    '<div class="chat_right_item_2">'+
                    '<div class="chat_right_time clearfix">'+time+'</div>'+
                    '<div class="chat_right_content clearfix">'+this.chat_context_item+'</div>'
                    +'</div>';
                    var oLi=document.createElement("div"); 
                    oLi.setAttribute("class","chat_right");
                    oLi.innerHTML=ans;
                    this.$refs.chat_middle_item.append(oLi);
                    this.chat_context_item=null;
                    let ele = document.getElementById('chat_middle_item');
                    ele.scrollTop = ele.scrollHeight;
                }
            }
        });
        */
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

请添加图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/417962
推荐阅读
相关标签
  

闽ICP备14008679号