Onlinewebsocket.vue 21.6 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 129
import VueMarkdown from 'vue-markdown'
import axios from 'axios'
yma16's avatar
yma16 已提交
130 131

export default {
yma16's avatar
yma16 已提交
132 133
    components: {
        VueMarkdown
Y
yma16 已提交
134
    },
yma16's avatar
yma16 已提交
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
    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保存聊天信息的数组
            chat_info: new Array(),
            chat_room: null,
            room_loc: 0,
            user: '',
            cookieValue: document.cookie,
            chatCount: 0,
            personCount: 0,
            sendmsg: '',
            getmsg: '',
            // 房间索引0
            chatRoomIndex: 0
            // msg='连接成功'
Y
yma16 已提交
161 162
        }
    },
yma16's avatar
yma16 已提交
163 164 165
    mounted () {
    // 判断是否登录
        this.judeIsLogin()
Y
yma16 已提交
166
    },
yma16's avatar
yma16 已提交
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 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
    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
            this.room_loc = room_loc
            console.log('获取房间')
            axios
                .get(this.baseUrl + 'webchat/index/')
                .then((res) => {
                    console.log('返回', res)
                })
                .catch((error) => {
                    console.log('error', error)
                })
        },
        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 已提交
264

yma16's avatar
yma16 已提交
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
            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 已提交
285

yma16's avatar
yma16 已提交
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
            // 默认第一个房间
            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 已提交
303

yma16's avatar
yma16 已提交
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 346 347 348 349 350 351 352
                    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 已提交
353

yma16's avatar
yma16 已提交
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 412 413 414 415 416 417 418
                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 已提交
419
    },
yma16's avatar
yma16 已提交
420 421 422 423
    destroyed () {
        this.websocketClose() // 关闭
    }
}
yma16's avatar
yma16 已提交
424 425 426 427
</script>

<style scoped>
.selectName {
Y
yma16 已提交
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
  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 已提交
447 448 449
}

.selectInput {
Y
yma16 已提交
450 451 452 453 454 455 456
  position: relative;
  width: 50%;
  height: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
yma16's avatar
yma16 已提交
457 458 459
}

.selectInput h1 {
Y
yma16 已提交
460 461
  font-size: 3em;
  color: #fb7248;
yma16's avatar
yma16 已提交
462 463 464
}

.btn_fx {
Y
yma16 已提交
465 466 467
  position: relative;
  padding: 20px;
  /* margin:20px; */
yma16's avatar
yma16 已提交
468 469 470
}

.blockChat {
Y
yma16 已提交
471 472 473
  position: relative;
  width: 100%;
  display: block;
yma16's avatar
yma16 已提交
474 475 476
}

.blockChat h1 {
Y
yma16 已提交
477 478 479
  color: rgb(135, 187, 222);
  font-size: 20px;
  font-weight: bold;
yma16's avatar
yma16 已提交
480 481 482
}

.msgClass {
Y
yma16 已提交
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
  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 已提交
499 500 501 502
  -webkit-text-fill-color: transparent; */
}

.msgUser {
Y
yma16 已提交
503 504 505 506 507 508 509 510
  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 已提交
511 512 513
}

.msgMessage {
Y
yma16 已提交
514
  position: relative;
yma16's avatar
yma16 已提交
515

Y
yma16 已提交
516 517 518 519 520
  width: 100%;
  height: 50px;
  font-size: 20px;
  color: rgb(0, 0, 0);
  /* background: rgb(135, 187, 222); */
yma16's avatar
yma16 已提交
521 522 523
}

.msgMessage p {
Y
yma16 已提交
524 525 526 527 528
  position: relative;
  /* left:50%; */
  margin: 5px;
  padding: 5px;
  top: 50%;
yma16's avatar
yma16 已提交
529 530 531
}

.left_top {
Y
yma16 已提交
532 533 534 535 536
  position: relative;
  cursor: pointer;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
yma16's avatar
yma16 已提交
537 538 539
}

.left_top p {
Y
yma16 已提交
540 541 542
  font-size: 20px;
  margin-bottom: 5px;
  padding-bottom: 5px;
yma16's avatar
yma16 已提交
543 544 545
}

.roomNameClass {
Y
yma16 已提交
546 547
  position: relative;
  cursor: pointer;
yma16's avatar
yma16 已提交
548 549 550
}

.room_active {
Y
yma16 已提交
551 552 553 554 555 556 557 558 559 560 561 562 563
  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 已提交
564 565 566
}

.room_defaultClass {
Y
yma16 已提交
567 568 569 570 571 572 573 574 575 576 577 578
  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 已提交
579 580 581
}

.info_active {
Y
yma16 已提交
582 583 584 585 586 587 588 589 590 591 592 593 594
  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 已提交
595 596 597
}

.info_defaultClass {
Y
yma16 已提交
598 599 600 601 602 603 604 605 606
  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 已提交
607 608 609
}

@keyframes sendInfo {
Y
yma16 已提交
610 611 612
  0% {
    background-position: 0% 50%;
  }
yma16's avatar
yma16 已提交
613

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

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

.container {
Y
yma16 已提交
624 625 626 627 628 629 630 631 632 633 634 635 636
  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 已提交
637 638 639 640 641
}

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

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

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

.text {
Y
yma16 已提交
664
  font-size: 14px;
yma16's avatar
yma16 已提交
665 666 667
}

.item {
Y
yma16 已提交
668
  padding: 18px 0;
yma16's avatar
yma16 已提交
669 670 671
}

.box-card {
Y
yma16 已提交
672
  width: 100%;
yma16's avatar
yma16 已提交
673 674 675
}

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

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

.selectName a {
Y
yma16 已提交
693 694 695 696 697 698 699 700 701
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 80px;
  overflow: hidden;
  margin: 0;
  padding: 0;
yma16's avatar
yma16 已提交
702 703 704
}

.selectName a p {
Y
yma16 已提交
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719
  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 已提交
720 721 722
}

.selectName a:hover p {
Y
yma16 已提交
723
  color: #fff;
yma16's avatar
yma16 已提交
724 725 726
}

.selectName a span {
Y
yma16 已提交
727 728 729 730 731 732 733
  position: absolute;
  width: 100%;
  height: 100%;
  background: #fb7248;
  opacity: 0.5;
  z-index: -1;
  transition: 0.5s;
yma16's avatar
yma16 已提交
734 735 736
}

.selectName a span:nth-child(1) {
Y
yma16 已提交
737 738
  top: -100%;
  left: -100%;
yma16's avatar
yma16 已提交
739 740 741
}

.selectName a span:nth-child(2) {
Y
yma16 已提交
742 743
  bottom: -100%;
  left: -100%;
yma16's avatar
yma16 已提交
744 745 746
}

.selectName a span:nth-child(3) {
Y
yma16 已提交
747 748
  top: -100%;
  right: -100%;
yma16's avatar
yma16 已提交
749 750 751
}

.selectName a span:nth-child(4) {
Y
yma16 已提交
752 753
  bottom: -100%;
  right: -100%;
yma16's avatar
yma16 已提交
754 755 756
}

.selectName a:hover span:nth-child(1) {
Y
yma16 已提交
757 758
  top: 0px;
  left: 0px;
yma16's avatar
yma16 已提交
759 760 761
}

.selectName a:hover span:nth-child(2) {
Y
yma16 已提交
762 763
  bottom: 0px;
  left: 0px;
yma16's avatar
yma16 已提交
764 765 766
}

.selectName a:hover span:nth-child(3) {
Y
yma16 已提交
767 768
  top: 0px;
  right: 0px;
yma16's avatar
yma16 已提交
769 770 771
}

.selectName a:hover span:nth-child(4) {
Y
yma16 已提交
772 773
  bottom: 0px;
  right: 0px;
yma16's avatar
yma16 已提交
774 775 776
}

@media screen and (max-width: 450px) {
Y
yma16 已提交
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 823 824 825 826 827 828 829
  .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 已提交
830
    /* position: myblog_static; */
Y
yma16 已提交
831 832 833 834 835 836 837
    margin-top: 5%;
    width: 100%;
    text-align: letf;
    line-height: 50px;
    background: cadetblue;
    display: inline-block;
  }
yma16's avatar
yma16 已提交
838 839
}
</style>