1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to make background image align center via css?

Discussion in 'CSS' started by Sxperm, May 15, 2007.

  1. #1
    Hi,
    SEMrush
    I tried to make my background image align center but it did not work. here is my css

    
    #headerimage {
    	clear: both; 
    	background: #fff url(img/image.jpg) no-repeat 0 0;
    	margin: 10px; 
    	color: #fff; 
    	height: 200px;
    }
    
    Code (markup):
    please suggest me. :D
     
    Sxperm, May 15, 2007 IP
    SEMrush
  2. dylanmills

    dylanmills Peon

    Messages:
    50
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try adding

    background-position:center;
     
    dylanmills, May 15, 2007 IP
  3. Sxperm

    Sxperm Notable Member

    Messages:
    4,390
    Likes Received:
    142
    Best Answers:
    0
    Trophy Points:
    200
    #3
    Thanks :D It's worked.
     
    Sxperm, May 15, 2007 IP
  4. kk5st

    kk5st Prominent Member

    Messages:
    3,486
    Likes Received:
    367
    Best Answers:
    28
    Trophy Points:
    335
    #4
    Note that this:
    background: #fff url(img/image.jpg) no-repeat [color=red]0 0[/color];
    Code (markup):
    told the image to align top left. Had you left the "0 0" off, the default would have been to center vertically and horizontally. If you want to be explicit, use "center':
    background: #fff url(img/image.jpg) no-repeat center;
    Code (markup):
    cheers,

    gary
     
    kk5st, May 15, 2007 IP
  5. caj

    caj Active Member

    Messages:
    748
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    75
    #5

    Thank Gary - I've been figuring out why one of my blogs when view higher resolution look out of position. I've fixed it - by following what you told above. :D
     
    caj, Dec 14, 2008 IP
  6. kingdolar

    kingdolar Well-Known Member

    Messages:
    404
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    133
    #6
    its old thread, but i am very help me.. after search in google

    thanks mate
     
    kingdolar, Jun 8, 2012 IP
  7. henry001

    henry001 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It also helped me."background-position:center;"
     
    henry001, Jun 9, 2012 IP