Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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

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

Problem

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?

Problem courtesy of: starbucks

Solution

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;.

Solution courtesy of: DontVoteMeDown

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

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

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×