...

View Full Version : Center CSS Icon



Zangeel
05-28-2009, 11:05 AM
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.

VIPStephan
05-28-2009, 11:19 AM
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.

frankle
05-28-2009, 12:23 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum