Onlinewebsocket.vue 21.4 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 128 129
</template>

<script>

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()
Y
yma16 已提交
161
    },
yma16's avatar
yma16 已提交
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
    methods: {
        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 已提交
217 218
            const that = this
            that.room_loc = room_loc
yma16's avatar
yma16 已提交
219
            console.log('获取房间')
yma16's avatar
yma16 已提交
220 221
            that.$axios
                .get(that.baseUrl + 'webchat/index/')
yma16's avatar
yma16 已提交
222
                .catch((error) => {
yma16's avatar
yma16 已提交
223
                    throw Error(error)
yma16's avatar
yma16 已提交
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 249 250 251 252 253 254 255 256
                })
        },
        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 已提交
257

yma16's avatar
yma16 已提交
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
            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 已提交
278

yma16's avatar
yma16 已提交
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
            // 默认第一个房间
            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 已提交
296

yma16's avatar
yma16 已提交
297 298 299 300 301 302 303 304 305 306 307 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
                    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 已提交
346

yma16's avatar
yma16 已提交
347 348 349 350 351 352 353 354 355 356 357 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
                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 已提交
412
    },
yma16's avatar
yma16 已提交
413 414 415 416
    destroyed () {
        this.websocketClose() // 关闭
    }
}
yma16's avatar
yma16 已提交
417 418 419 420
</script>

<style scoped>
.selectName {
Y
yma16 已提交
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
  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 已提交
440 441 442
}

.selectInput {
Y
yma16 已提交
443 444 445 446 447 448 449
  position: relative;
  width: 50%;
  height: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
yma16's avatar
yma16 已提交
450 451 452
}

.selectInput h1 {
Y
yma16 已提交
453 454
  font-size: 3em;
  color: #fb7248;
yma16's avatar
yma16 已提交
455 456 457
}

.btn_fx {
Y
yma16 已提交
458 459 460
  position: relative;
  padding: 20px;
  /* margin:20px; */
yma16's avatar
yma16 已提交
461 462 463
}

.blockChat {
Y
yma16 已提交
464 465 466
  position: relative;
  width: 100%;
  display: block;
yma16's avatar
yma16 已提交
467 468 469
}

.blockChat h1 {
Y
yma16 已提交
470 471 472
  color: rgb(135, 187, 222);
  font-size: 20px;
  font-weight: bold;
yma16's avatar
yma16 已提交
473 474 475
}

.msgClass {
Y
yma16 已提交
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
  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 已提交
492 493 494 495
  -webkit-text-fill-color: transparent; */
}

.msgUser {
Y
yma16 已提交
496 497 498 499 500 501 502 503
  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 已提交
504 505 506
}

.msgMessage {
Y
yma16 已提交
507
  position: relative;
yma16's avatar
yma16 已提交
508

Y
yma16 已提交
509 510 511 512 513
  width: 100%;
  height: 50px;
  font-size: 20px;
  color: rgb(0, 0, 0);
  /* background: rgb(135, 187, 222); */
yma16's avatar
yma16 已提交
514 515 516
}

.msgMessage p {
Y
yma16 已提交
517 518 519 520 521
  position: relative;
  /* left:50%; */
  margin: 5px;
  padding: 5px;
  top: 50%;
yma16's avatar
yma16 已提交
522 523 524
}

.left_top {
Y
yma16 已提交
525 526 527 528 529
  position: relative;
  cursor: pointer;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
yma16's avatar
yma16 已提交
530 531 532
}

.left_top p {
Y
yma16 已提交
533 534 535
  font-size: 20px;
  margin-bottom: 5px;
  padding-bottom: 5px;
yma16's avatar
yma16 已提交
536 537 538
}

.roomNameClass {
Y
yma16 已提交
539 540
  position: relative;
  cursor: pointer;
yma16's avatar
yma16 已提交
541 542 543
}

.room_active {
Y
yma16 已提交
544 545 546 547 548 549 550 551 552 553 554 555 556
  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 已提交
557 558 559
}

.room_defaultClass {
Y
yma16 已提交
560 561 562 563 564 565 566 567 568 569 570 571
  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 已提交
572 573 574
}

.info_active {
Y
yma16 已提交
575 576 577 578 579 580 581 582 583 584 585 586 587
  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 已提交
588 589 590
}

.info_defaultClass {
Y
yma16 已提交
591 592 593 594 595 596 597 598 599
  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 已提交
600 601 602
}

@keyframes sendInfo {
Y
yma16 已提交
603 604 605
  0% {
    background-position: 0% 50%;
  }
yma16's avatar
yma16 已提交
606

Y
yma16 已提交
607 608 609
  50% {
    background-position: 100% 50%;
  }
yma16's avatar
yma16 已提交
610

Y
yma16 已提交
611 612 613
  100% {
    background-position: 0% 50%;
  }
yma16's avatar
yma16 已提交
614 615 616
}

.container {
Y
yma16 已提交
617 618 619 620 621 622 623 624 625 626 627 628 629
  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);
  /* background-size: cover; */
  background-repeat: repeat-y;
yma16's avatar
yma16 已提交
630 631 632 633 634
}

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

.left {
Y
yma16 已提交
639 640 641 642 643 644
  position: relative;
  width: 30%;
  height: 100%;
  overflow: auto;
  margin: 5px;
  padding: 5px;
yma16's avatar
yma16 已提交
645 646 647
}

.right {
Y
yma16 已提交
648 649 650 651 652 653
  position: relative;
  width: 70%;
  height: 100%;
  overflow: auto;
  margin: 5px;
  padding: 5px;
yma16's avatar
yma16 已提交
654 655 656
}

.text {
Y
yma16 已提交
657
  font-size: 14px;
yma16's avatar
yma16 已提交
658 659 660
}

.item {
Y
yma16 已提交
661
  padding: 18px 0;
yma16's avatar
yma16 已提交
662 663 664
}

.box-card {
Y
yma16 已提交
665
  width: 100%;
yma16's avatar
yma16 已提交
666 667 668
}

.input_chat1 {
yma16's avatar
yma16 已提交
669
  /* position: myblog_static; */
Y
yma16 已提交
670 671 672 673
  margin-top: 5%;
  text-align: letf;
  line-height: 50px;
  /* background: cadetblue; */
yma16's avatar
yma16 已提交
674 675 676
}

.input_chat2 {
yma16's avatar
yma16 已提交
677
  /* position: myblog_static; */
Y
yma16 已提交
678 679 680 681 682
  margin-top: 5%;
  text-align: letf;
  line-height: 50px;
  background: cadetblue;
  display: none;
yma16's avatar
yma16 已提交
683 684 685
}

.selectName a {
Y
yma16 已提交
686 687 688 689 690 691 692 693 694
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 80px;
  overflow: hidden;
  margin: 0;
  padding: 0;
yma16's avatar
yma16 已提交
695 696 697
}

.selectName a p {
Y
yma16 已提交
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712
  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 已提交
713 714 715
}

.selectName a:hover p {
Y
yma16 已提交
716
  color: #fff;
yma16's avatar
yma16 已提交
717 718 719
}

.selectName a span {
Y
yma16 已提交
720 721 722 723 724 725 726
  position: absolute;
  width: 100%;
  height: 100%;
  background: #fb7248;
  opacity: 0.5;
  z-index: -1;
  transition: 0.5s;
yma16's avatar
yma16 已提交
727 728 729
}

.selectName a span:nth-child(1) {
Y
yma16 已提交
730 731
  top: -100%;
  left: -100%;
yma16's avatar
yma16 已提交
732 733 734
}

.selectName a span:nth-child(2) {
Y
yma16 已提交
735 736
  bottom: -100%;
  left: -100%;
yma16's avatar
yma16 已提交
737 738 739
}

.selectName a span:nth-child(3) {
Y
yma16 已提交
740 741
  top: -100%;
  right: -100%;
yma16's avatar
yma16 已提交
742 743 744
}

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

.selectName a:hover span:nth-child(1) {
Y
yma16 已提交
750 751
  top: 0px;
  left: 0px;
yma16's avatar
yma16 已提交
752 753 754
}

.selectName a:hover span:nth-child(2) {
Y
yma16 已提交
755 756
  bottom: 0px;
  left: 0px;
yma16's avatar
yma16 已提交
757 758 759
}

.selectName a:hover span:nth-child(3) {
Y
yma16 已提交
760 761
  top: 0px;
  right: 0px;
yma16's avatar
yma16 已提交
762 763 764
}

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

@media screen and (max-width: 450px) {
Y
yma16 已提交
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 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
  .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 已提交
823
    /* position: myblog_static; */
Y
yma16 已提交
824 825 826 827 828 829 830
    margin-top: 5%;
    width: 100%;
    text-align: letf;
    line-height: 50px;
    background: cadetblue;
    display: inline-block;
  }
yma16's avatar
yma16 已提交
831 832
}
</style>