简体   繁体   中英

How can I control an image being displayed in the html selector in css?

CODE:

html {
    background: url("/_images/back.png") no-repeat center center fixed; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

Using this I am able to display the image perfectly but the entire image doesn't get displayed from the top. If this were in a div i could display it properly and control via margin-top but with html I am limited unless there is something else.

How can I show the entire image? is there something similar to margin-top?

The background property is a shorthand for some background properties of CSS. One of them is the background-position which can hold positions like top , center , bottom , or left and right or values in % , px , em , cm and so on...

You don't need to use divs for that purpose.

So in your case, you may try background: url("/_images/back.png") no-repeat top left fixed; .

have you tried the body tag ? also you can try the yahoo css reset

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM