简体   繁体   English

如何控制CSS中HTML选择器中显示的图像?

[英]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. 如果在div中,我可以正确显示它并通过margin-top进行控制,但是使用html时我会受到限制,除非有其他问题。

How can I show the entire image? 如何显示整个图像? is there something similar to margin-top? 有没有类似于margin-top的东西?

The background property is a shorthand for some background properties of CSS. background属性是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... 其中之一是background-position ,可以保留诸如topcenterbottomleftright%pxemcm等值的位置。

You don't need to use divs for that purpose. 您无需为此目的使用div。

So in your case, you may try background: url("/_images/back.png") no-repeat top left fixed; 因此,您可以尝试使用以下方法background: url("/_images/back.png") no-repeat top left fixed; .

have you tried the body tag ? 您是否尝试过车身标签? also you can try the yahoo css reset 您也可以尝试yahoo CSS重置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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