Centering a background image, using CSS

前端 未结 13 2105
佛祖请我去吃肉
佛祖请我去吃肉 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条回答
  •  情书的邮戳
    2020-11-28 04:25

    if your not satisfied with the answers above then use this

        * {margin: 0;padding: 0;}
    
        html
        {
            height: 100%;
        }
    
        body
        {
            background-image: url("background.png");
            background-repeat: no-repeat;
            background-position: center center;
            background-size: 80%;
        }
    

提交回复
热议问题