Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Center CSS Icon

  1. #1
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts

    Center CSS Icon

    So im embedding icons via css / divs like

    .icon
    {
    width:16px;
    height:16px;
    background-image:url(url.jpg);
    }

    then i embed like

    <div class="icon"></div>

    problem is I want this icon to be centered in the page, but its being quite stubborn, center tags, the div attribute align="center", etc, dont work.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,680
    Thanks
    6
    Thanked 1,009 Times in 982 Posts
    Please show us your entire code (at best by posting a link to the page in question). I’m 100% sure that the way you’re trying it is not the correct approach. The fact that you’re adding an empty element just to apply a background image just can’t be right.

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    74
    Thanks
    0
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by Zangeel View Post
    So im embedding icons via css / divs like

    .icon
    {
    width:16px;
    height:16px;
    background-image:url(url.jpg);
    }

    then i embed like

    <div class="icon"></div>

    problem is I want this icon to be centered in the page, but its being quite stubborn, center tags, the div attribute align="center", etc, dont work.

    Try replacing your css with this :


    .icon
    {
    width:16px;
    height:16px;
    background-image:url(url.jpg);
    background-position:center;
    }


    I am not sure what you want. Just in case this may help you.


    Regards.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •