Ivan Ivković Posted April 30, 2012 Share Posted April 30, 2012 This is the code: <html> <head> <style> #parent{ border: 1px solid black; width: 90%; position: relative; left: 5%; padding: 1%; } #parent > div{ width: 10%; border: 1px solid #ccc; } #parent > div > img{ width: 100%; } </style> </head> <body> <div id="parent"> <div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div> <div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div> <div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div><div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div><div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div><div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div><div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div><div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div><div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div><div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div><div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div><div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div> <div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div> <div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div> <div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div> <div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div> <div> Planet Earth <img src="http://t3.gstatic.com/images?q=tbn:ANd9GcSmMWgMiKcAfjiYUAUz8dEM90_KrDnlXq4_6hnzKd83W03ykxal"> user : Franko </div> </div> </body> </html> Display: inline-block does not work in IE. Floats are not a solution because it makes the parent div have a small height. It needs to look like this: https://www.box.com/s/2b73018fa44f89bea191 The content is dynamic, so fixed height won't work also. Link to comment https://forums.phpfreaks.com/topic/261836-how-to-put-div-elements-centered-in-same-line-containing-images-and-text/ Share on other sites More sharing options...
Jessica Posted April 30, 2012 Share Posted April 30, 2012 You should be able to do a float with a clearing element after it, to make the parent div have the correct height. <br style="clear: both" /> after your floated elements. Link to comment https://forums.phpfreaks.com/topic/261836-how-to-put-div-elements-centered-in-same-line-containing-images-and-text/#findComment-1341679 Share on other sites More sharing options...
Ivan Ivković Posted May 2, 2012 Author Share Posted May 2, 2012 I have done that and succeded. Thank you. How do I center them now?? Link to comment https://forums.phpfreaks.com/topic/261836-how-to-put-div-elements-centered-in-same-line-containing-images-and-text/#findComment-1342238 Share on other sites More sharing options...
Jessica Posted May 2, 2012 Share Posted May 2, 2012 You'll have to play around with it, but you could probably put a wrapper around them with margin: 0 auto; Link to comment https://forums.phpfreaks.com/topic/261836-how-to-put-div-elements-centered-in-same-line-containing-images-and-text/#findComment-1342282 Share on other sites More sharing options...
Ivan Ivković Posted May 3, 2012 Author Share Posted May 3, 2012 I want something that does the effect like text-align: center.. But yea it doesn't work for floats. Link to comment https://forums.phpfreaks.com/topic/261836-how-to-put-div-elements-centered-in-same-line-containing-images-and-text/#findComment-1342559 Share on other sites More sharing options...
Jessica Posted May 3, 2012 Share Posted May 3, 2012 You'll have to put a div around them, set it's width, and then give it a margin of 0 auto; Link to comment https://forums.phpfreaks.com/topic/261836-how-to-put-div-elements-centered-in-same-line-containing-images-and-text/#findComment-1342640 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.