Centering a background image, using CSS

前端 未结 13 2102
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 03:59

I want to center a background image. There is no div used, this is the CSS style:

body{
    background-position:center;
    background-image:url(../images/im         


        
13条回答
  •  猫巷女王i
    2020-11-28 04:15

    I use this code, it works nice

    html, body {
      height: 100%;
      width: 100%;
      padding: 0;
      margin: 0;
      background: black url(back2.png) center center no-repeat;;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    }
    

提交回复
热议问题