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

'background-position' on 'background-color' with CSS

'background-position' on 'background-color' with CSS


I'm trying to use 'bakground-position' in the background of my div, but not working. When background an image, the 'background-position' works, but with 'background-color' is not working. What can I do?

This is my CSS:

#defaultContent {
    width: 983px;
    min-height: 382px;
    margin: 0 auto;
    background-color: #000000;
    background-position: right 50px;
Problem courtesy of: user2297392


You can workaround with a div only for background, simulating it by mixing position: absolute offsets and negative z-index.. (Though I've tested only in chrome)

See fiddle



#defaultContentParent {
    border: 1px solid #00f;
    background-color: #aaa;
    color: #fff;
    position: relative;    
    width: 200px;
    min-height: 140px;
    margin: 0 auto;
    z-index: 0;

#defaultContent {
    background-color: #000000;
    height: 50px;
    position: absolute;
        top: 50px;
        right: 0;
    width: 80px;
    z-index: -1;

#defaultContentContent {
    z-index: 9999;
Solution courtesy of: Andre Figueiredo


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

'background-position' on 'background-color' with CSS


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

Get updates delivered right to your inbox!

Thank you for your subscription