otuatail Posted December 15, 2009 Share Posted December 15, 2009 Can someone please tell me how to align an image in a div. I have tried several ways without success. www.des-otoole.co.uk?counter=0 Desmond. Link to comment https://forums.phpfreaks.com/topic/185253-align-an-image/ Share on other sites More sharing options...
FaT3oYCG Posted December 15, 2009 Share Posted December 15, 2009 float:center; ? Link to comment https://forums.phpfreaks.com/topic/185253-align-an-image/#findComment-978069 Share on other sites More sharing options...
teamatomic Posted December 16, 2009 Share Posted December 16, 2009 There is no float center. img.centered { display: block; margin-left: auto; margin-right: auto; } HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/185253-align-an-image/#findComment-978169 Share on other sites More sharing options...
otuatail Posted December 17, 2009 Author Share Posted December 17, 2009 Hi I have created this style in a seperate style sheet but not sure how it is implemented. #CenterMe { display: block; margin-left: auto; margin-right: auto; } <div style="border-style:solid;border-width:1px;border-color:green;width:580px"> <div style=CenterMe> <img src="MalawiPics/MalawiMe.jpg" alt=""> </div> </div> Link to comment https://forums.phpfreaks.com/topic/185253-align-an-image/#findComment-979051 Share on other sites More sharing options...
vinpkl Posted December 17, 2009 Share Posted December 17, 2009 # means id in css <div style="border-style:solid;border-width:1px;border-color:green;width:580px"> <div id="CenterMe"> <img src="MalawiPics/MalawiMe.jpg" alt=""> </div> </div> vineet Link to comment https://forums.phpfreaks.com/topic/185253-align-an-image/#findComment-979073 Share on other sites More sharing options...
otuatail Posted December 17, 2009 Author Share Posted December 17, 2009 I have tried this But it still is not aligned <div style="border-style:solid;border-width:1px;border-color:green;width:580px"> <div id="CenterMe"> <img src="MalawiPics/MalawiMe.jpg" alt=""> </div> </div> www.des-otoole.co.uk?counter=0 Link to comment https://forums.phpfreaks.com/topic/185253-align-an-image/#findComment-979237 Share on other sites More sharing options...
vinpkl Posted December 17, 2009 Share Posted December 17, 2009 your html code is fine. just replace your css with this #CenterMe { display: block; margin-left: auto; margin-right: auto; width:150px; } in this css replace 150px with the actual image width. vineet Link to comment https://forums.phpfreaks.com/topic/185253-align-an-image/#findComment-979241 Share on other sites More sharing options...
otuatail Posted December 17, 2009 Author Share Posted December 17, 2009 Great thanks this wors now. Desmond. Link to comment https://forums.phpfreaks.com/topic/185253-align-an-image/#findComment-979251 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.