Onlinewebsocket.vue 22.1 KB
Newer Older
yma16's avatar
yma16 已提交
1
<template>
Y
yma16 已提交
2
  <div class="container">
yma16's avatar
yma16 已提交
3
    <div class="selectName" id="selectNameId">
Y
yma16 已提交
4 5 6 7 8 9 10
      <div class="selectInput">
        <h1>欢迎进入聊天室</h1>
        <div style="display: flex; height: 20%">
          <el-input placeholder="请输入昵称进入聊天室" v-model="user" clearable>
          </el-input>
          <!-- &nbsp; -->
          <!-- <el-button type="success" icon="el-icon-check" circle></el-button> -->
yma16's avatar
yma16 已提交
11
        </div>
Y
yma16 已提交
12 13 14 15 16 17 18 19 20 21
        <div class="btn_fx">
          <a @click="registerUsername()">
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <p>进入聊天室</p>
          </a>
        </div>
      </div>
yma16's avatar
yma16 已提交
22 23
    </div>
    <div class="left">
Y
yma16 已提交
24 25 26 27 28 29 30 31 32 33 34
      <el-card class="left_top">
        <p>聊天室</p>
        <!-- <p>人数:{{personCount}}</p> -->
        <p>消息:{{ chatCount }}</p>
        <div
          v-for="(item, index) in room_name"
          :key="index"
          class="roomNameClass"
        >
          <div
            v-bind:class="[
yma16's avatar
yma16 已提交
35
              { room_active: index === room_loc },
yma16's avatar
yma16 已提交
36
              room_defaultClass,
Y
yma16 已提交
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
            ]"
            @click="changeRoom(item, index)"
          >
            {{ item }}
          </div>
        </div>
        <p>{{ msg }}</p>
      </el-card>

      <el-card class="input_chat1" shadow="always" cellpadding="1px">
        <div class="right_header" style="display: flex; width: 100%">
          <h1 class="roomName">{{ room_select }}</h1>
          <h1
            class="clearFont"
            style="width: 100%; right: 0; text-align: right; cursor: pointer"
            @click="clearChat()"
          >
            清屏
          </h1>
        </div>
yma16's avatar
yma16 已提交
57

Y
yma16 已提交
58 59 60 61 62 63 64 65 66
        <el-input type="textarea" v-model="send_info"> </el-input>
        <el-button
          type="success"
          round
          style="margin-top: 2%"
          @click="websocketOpen(send_info)"
          >发送</el-button
        >
      </el-card>
yma16's avatar
yma16 已提交
67 68 69
    </div>
    <!-- 聊天信息 -->
    <div class="right" id="idChat" style="opacity: 0.8">
Y
yma16 已提交
70 71 72 73 74 75 76 77
      <el-card shadow="hover" style="line-height: 10px">
        <div class="blockChat">
          <div
            v-for="(item, index) in chat_info"
            :key="index"
            class="text item"
          >
            <!-- {{item}} -->
yma16's avatar
yma16 已提交
78
            <template v-if="item.room === room_select">
Y
yma16 已提交
79 80 81 82 83
              <div
                v-for="(item2, index2) in item.content"
                :key="index2"
                class="msgClass"
                v-bind:class="[
yma16's avatar
yma16 已提交
84
                  { info_active: ws_flag === true },
yma16's avatar
yma16 已提交
85
                  info_defaultClass,
Y
yma16 已提交
86 87 88 89 90 91
                ]"
              >
                <div class="msgUser">
                  <i class="el-icon-user"
                    >{{ item2.user }} &nbsp;{{ item2.create_time }}</i
                  >
yma16's avatar
yma16 已提交
92
                </div>
Y
yma16 已提交
93 94
                <div class="msgMessage">
                  <p>{{ item2.message }}</p>
yma16's avatar
yma16 已提交
95
                </div>
Y
yma16 已提交
96 97 98 99
              </div>
            </template>
          </div>
        </div>
yma16's avatar
yma16 已提交
100

Y
yma16 已提交
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
        <el-card class="input_chat2" shadow="always" cellpadding="1px">
          <div class="right_header" style="display: flex; width: 100%">
            <h1 class="roomName">{{ room_select }}</h1>
            <h1
              class="clearFont"
              style="width: 100%; right: 0; text-align: right; cursor: pointer"
              @click="clearChat()"
            >
              清屏
            </h1>
          </div>

          <el-input type="textarea" v-model="send_info"> </el-input>
          <el-button
            type="success"
            round
            style="margin-top: 2%"
            @click="websocketOpen(send_info)"
            >发送</el-button
          >
yma16's avatar
yma16 已提交
121
        </el-card>
Y
yma16 已提交
122
      </el-card>
yma16's avatar
yma16 已提交
123
    </div>
Y
yma16 已提交
124
  </div>
yma16's avatar
yma16 已提交
125 126 127
</template>

<script>
yma16's avatar
yma16 已提交
128
import store from '@/store'
yma16's avatar
yma16 已提交
129
export default {
yma16's avatar
yma16 已提交
130 131 132 133 134 135 136 137 138 139 140 141 142 143
    name: 'Onlinewebsocket',
    data () {
        return {
            ws_flag: false,
            msg: '连接中',
            send_info: 'hello world!',
            room_name: ['DjangoVue'],
            room_select: '',
            // baseUrl: "http://localhost:8006/webchat/index/",
            baseUrl: 'https://yongma16.xyz/api/',
            // websocketUrl: "/ws_api/",
            websocketUrl: 'wss://yongma16.xyz/ws-api/',
            websocket: null,
            // room 存房间名字,content保存聊天信息的数组
yma16's avatar
yma16 已提交
144
            chat_info: [],
yma16's avatar
yma16 已提交
145 146 147 148 149 150 151 152 153 154 155
            chat_room: null,
            room_loc: 0,
            user: '',
            cookieValue: document.cookie,
            chatCount: 0,
            personCount: 0,
            sendmsg: '',
            getmsg: '',
            // 房间索引0
            chatRoomIndex: 0
            // msg='连接成功'
Y
yma16 已提交
156 157
        }
    },
yma16's avatar
yma16 已提交
158 159 160
    mounted () {
    // 判断是否登录
        this.judeIsLogin()
yma16's avatar
yma16 已提交
161
        this.initUserName()
Y
yma16 已提交
162
    },
yma16's avatar
yma16 已提交
163
    methods: {
yma16's avatar
yma16 已提交
164 165 166 167 168 169 170 171 172 173
        initUserName () {
            const thirdUserInfo = JSON.parse(localStorage.getItem('thirdUserInfo'))
            const currentUsername = store.state.user.userInfo && store.state.user.userInfo.thirdUserInfo
                ? store.state.user.userInfo.thirdUserInfo.nickname : store.state.user.userInfo.name ? store.state.user.userInfo.name : ''
            this.user = currentUsername
            if (thirdUserInfo && thirdUserInfo.nickName) {
                this.user = thirdUserInfo.nickName
            }
            this.registerUsername()
        },
yma16's avatar
yma16 已提交
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
        judeIsLogin () {
            try {
                console.log(
                    'domMain',
                    document.getElementById('mainappid'),
                    document.getElementById('mainappid').style
                )
                document.getElementById('mainappid').style.padding = '0'
                document.getElementById('mainappid').style.margin = '0'
            } catch (e) {
                console.log('e', e)
            }
        },
        registerUsername () {
            let selectNameDom = document.getElementById('selectNameId')
            console.log(selectNameDom)
            selectNameDom.style.display = 'none'
            //
            this.initWebsocket()
            this.getRoom(this.room_loc)
            this.initRoom()
            // this.cookiePrint(); //打印cookie
        },
        clearChat () {
            // 清空消息
            this.chatCount = 0
            this.chat_info = new Array()
            this.websocket.chat_info[this.chatRoomIndex].content = []
        },
        cookiePrint () {
            let that = this
            console.log('cookie')
            let strcookie = document.cookie // 获取cookie字符串
            let arrcookie = strcookie.split(';') // 分割
            let length = arrcookie.length
            // 遍历匹配
            for (let i = 0; i < length; i++) {
                let arr = arrcookie[i].split('=')
                let arrname = arr[0].replace(' ', '')
                // 划分为两个
                if (arrname === 'user') {
                    that.user = arr[1]
                }
                console.log(arrname === 'user', arrname + '' + arr[1])
            }
        },
        info_defaultClass: function () {
            console.log('发送消息的css')
        },
        room_defaultClass: function () {
            console.log('选中房间的css')
        },
        getRoom: function (room_loc) {
            // 更新index
yma16's avatar
yma16 已提交
228 229
            const that = this
            that.room_loc = room_loc
yma16's avatar
yma16 已提交
230
            console.log('获取房间')
yma16's avatar
yma16 已提交
231 232
            that.$axios
                .get(that.baseUrl + 'webchat/index/')
yma16's avatar
yma16 已提交
233
                .catch((error) => {
yma16's avatar
yma16 已提交
234
                    throw Error(error)
yma16's avatar
yma16 已提交
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
                })
        },
        initRoom: function () {
            // 用户信息
            // 日期格式化
            Date.prototype.Format = function (fmt) {
                var o = {
                    'M+': this.getMonth() + 1, // 月份
                    'd+': this.getDate(), // 日
                    'H+': this.getHours(), // 小时
                    'm+': this.getMinutes(), // 分
                    's+': this.getSeconds(), // 秒
                    'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
                    S: this.getMilliseconds() // 毫秒
                }
                if (/(y+)/.test(fmt)) {
                    fmt = fmt.replace(
                        RegExp.$1,
                        (this.getFullYear() + '').substr(4 - RegExp.$1.length)
                    )
                }
                for (var k in o) {
                    if (new RegExp('(' + k + ')').test(fmt)) {
                        fmt = fmt.replace(
                            RegExp.$1,
                            RegExp.$1.length === 1
                                ? o[k]
                                : ('00' + o[k]).substr(('' + o[k]).length)
                        )
                    }
                }
                return fmt
            }
Y
yma16 已提交
268

yma16's avatar
yma16 已提交
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
            this.room_select = this.room_name[0]
        },
        changeRoom: function (roomName, roomLoc) {
            this.room_loc = roomLoc
            this.room_select = roomName
            // 新建连接
            // this.initWebsocket(roomName)
            console.log('选择房间', roomName)
            // console.log(that)
        },
        initWebsocket: function (roomName) {
            try {
                if (this.websocket) {
                    this.websocket.close()
                }
            } catch (e) {
                console.log('关闭失败!', e)
            }
            // 触发+1
            this.personCount++
Y
yma16 已提交
289

yma16's avatar
yma16 已提交
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
            // 默认第一个房间
            let room = roomName !== undefined ? roomName : this.room_name[0]
            // 判断房间是否存在,不存在则创建房间
            let chatRoomIndex = 0
            try {
                // 判断房间是否存在
                let roomFlag = false
                this.chat_info.map((item, index) => {
                    if (item.room === roomName) {
                        // 房间存在
                        console.log('房间存在', roomName)
                        roomFlag = true
                        chatRoomIndex = index
                    }
                })
                if (!roomFlag) {
                    // 房间不存在,创建
Y
yma16 已提交
307

yma16's avatar
yma16 已提交
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
                    let roomObject = {
                        room: room,
                        content: []
                    }
                    this.chat_info.push(roomObject)
                    console.log('创建房间', this.chat_info)
                }
            } catch (e) {
                console.log('创建房间出错', e)
            }
            this.chatRoomIndex = chatRoomIndex
            const wsUrl = this.websocketUrl
            this.websocket = new WebSocket(wsUrl + room + '/') // 连接
            console.log(this.websocket, '聊天室')
            this.websocket.onmessage = this.websocketMessage // 函数指向
            this.websocket.onopen = this.websocketOpen
            this.websocket.onerror = this.websocketError
            this.websocket.onclose = this.websocketClose
            // 保存数据 临时容器  房间号
            this.websocket.chat_info = JSON.parse(JSON.stringify(this.chat_info))
            this.websocket.chatRoomIndex = chatRoomIndex
            console.log('实例websocket', this.websocket)
        },
        websocketMessage: function (e) {
            console.log('聊天信息', JSON.parse(JSON.stringify(e.data)))
            let res = JSON.parse(e.data)
            if (res.message.info.isTrusted) {
                console.log('accsee right!')
                // 人数记录,只会后加入的
            }
            let flag = true
            if (flag) {
                //  房间计数
                this.personCount = res.message.person_count
                    ? res.message.person_count
                    : 0
                let getUser = res.message.user
                let getinfo = res.message.info.isTrusted
                    ? `欢迎${getUser}加入聊天室`
                    : res.message.info
                this.getmsg = getinfo
                this.msg = this.sendmsg === this.getmsg ? '连接聊天室成功' : ''
                let getTime = res.message.create_time
                let message = {
                    user: getUser,
                    message: getinfo,
                    create_time: getTime
                }
                // 添加信息
Y
yma16 已提交
357

yma16's avatar
yma16 已提交
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
                this.websocket.chat_info[this.websocket.chatRoomIndex].content.push(
                    message
                )
                // 交换数据
                this.chat_info = this.websocket.chat_info
                this.chatCount++
                console.log('信息', this.chat_info)
                setTimeout((o) => {
                    try {
                        let dom = document.getElementById('idChat')
                        console.log('滚动前', dom.scrollTop, dom.scrollHeight)
                        dom.scrollTop = parseInt(dom.scrollHeight)
                        console.log('滚动后', dom.scrollTop, dom.scrollHeight)
                        dom.scrollTop = dom.scrollHeight
                        // document.getElementById('idChat').scrollTop+=20
                    } catch (e) {
                        console.log(e)
                    }
                }, 100)
            }
        },
        websocketOpen: function (info) {
            this.websocketSend(info)
            // this.send_info=''//清空
        },
        websocketSend: function (data) {
            this.sendmsg = data
            // 名字,消息,时间
            let sendData = {
                person_count: this.personCount,
                user: this.user,
                info: data,
                create_time: new Date().Format('yyyy-MM-dd HH:mm:ss')
            }
            // this.msg='消息发送中'
            console.log('消息发送中')
            let info = JSON.stringify({
                message: sendData
            })
            try {
                this.websocket.send(info)
                // this.msg=''
            } catch (e) {
                console.log('消息发送失败', e)
                this.msg = '连接失败'
            }
        },
        websocketError: function () {
            this.msg = '连接失败'
            let selectNameDom = document.getElementById('selectNameId')
            console.log(selectNameDom)
            selectNameDom.style.display = 'block'
            window.alert('websocket连接失败!')
            // this.initWebsocket()// 重连
        },
        websocketClose: function (e) {
            // 人数减一
            this.personCount = this.personCount > 0 ? this.personCount-- : 0
            this.msg = '离开'
            console.log('离开', e)
            let selectNameDom = document.getElementById('selectNameId')
            console.log(selectNameDom)
            selectNameDom.style.display = 'block'
yma16's avatar
yma16 已提交
421
            this.initRoom()
yma16's avatar
yma16 已提交
422 423
            // 触发减一
        }
yma16's avatar
yma16 已提交
424
    },
yma16's avatar
yma16 已提交
425 426 427 428
    destroyed () {
        this.websocketClose() // 关闭
    }
}
yma16's avatar
yma16 已提交
429 430 431 432
</script>

<style scoped>
.selectName {
Y
yma16 已提交
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
  width: 100%;
  height: 100%;
  position: absolute;
  overflow: hidden;
  /* display: fixed; */
  top: 50%;
  left: 50%;
  z-index: 3;
  /* border-radius: 10px; */
  transform: translate(-50%, -50%);
  background: #005aa7;
  /* fallback for old browsers */
  background: -webkit-linear-gradient(to right, #fffde4, #005aa7);
  /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(to right, #fffde4, #005aa7);
  /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
  background-size: 400%;
  animation: sendInfo 20s linear infinite;
  opacity: 0.9;
yma16's avatar
yma16 已提交
452 453 454
}

.selectInput {
Y
yma16 已提交
455 456 457 458 459 460 461
  position: relative;
  width: 50%;
  height: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
yma16's avatar
yma16 已提交
462 463 464
}

.selectInput h1 {
Y
yma16 已提交
465 466
  font-size: 3em;
  color: #fb7248;
yma16's avatar
yma16 已提交
467 468 469
}

.btn_fx {
Y
yma16 已提交
470 471 472
  position: relative;
  padding: 20px;
  /* margin:20px; */
yma16's avatar
yma16 已提交
473 474 475
}

.blockChat {
Y
yma16 已提交
476 477 478
  position: relative;
  width: 100%;
  display: block;
yma16's avatar
yma16 已提交
479 480 481
}

.blockChat h1 {
Y
yma16 已提交
482 483 484
  color: rgb(135, 187, 222);
  font-size: 20px;
  font-weight: bold;
yma16's avatar
yma16 已提交
485 486 487
}

.msgClass {
Y
yma16 已提交
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
  position: relative;
  width: 100%;
  text-align: left;
  margin-bottom: 30px;
  padding-bottom: 30px;
  /* background: rgba(135, 187, 222,.6); */
  background: #4ca1af;
  /* fallback for old browsers */
  background: -webkit-linear-gradient(to left, #c4e0e5, #4ca1af);
  /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(to left, #c4e0e5, #4ca1af);
  /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */

  background-size: 400%;
  animation: sendInfo 20s linear infinite;
  /* -webkit-background-clip: text;
yma16's avatar
yma16 已提交
504 505 506 507
  -webkit-text-fill-color: transparent; */
}

.msgUser {
Y
yma16 已提交
508 509 510 511 512 513 514 515
  position: relative;
  margin: 5px;
  padding: 5px;
  top: 50%;
  width: 100%;
  height: 30px;
  color: rgb(0, 0, 0);
  /* background: rgb(135, 187, 222); */
yma16's avatar
yma16 已提交
516 517 518
}

.msgMessage {
Y
yma16 已提交
519
  position: relative;
yma16's avatar
yma16 已提交
520

Y
yma16 已提交
521 522 523 524 525
  width: 100%;
  height: 50px;
  font-size: 20px;
  color: rgb(0, 0, 0);
  /* background: rgb(135, 187, 222); */
yma16's avatar
yma16 已提交
526 527 528
}

.msgMessage p {
Y
yma16 已提交
529 530 531 532 533
  position: relative;
  /* left:50%; */
  margin: 5px;
  padding: 5px;
  top: 50%;
yma16's avatar
yma16 已提交
534 535 536
}

.left_top {
Y
yma16 已提交
537 538 539 540 541
  position: relative;
  cursor: pointer;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
yma16's avatar
yma16 已提交
542 543 544
}

.left_top p {
Y
yma16 已提交
545 546 547
  font-size: 20px;
  margin-bottom: 5px;
  padding-bottom: 5px;
yma16's avatar
yma16 已提交
548 549 550
}

.roomNameClass {
Y
yma16 已提交
551 552
  position: relative;
  cursor: pointer;
yma16's avatar
yma16 已提交
553 554 555
}

.room_active {
Y
yma16 已提交
556 557 558 559 560 561 562 563 564 565 566 567 568
  appearance: none;
  position: relative;
  text-align: left;
  width: 100%;
  height: 100%;
  font-weight: bold;
  color: rgb(135, 187, 222);
  text-shadow: 0 5px 20px #fff;
  background: transparent;
  cursor: pointer;
  line-height: 20px;
  /* padding-top:10px; */
  /* transition: 0.5s; */
yma16's avatar
yma16 已提交
569 570 571
}

.room_defaultClass {
Y
yma16 已提交
572 573 574 575 576 577 578 579 580 581 582 583
  appearance: none;
  position: relative;
  text-align: left;
  width: 100%;
  height: 100%;
  font-weight: bold;
  color: rgb(0, 140, 255);
  background: transparent;
  cursor: pointer;
  line-height: 20px;
  /* padding-top:10px; */
  /* transition: 0.5s; */
yma16's avatar
yma16 已提交
584 585 586
}

.info_active {
Y
yma16 已提交
587 588 589 590 591 592 593 594 595 596 597 598 599
  position: relative;
  width: 100%;
  text-align: left;
  margin-bottom: 30px;
  padding-bottom: 30px;
  background: #5d4157;
  /* fallback for old browsers */
  background: -webkit-linear-gradient(to right, #a8caba, #5d4157);
  /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(to right, #a8caba, #5d4157);
  /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
  background-size: 400%;
  animation: sendInfo 2s linear infinite;
yma16's avatar
yma16 已提交
600 601 602
}

.info_defaultClass {
Y
yma16 已提交
603 604 605 606 607 608 609 610 611
  position: relative;
  width: 100%;
  text-align: left;
  margin-bottom: 30px;
  padding-bottom: 30px;
  background: rgba(135, 187, 222, 0.6);
  background-image: linear-gradient(to right, #9b63ff, #462188);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
yma16's avatar
yma16 已提交
612 613 614
}

@keyframes sendInfo {
Y
yma16 已提交
615 616 617
  0% {
    background-position: 0% 50%;
  }
yma16's avatar
yma16 已提交
618

Y
yma16 已提交
619 620 621
  50% {
    background-position: 100% 50%;
  }
yma16's avatar
yma16 已提交
622

Y
yma16 已提交
623 624 625
  100% {
    background-position: 0% 50%;
  }
yma16's avatar
yma16 已提交
626 627 628
}

.container {
Y
yma16 已提交
629 630 631 632 633 634 635 636 637 638 639
  position: relative;
  height: 100%;
  width: 100%;
  opacity: 1;
  /* overflow: hidden; */
  /* background-color: aliceblue; */
  align-content: inherit;
  display: flex;
  margin: 0;
  padding: 0;
  background: url(https://w.wallhaven.cc/full/72/wallhaven-72wzq9.png);
yma16's avatar
yma16 已提交
640 641 642 643 644
  background-position: center center;
  background-clip: border-box;
  background-size:100% 100%;
  background-attachment:fixed;
  background-repeat: no-repeat;
yma16's avatar
yma16 已提交
645 646 647 648 649
}

/* 取消滚动并且隐藏 */
.container::-webkit-scrollbar,
.left::-webkit-scrollbar .right::-webkit-scrollbar {
Y
yma16 已提交
650
  display: none;
yma16's avatar
yma16 已提交
651 652 653
}

.left {
Y
yma16 已提交
654 655 656 657 658 659
  position: relative;
  width: 30%;
  height: 100%;
  overflow: auto;
  margin: 5px;
  padding: 5px;
yma16's avatar
yma16 已提交
660 661 662
}

.right {
Y
yma16 已提交
663 664 665 666 667 668
  position: relative;
  width: 70%;
  height: 100%;
  overflow: auto;
  margin: 5px;
  padding: 5px;
yma16's avatar
yma16 已提交
669 670 671
}

.text {
Y
yma16 已提交
672
  font-size: 14px;
yma16's avatar
yma16 已提交
673 674 675
}

.item {
Y
yma16 已提交
676
  padding: 18px 0;
yma16's avatar
yma16 已提交
677 678 679
}

.box-card {
Y
yma16 已提交
680
  width: 100%;
yma16's avatar
yma16 已提交
681 682 683
}

.input_chat1 {
yma16's avatar
yma16 已提交
684
  /* position: myblog_static; */
Y
yma16 已提交
685 686 687 688
  margin-top: 5%;
  text-align: letf;
  line-height: 50px;
  /* background: cadetblue; */
yma16's avatar
yma16 已提交
689 690 691
}

.input_chat2 {
yma16's avatar
yma16 已提交
692
  /* position: myblog_static; */
Y
yma16 已提交
693 694 695 696 697
  margin-top: 5%;
  text-align: letf;
  line-height: 50px;
  background: cadetblue;
  display: none;
yma16's avatar
yma16 已提交
698 699 700
}

.selectName a {
Y
yma16 已提交
701 702 703 704 705 706 707 708 709
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 80px;
  overflow: hidden;
  margin: 0;
  padding: 0;
yma16's avatar
yma16 已提交
710 711 712
}

.selectName a p {
Y
yma16 已提交
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727
  position: absolute;
  text-align: center;
  width: 100%;
  height: 100%;
  line-height: 80px;
  appearance: none;
  font-size: 2em;
  text-transform: uppercase;
  color: #fb7248;
  border: 1px solid #fb7248;
  box-sizing: border-box;
  z-index: 1;
  transition: 0.5s;
  margin: 0;
  padding: 0;
yma16's avatar
yma16 已提交
728 729 730
}

.selectName a:hover p {
Y
yma16 已提交
731
  color: #fff;
yma16's avatar
yma16 已提交
732 733 734
}

.selectName a span {
Y
yma16 已提交
735 736 737 738 739 740 741
  position: absolute;
  width: 100%;
  height: 100%;
  background: #fb7248;
  opacity: 0.5;
  z-index: -1;
  transition: 0.5s;
yma16's avatar
yma16 已提交
742 743 744
}

.selectName a span:nth-child(1) {
Y
yma16 已提交
745 746
  top: -100%;
  left: -100%;
yma16's avatar
yma16 已提交
747 748 749
}

.selectName a span:nth-child(2) {
Y
yma16 已提交
750 751
  bottom: -100%;
  left: -100%;
yma16's avatar
yma16 已提交
752 753 754
}

.selectName a span:nth-child(3) {
Y
yma16 已提交
755 756
  top: -100%;
  right: -100%;
yma16's avatar
yma16 已提交
757 758 759
}

.selectName a span:nth-child(4) {
Y
yma16 已提交
760 761
  bottom: -100%;
  right: -100%;
yma16's avatar
yma16 已提交
762 763 764
}

.selectName a:hover span:nth-child(1) {
Y
yma16 已提交
765 766
  top: 0px;
  left: 0px;
yma16's avatar
yma16 已提交
767 768 769
}

.selectName a:hover span:nth-child(2) {
Y
yma16 已提交
770 771
  bottom: 0px;
  left: 0px;
yma16's avatar
yma16 已提交
772 773 774
}

.selectName a:hover span:nth-child(3) {
Y
yma16 已提交
775 776
  top: 0px;
  right: 0px;
yma16's avatar
yma16 已提交
777 778 779
}

.selectName a:hover span:nth-child(4) {
Y
yma16 已提交
780 781
  bottom: 0px;
  right: 0px;
yma16's avatar
yma16 已提交
782 783 784
}

@media screen and (max-width: 450px) {
Y
yma16 已提交
785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837
  .selectName a {
    width: 100px;
    height: 50px;
  }

  .selectName a p {
    position: absolute;
    text-align: center;
    width: 100%;
    height: 100%;
    line-height: 50px;
    font-size: 1em;
  }

  .selectInput h1 {
    font-size: 2em;
    color: #fb7248;
  }

  .container {
    background-color: lightblue;
    display: inline-block;
    box-sizing: border-box;
    background: url(https://w.wallhaven.cc/full/72/wallhaven-72wzq9.png);
    background-repeat: repeat-y;
    /* overflow: hidden; */
  }

  .left {
    /* top:60%; */
    position: relative;
    width: 100%;
    height: auto;
    overflow: auto;
    margin: 5px;
    padding: 5px;
  }

  .right {
    /* top:5%; */
    position: relative;
    width: 100%;
    height: auto;
    overflow: auto;
    margin: 5px;
    padding: 5px;
  }

  .input_chat1 {
    display: none;
  }

  .input_chat2 {
yma16's avatar
yma16 已提交
838
    /* position: myblog_static; */
Y
yma16 已提交
839 840 841 842 843 844 845
    margin-top: 5%;
    width: 100%;
    text-align: letf;
    line-height: 50px;
    background: cadetblue;
    display: inline-block;
  }
yma16's avatar
yma16 已提交
846 847
}
</style>