Csslearn.vue 7.5 KB
Newer Older
yma16's avatar
yma16 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
<template>
  <div class="container">
    <div class="box_left">
      <div style="padding: 10px">
        <h2>{{ msg }}{{ css_length }}</h2>
        <h2 style="font-size: 1em">选择:{{ now_title }}</h2>
      </div>
      <!-- 标题传递索引 -->
      <div class="css_title">
        <ul v-for="(item, index) in css_title" :key="index" class="ul_style">
          <div v-bind:class="[{ li_active: index == css_loc }, li_errorClass]">
            <li @click="get_ifreame(index)">
              {{ index + 1 }}.&nbsp;{{ item }}
            </li>
          </div>
        </ul>
      </div>
    </div>
    <div class="box_right">
      <!-- 全屏线框 -->
      <div class="fullscreen" @click="fullScreenFun">
        <span></span> {{ screenmsg }}
      </div>
      <!-- 绑定src参数 -->
      <iframe v-bind:src="ifreame_content" id="iframeId"></iframe>
    </div>
  </div>
</template>

<script>
export default {
yma16's avatar
yma16 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
    name: 'Csslearn',
    data () {
        return {
            screenmsg: '全屏',
            msg: 'css练习:',
            css_length: '',
            // baseurl: 'http://127.0.0.1:1998',
            baseurl: '/api/',
            // baseurl: "http://yongma16.xyz/",
            css_title: [],
            css_path: [],
            css_loc: 0,
            ifreame_content: '',
            look_i: '浏览:',
            now_title: ''
yma16's avatar
yma16 已提交
47 48
        }
    },
yma16's avatar
yma16 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    methods: {
        fullScreenFun: function () {
            window.parent.location.href = this.ifreame_content
            function launchFullscreen (element) {
                if (element.requestFullscreen) {
                    element.requestFullscreen()
                } else if (element.mozRequestFullScreen) {
                    element.mozRequestFullScreen()
                } else if (element.msRequestFullscreen) {
                    element.msRequestFullscreen()
                } else if (element.webkitRequestFullscreen) {
                    element.webkitRequestFullScreen()
                }
            }

            launchFullscreen(document.documentElement)
            // launchFullscreen(document.getElementById('iframeId')) // 某个元素进入全屏
            window.parent.location.href = this.ifreame_content
        },
        li_errorClass: function () {
        },
        get_ifreame: function (index) {
            let that = this // that
            that.ifreame_content = that.css_path[index] // 路径
            that.css_loc = index // 索引传递
            that.now_title = index + 1 + '. ' + that.css_title[index] // 标题
        },
        getCss: function () {
            try {
                document.getElementById('mainappid').style.padding = '0'
                document.getElementById('mainappid').style.margin = '0'
            } catch (e) {
                throw Error(e)
            }
yma16's avatar
yma16 已提交
83

yma16's avatar
yma16 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
            let that = this
            that.$axios
                .get(that.baseurl + 'css/')
                .then((res) => {
                    let getdata = res.data
                    let csspath = getdata.path
                    let csstitle = getdata.title
                    csspath.map((o) => {
                        that.css_path.push(o)
                    })
                    // 标题传递
                    // eslint-disable-next-line camelcase
                    that.css_title = csstitle
                    // 传递第一个路html路径
                    that.ifreame_content = that.css_path[0]
                    // 传递长度
                    that.css_length = csstitle.length
                    that.now_title = csstitle.length > 0 ? 1 + '. ' + csstitle[0] : '' // 标题加序号
                })
                .catch((error) => {
                    throw Error(error)
                })
        }
    },
    mounted () {
        let that = this
        that.getCss() // get请求
yma16's avatar
yma16 已提交
111
    },
yma16's avatar
yma16 已提交
112 113 114 115 116
    created () {
        let that = this
        window.onload = that.getCss // get请求
    }
}
yma16's avatar
yma16 已提交
117 118
</script>

Y
yma16 已提交
119
<style scoped>
yma16's avatar
yma16 已提交
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 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 279 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 324 325 326
.container {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}
.box_left {
  position: relative;
  left: 0;
  width: 20%;
  height: 100%;
  background: #fff;
  transition: 0.5s;
  overflow: auto;
  /* 超出部分 不溢出 */
}
/* 滚动条的隐藏 css3特性 */
.box_left::-webkit-scrollbar {
  display: none;
}
/* .box_left:hover {
  background: #646464;
} */
.box_left h2 {
  color: rgb(0, 140, 255);
  text-align: left;
  line-height: 20px;
}
.box_left:hover h2 {
  color: rgb(0, 140, 255);
}
.box_right {
  position: relative;
  right: 0;
  width: 100%;
  height: 100%;
  background: coral;
}
.box_right iframe {
  position: relative;
  width: 100%;
  height: 100%;
  appearance: none;
  border: none;
  border-left: 3px solid rgb(248, 183, 157);
}
.css_title {
  text-align: center;
  width: 100%;
}
.ul_style {
  position: relative;
  width: 100%;
  height: 20px;
  display: flex;
  align-content: center;
  /* 取消头部 */
  list-style: none;
  appearance: none;
  /* border:1px solid rgb(253, 135, 0); */
  background: transparent;
  padding: 10px;
  margin: 2px;
  /* transition: 0.5s; */
}
.ul_style:hover {
  background: rgb(0, 140, 255);
  box-shadow: 0 2px 20px rgb(0, 140, 255);
}
.ul_style li {
  appearance: none;
  position: absolute;
  text-align: left;
  width: 100%;
  height: 100%;
  font-weight: bold;
  color: rgb(252, 118, 8);
  background: transparent;
  cursor: pointer;
  line-height: 20px;
  /* transition: 0.5s; */
}

.li_active li {
  appearance: none;
  position: relative;
  text-align: left;
  width: 100%;
  height: 100%;
  font-weight: bold;
  color: rgb(0, 140, 255);
  text-shadow: 0 5px 20px #fff;
  background: transparent;
  cursor: pointer;
  line-height: 20px;
  /* transition: 0.5s; */
}
.li_errorClass li {
  appearance: none;
  position: absolute;
  text-align: left;
  width: 100%;
  height: 100%;
  font-weight: bold;
  color: rgb(0, 140, 255);
  background: transparent;
  cursor: pointer;
  line-height: 20px;
  /* transition: 0.5s; */
}
.box_left:hover .ul_style:hover li:hover {
  font-weight: bolder;
  color: #fff;
  /* box-shadow: 0 2px 20px #fff; */
  cursor: pointer;
  /* border:1px solid rgb(253, 135, 0); */
}

.box_left:hover .ul_style li {
  font-weight: bolder;
  /* color: rgb(252, 118, 8); */
  /* color: rgb(255, 255, 255); */
  /* box-shadow: 0 2px 20px #fff; */
  cursor: pointer;
  /* border:1px solid rgb(253, 135, 0); */
}

/* 全屏线框 */
.fullscreen {
  position: fixed;
  width: 140px;
  height: 50px;
  float: right;
  line-height: 50px;
  text-align: center;
  top: 10%;
  right: 10px;
  z-index: 1;
  background: #262626;
  color: #7efff5;
  font-weight: bold;
  text-shadow: 0 10px 20px #7efff5;
  cursor: pointer;
  box-sizing: border-box;
}
.fullscreen::before,
.fullscreen::after,
span::before,
span::after {
  position: absolute;
  content: "";
  width: 10px;
  height: 10px;
  background: #7efff5;
  mix-blend-mode: hue;
  transition: 1s;
}

.fullscreen::before {
  top: -2px;
  left: -2px;
}

.fullscreen::after {
  top: -2px;
  right: -2px;
}

span::before {
  bottom: -2px;
  left: -2px;
}

span::after {
  bottom: -2px;
  right: -2px;
}

/* 上下左右 */
.fullscreen:hover::before,
.fullscreen:hover::after,
.fullscreen:hover span::before,
.fullscreen:hover span::after {
  width: calc(140px / 2);
  height: calc(50px / 2);
  box-shadow: 0 5px 20px #7eabff;
}
@media screen and (max-width: 450px) {
  .container {
    position: relative;
    display: inline-block;
    /* box-sizing: border-box; */
  }
  .box_left {
    position: relative;
    width: 100%;
    height: 50%;
  }
  .box_right {
    position: relative;
    width: 100%;
    height: 100%;
  }
}
</style>