美文网首页
背景图片整屏平铺

背景图片整屏平铺

作者: 給我小鱼干 | 来源:发表于2018-09-26 09:30 被阅读0次

第一种css

body{
      background:url(./login_01.jpg)  no-repeat center center;
      background-size:cover;
      background-attachment:fixed;
      background-color:#CCCCCC;
    }

第二种js

<template>
    <el-row>
        <el-col :span="24">
            <div ref='changeH' class="container">
              <div class="login-info">
                    <span class="login"></span>
                     <Login></Login>
                </div>
            </div>
        </el-col>
    </el-row>
</template>

<script>
import { Row, Col } from "element-ui";
import Login from './login/Login.vue'
export default {
  data() {
    return {
      cHeight: 0
    };
  },
  computed: {},
  created() {},
  mounted() {
    this.initHeight();
  },
  watch: {
    cHeight: function() {
      this.changeHeight(this.cHeight);
    }
  },
  methods: {
    changeHeight(h) {
      this.$refs.changeH.style.height = h + "px";
    },
    initHeight() {
      this.cHeight =
        document.documentElement.clientHeight || document.body.clientHeight;
      window.onresize = () => {
        this.cHeight =
        document.documentElement.clientHeight || document.body.clientHeight;
      };
    }
  },
  components: {
    Row,
    Col,
    Login
  }
};
</script>

<style scoped lang="scss" rel="stylesheet/sass">
.container{
  min-width: 1200px;
  background: url("./login_01.jpg") no-repeat center;
  background-size: 100% 100%;
}
@media screen and (min-width: 600px) {
   .login-info{
    background-color: rgba(255,255,255,0.8);
    border-radius: 10px;
    padding:60px;
    position:absolute;
    left:50%;
    top:50%;
    margin-left:-281px;
    margin-top:-219px;
    width: 400px;
      .login{
      margin-bottom: 50px;
      width:160px;
      height:35px;
      display:inline-block;
      background:url('./logo_03.png');
      background-size:100% 100%;
      }
  }
} 
@media screen and (min-width: 1920px) {
   .login-info{
    background-color: rgba(255,255,255,0.8);
    border-radius: 10px;
    padding:80px 120px;
    position:absolute;
    left:50%;
    top:50%;
    margin-left:-496px;
    margin-top:-239px;
    width: 752px;
    height:358px;
      .login{
      margin-bottom: 80px;
      width:160px;
      height:35px;
      display:inline-block;
      background:url('./logo_03.png');
      background-size:100% 100%;
      }
  }
    
}
a {
  outline: none !important;
}
</style>

第三种vh

html,body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-size: cover;
}

相关文章

  • 背景图片整屏平铺

    第一种css 第二种js 第三种vh

  • 背景

    background-color&background-image 背景颜色&背景图片 背景图片默认平铺显示,背景...

  • 设置背景图片及相关属性

    设置背景图片: 在CSS可以通过background-image: url();设置背景图片 控制背景图片的平铺方...

  • uni-app 背景相关

    背景图片固定大小 :背景图片大小,背景图片资源路径,背景的平铺方式 background-size: 100% 1...

  • 小试牛刀

    background-repeat用于控制背景图片的 重复方式。 如果只设置背景图片默认背景图片将会使 用平铺的方...

  • 2018-12-18

    给 UIView 设置背景图片 // 平铺 self.backgroundColor = UIColor(patt...

  • 背景

    设置背景颜色:background-color设置背景图片: 背景图片平铺: 背景定位 背景关联方式:滚动条和背景...

  • View设置大背景图片

    设置大背景图片 平铺 设置layer 设置ImageView draw绘制图片

  • CSS背景

    背景颜色:background-color背景图片:background-image平铺图片:background...

  • ## 背景

    ## 背景 # 百度首页案例 # 背景图片 background-image # 背景平铺属性 backgroun...

网友评论

      本文标题:背景图片整屏平铺

      本文链接:https://www.haomeiwen.com/subject/ysfdoftx.html