Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How to centre a Background image

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #43070

    Hi New here and to CSS. I have looked everywhere but can’t find or work out how to centre a background image.
    I have a header and want to use an image as the background. I have set the background image and tried using left and right margin as auto. However the image always goes to the left. I want to use it for a mobile site, and just need a small image to be in the centre. I am using Dreamweaver CS6 on a mac.

    Any help would be appreciated.

    #126562
    AlanFall
    Member

    You should try this:

    element(your header) {
    background: url(imagepath/bg.png) no-repeat center center;
    }

    #126571

    Many thanks….. you’re a genius

    #126633
    Alen
    Participant

    [You might also look at this implementation](https://css-tricks.com/perfect-full-page-background-image).

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.