Onlinewebsocket.vue 21.0 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 36
              { room_active: index == room_loc },
              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 78 79 80 81 82 83
      <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}} -->
            <template v-if="item.room == room_select">
              <div
                v-for="(item2, index2) in item.content"
                :key="index2"
                class="msgClass"
                v-bind:class="[
yma16's avatar
yma16 已提交
84 85
                  { info_active: ws_flag == true },
                  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 130 131
</template>

<script>
import VueMarkdown from "vue-markdown";
import axios from "axios";

export default {
Y
yma16 已提交
132 133 134 135 136 137 138 139 140 141 142 143
  components: {
    VueMarkdown,
  },
  name: "Onlinewebsocket",
  data() {
    return {
      ws_flag: false,
      msg: "连接中",
      send_info: "hello world!",
      room_name: ["DjangoVue"],
      room_select: "",
      // baseUrl: "http://localhost:8006/webchat/index/",
yma16's avatar
yma16 已提交
144 145 146
      baseUrl: "http://yongma16.xyz/api/",
      // websocketUrl: "/ws_api/",
      websocketUrl: "ws://yongma16.xyz/ws-api/",
Y
yma16 已提交
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
      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='连接成功'
    };
  },
  watch() {
    // cookieValue:function(newValue,oldValue){
    //   this.user=newValue
    //   console.log(newValue,oldValue)
    //   return newValue
    // }
  },
  beforeDestroy() {
    // window.removeEventListener("onload",this.initWebsocket());
  },
  mounted() {
    // 判断是否登录
    this.judeIsLogin();
    // window.addEventListener("onload",this.initWebsocket());
  },
  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);
      }
      // 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];
      //     let selectNameDom = document.getElementById("selectNameId");
      //     console.log(selectNameDom);
      //     selectNameDom.style.display = "none";
      //   }
      //   console.log(arrname == "user", arrname + ":" + arr[1]);
      // }
yma16's avatar
yma16 已提交
209
    },
Y
yma16 已提交
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 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
    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();
      // console.log('this.websocket.chat_info',this.websocket.chat_info)
      // console.log('this.websocket.chat_info.content',this.websocket.chat_info.content)
      this.websocket.chat_info[this.chatRoomIndex].content = [];
      // console.log('this.websocket.chat_info.content',this.websocket.chat_info.content)
      // this.websocket.chat_info=null;
      // this.websocket.chat_info=new Array()
    },
    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(), //毫秒
yma16's avatar
yma16 已提交
279
        };
Y
yma16 已提交
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 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
        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;
      };

      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++;

      // 默认第一个房间
      let room = roomName != undefined ? roomName : this.room_name[0];
      // 判断房间是否存在,不存在则创建房间
      let chatRoomIndex = 0;
      try {
        //判断房间是否存在
        let roomFlag = false;
yma16's avatar
yma16 已提交
324 325
        this.chat_info.map((item, index) => {
          if (item.room == roomName) {
Y
yma16 已提交
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
            // 房间存在
            console.log("房间存在", roomName);
            roomFlag = true;
            chatRoomIndex = index;
          }
        });
        if (!roomFlag) {
          // 房间不存在,创建

          let roomObject = {
            room: room,
            content: [],
          };
          this.chat_info.push(roomObject);
          console.log("创建房间", this.chat_info);
        }
      } catch (e) {
        console.log("创建房间出错", e);
      }
      this.chatRoomIndex = chatRoomIndex;
yma16's avatar
yma16 已提交
346
      const wsUrl = this.websocketUrl;
Y
yma16 已提交
347 348 349 350 351 352 353 354 355 356
      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);
yma16's avatar
yma16 已提交
357
    },
Y
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
    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!");

        // 人数记录,只会后加入的
      }
      if (true) {
        //  房间计数
        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,
        };
        // 添加信息

        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);
      }
yma16's avatar
yma16 已提交
405
    },
Y
yma16 已提交
406 407 408
    websocketOpen: function (info) {
      this.websocketSend(info);
      // this.send_info=''//清空
yma16's avatar
yma16 已提交
409
    },
Y
yma16 已提交
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
    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 = "连接失败";
      }
yma16's avatar
yma16 已提交
431
    },
Y
yma16 已提交
432 433 434 435 436 437 438
    websocketError: function () {
      this.msg = "连接失败";
      let selectNameDom = document.getElementById("selectNameId");
      console.log(selectNameDom);
      selectNameDom.style.display = "block";
      window.alert("websocket连接失败!");
      // this.initWebsocket()// 重连
yma16's avatar
yma16 已提交
439
    },
Y
yma16 已提交
440 441 442 443 444 445 446 447 448
    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 已提交
449
    },
Y
yma16 已提交
450 451 452 453
  },
  destroyed() {
    this.websocketClose(); // 关闭
  },
yma16's avatar
yma16 已提交
454 455 456 457 458
};
</script>

<style scoped>
.selectName {
Y
yma16 已提交
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477
  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 已提交
478 479 480
}

.selectInput {
Y
yma16 已提交
481 482 483 484 485 486 487
  position: relative;
  width: 50%;
  height: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
yma16's avatar
yma16 已提交
488 489 490
}

.selectInput h1 {
Y
yma16 已提交
491 492
  font-size: 3em;
  color: #fb7248;
yma16's avatar
yma16 已提交
493 494 495
}

.btn_fx {
Y
yma16 已提交
496 497 498
  position: relative;
  padding: 20px;
  /* margin:20px; */
yma16's avatar
yma16 已提交
499 500 501
}

.blockChat {
Y
yma16 已提交
502 503 504
  position: relative;
  width: 100%;
  display: block;
yma16's avatar
yma16 已提交
505 506 507
}

.blockChat h1 {
Y
yma16 已提交
508 509 510
  color: rgb(135, 187, 222);
  font-size: 20px;
  font-weight: bold;
yma16's avatar
yma16 已提交
511 512 513
}

.msgClass {
Y
yma16 已提交
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
  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 已提交
530 531 532 533
  -webkit-text-fill-color: transparent; */
}

.msgUser {
Y
yma16 已提交
534 535 536 537 538 539 540 541
  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 已提交
542 543 544
}

.msgMessage {
Y
yma16 已提交
545
  position: relative;
yma16's avatar
yma16 已提交
546

Y
yma16 已提交
547 548 549 550 551
  width: 100%;
  height: 50px;
  font-size: 20px;
  color: rgb(0, 0, 0);
  /* background: rgb(135, 187, 222); */
yma16's avatar
yma16 已提交
552 553 554
}

.msgMessage p {
Y
yma16 已提交
555 556 557 558 559
  position: relative;
  /* left:50%; */
  margin: 5px;
  padding: 5px;
  top: 50%;
yma16's avatar
yma16 已提交
560 561 562
}

.left_top {
Y
yma16 已提交
563 564 565 566 567
  position: relative;
  cursor: pointer;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
yma16's avatar
yma16 已提交
568 569 570
}

.left_top p {
Y
yma16 已提交
571 572 573
  font-size: 20px;
  margin-bottom: 5px;
  padding-bottom: 5px;
yma16's avatar
yma16 已提交
574 575 576
}

.roomNameClass {
Y
yma16 已提交
577 578
  position: relative;
  cursor: pointer;
yma16's avatar
yma16 已提交
579 580 581
}

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

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

.info_active {
Y
yma16 已提交
613 614 615 616 617 618 619 620 621 622 623 624 625
  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 已提交
626 627 628
}

.info_defaultClass {
Y
yma16 已提交
629 630 631 632 633 634 635 636 637
  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 已提交
638 639 640
}

@keyframes sendInfo {
Y
yma16 已提交
641 642 643
  0% {
    background-position: 0% 50%;
  }
yma16's avatar
yma16 已提交
644

Y
yma16 已提交
645 646 647
  50% {
    background-position: 100% 50%;
  }
yma16's avatar
yma16 已提交
648

Y
yma16 已提交
649 650 651
  100% {
    background-position: 0% 50%;
  }
yma16's avatar
yma16 已提交
652 653 654
}

.container {
Y
yma16 已提交
655 656 657 658 659 660 661 662 663 664 665 666 667
  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 已提交
668 669 670 671 672
}

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

.left {
Y
yma16 已提交
677 678 679 680 681 682
  position: relative;
  width: 30%;
  height: 100%;
  overflow: auto;
  margin: 5px;
  padding: 5px;
yma16's avatar
yma16 已提交
683 684 685
}

.right {
Y
yma16 已提交
686 687 688 689 690 691
  position: relative;
  width: 70%;
  height: 100%;
  overflow: auto;
  margin: 5px;
  padding: 5px;
yma16's avatar
yma16 已提交
692 693 694
}

.text {
Y
yma16 已提交
695
  font-size: 14px;
yma16's avatar
yma16 已提交
696 697 698
}

.item {
Y
yma16 已提交
699
  padding: 18px 0;
yma16's avatar
yma16 已提交
700 701 702
}

.box-card {
Y
yma16 已提交
703
  width: 100%;
yma16's avatar
yma16 已提交
704 705 706
}

.input_chat1 {
yma16's avatar
yma16 已提交
707
  /* position: myblog_static; */
Y
yma16 已提交
708 709 710 711
  margin-top: 5%;
  text-align: letf;
  line-height: 50px;
  /* background: cadetblue; */
yma16's avatar
yma16 已提交
712 713 714
}

.input_chat2 {
yma16's avatar
yma16 已提交
715
  /* position: myblog_static; */
Y
yma16 已提交
716 717 718 719 720
  margin-top: 5%;
  text-align: letf;
  line-height: 50px;
  background: cadetblue;
  display: none;
yma16's avatar
yma16 已提交
721 722 723
}

.selectName a {
Y
yma16 已提交
724 725 726 727 728 729 730 731 732
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 80px;
  overflow: hidden;
  margin: 0;
  padding: 0;
yma16's avatar
yma16 已提交
733 734 735
}

.selectName a p {
Y
yma16 已提交
736 737 738 739 740 741 742 743 744 745 746 747 748 749 750
  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 已提交
751 752 753
}

.selectName a:hover p {
Y
yma16 已提交
754
  color: #fff;
yma16's avatar
yma16 已提交
755 756 757
}

.selectName a span {
Y
yma16 已提交
758 759 760 761 762 763 764
  position: absolute;
  width: 100%;
  height: 100%;
  background: #fb7248;
  opacity: 0.5;
  z-index: -1;
  transition: 0.5s;
yma16's avatar
yma16 已提交
765 766 767
}

.selectName a span:nth-child(1) {
Y
yma16 已提交
768 769
  top: -100%;
  left: -100%;
yma16's avatar
yma16 已提交
770 771 772
}

.selectName a span:nth-child(2) {
Y
yma16 已提交
773 774
  bottom: -100%;
  left: -100%;
yma16's avatar
yma16 已提交
775 776 777
}

.selectName a span:nth-child(3) {
Y
yma16 已提交
778 779
  top: -100%;
  right: -100%;
yma16's avatar
yma16 已提交
780 781 782
}

.selectName a span:nth-child(4) {
Y
yma16 已提交
783 784
  bottom: -100%;
  right: -100%;
yma16's avatar
yma16 已提交
785 786 787
}

.selectName a:hover span:nth-child(1) {
Y
yma16 已提交
788 789
  top: 0px;
  left: 0px;
yma16's avatar
yma16 已提交
790 791 792
}

.selectName a:hover span:nth-child(2) {
Y
yma16 已提交
793 794
  bottom: 0px;
  left: 0px;
yma16's avatar
yma16 已提交
795 796 797
}

.selectName a:hover span:nth-child(3) {
Y
yma16 已提交
798 799
  top: 0px;
  right: 0px;
yma16's avatar
yma16 已提交
800 801 802
}

.selectName a:hover span:nth-child(4) {
Y
yma16 已提交
803 804
  bottom: 0px;
  right: 0px;
yma16's avatar
yma16 已提交
805 806 807
}

@media screen and (max-width: 450px) {
Y
yma16 已提交
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 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860
  .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 已提交
861
    /* position: myblog_static; */
Y
yma16 已提交
862 863 864 865 866 867 868
    margin-top: 5%;
    width: 100%;
    text-align: letf;
    line-height: 50px;
    background: cadetblue;
    display: inline-block;
  }
yma16's avatar
yma16 已提交
869 870
}
</style>