PDA

View Full Version : Center an image vertically and horizontally


Mark_W
08-02-2007, 07:28 PM
Hi there,

I am trying to centre an image vertically and horizontally. I can get it to centre vertically, however I'm having trouble with centring it horizontally.

This is the code I am currently using.


#prem {
background:#FFFFFF;
width:280px;
height:140px;
margin:10px auto auto 10px;
float:left;
border: 1px solid #000000;
}
#leaguelogo {
text-align:center;
}<div id="prem">
<div id="leaguelogo">
<img src="images/Premierleague.PNG" border="0" title="Click to view all the grounds in the English Premier League" />
</div>
</div>

Its just I have looked everywhere but I cannot find an answer.

domedia
08-02-2007, 08:00 PM
#leaguelogo img {display: block; text-align: center; margin-left: auto; margin-right: auto;}

Mark_W
08-02-2007, 08:09 PM
Nope, for some reason it still doesn't want to do it, I've tried that code before you see.

m1a2x3x7
08-03-2007, 02:18 AM
try this

#leaguelogo {
text-align:center;
height: auto;
width: auto;
margin: 19%;
}

domedia
08-03-2007, 09:04 AM
Can you give the whole page code, so I can see what cancels the CSS i just gave you?