CSS background image on top of

前端 未结 3 885
生来不讨喜
生来不讨喜 2020-12-01 14:50

How does one repeat this 1px x 1px CSS background image on top of the HTML ?

http://jsfiddle.net/hjv74tdw/1/

I came

3条回答
  •  有刺的猬
    2020-12-01 15:32

    Another way, is to set content to empty and set a background, for example:

    img {
        background: url(...) center center no-repeat;
        background-size: cover;
        content: '';
        display: block;
        width: 800px;
        height: 100px;
    }
    

    Here is a demo: http://jsfiddle.net/infous/effmea8x/

    In this demo the first image is standard but with unproportional width and hight, the second one is with the background. The first one is scaled badly, the second one is OK.

提交回复
热议问题