css实现:页面加载中的loading蒙层 loading垂直水平居中且转圈

实现:页面没加载完出现的loading蒙层


fixed实现效果如上图
如果用absoulte出现滚动条时 不会完全覆盖住


附上代码

<template>

  <div id="loading">

    <div class="loading_box" v-if="showLoading">

      <img src="../../../static/images/loading.png"/>

    </div>

  </div>

</template>

<script type="text/ecmascript-6">

  export default {

    name: 'loading',

    props: {

      showLoading: {

        type: Boolean,

        default: false

      }

    }

  }

</script>

<style>

  #loading {

    width: 100%;

  }

  #loading .loading_box {

    position: fixed;

    top: 0;

    bottom: 0;

    left: 0;

    right: 0;

    display: flex;

    justify-content: center;

    align-items: center;

    background: rgba(0, 0, 0, 0.4);

    z-index: 100000;

  }

  #loading .loading_box img {

    display: block;

    width:50px;

    height: 50px;

    animation: rotating 1s linear infinite;

  }

  @keyframes rotating {

    from { transform: rotate(0deg) } to { transform: rotate(360deg) }

  }

</style>

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容