vajra_hendry Posted September 2, 2007 Share Posted September 2, 2007 This may sounds overly simple. However I have looked his up in my CSS book, and looked at severla websites. My problem is that I want to center an image on my page (well center the image within its containing block). I would normally just use Absolute or Relative positioning, however the Banner that im trying to align is an images thats passed from PHP so its different everytime!! COuld be like 125x125 pixles or it might be 468 x 60 pixels. So whatever the image is , I need CSS to just align is Center!! Any ideas please?! Thanks Quote Link to comment Share on other sites More sharing options...
bronzemonkey Posted September 2, 2007 Share Posted September 2, 2007 I would do the following: /*css*/ .image_center {margin:0 auto;} <!-- xhtml --> <div class="image_center"> <img src="" alt="" /> </div> The margin value of "auto" will automatically create equal left/right margins around an element with class="image_center"...which centers it within the container element. Make sure you're using a valid doctype and validate your CSS and markup. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.