CSS - Div's Does Not Expand In Height As The Image Inserted Inside
I attached an image with an exemple of my problem, left side is from Internet explorer and right side is from Opera and Firefox.
The div in which I inserted that image does not expand in height as much as the image height .. only on how much text I insert in that div. How can I fix this in opera and firefox ? PHP Code: .bggrad{ background-image:url(images/bg-gradient-b-w.gif); width:486px; text-align:left; height:auto; /* INITIALY I DID NOT USED HEIGHT BUT IT WAS THE SAME */ } img.img_event{ padding:4px; border:1px solid #FFC91B; background-color:#FFF4CB; margin:10px; } <div class="bggrad"> <img src="images/test.gif" width="117" height="148" border="0" class="img_event" align="left"> text text text text </div> 10x in advance Similar TutorialsIt seems I get one or the other, but not all. Hi, Is there any way to set a DIV that starts at 500px height but can grow if the content inside is longer than that? Thanks. God, this is really simple but I have forgotten how to get the containing box to expand Basically the text div expands but the containing div doesn't PHP Code: <div style="width: 300px; min-height: 200px; border: 1px dashed red;"> <div style="border: 0; width: 110px; height: 110px; float: left;"> <img src="#" width="100" height="80" border="0" align="left" /> </div> <div style="border: 0; width: 190px; min-height: 200px; float: right;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In odio nibh, interdum eget, mollis quis, imperdiet non, risus. Curabitur laoreet vehicula massa. Curabitur consequat dui vitae lectus. Nam rutrum sapien id quam. Pellentesque aliquet nulla dignissim ante. Fusce metus libero, vehicula hendrerit, condimentum id, malesuada in, elit. Nam fermentum, metus in varius scelerisque, diam purus tristique tortor, vitae suscipit elit ipsum eu dolor. Ut dictum porttitor velit. Pellentesque cursus purus elementum dui. Phasellus aliquet ante vitae pede. </div> </div> I have an absolutely position <div> with some content positioned within it. I do not always know the size of the inner content so my problem is getting the outer div to expand to the height of the inner div. Is there a solution for this with absolutely positioned items that wil work in IE/Firefox/Safari? I'm attaching a simple html file which mimics what i am trying to accomplish and the code is below: Code: <div id="detailBlock" style="position: absolute; width: 250px; height: 35px; z-index: 3; border: 1px solid #000; overflow: visible; background-color: #fff5d9; font-size: 8pt; top: 50px; left: 100px;"> <div id="closeBlock" style="position: absolute; width: 40px; height: 8px; left: 210px; top: 3px; font-size: 7pt;"><a href="javascript: closeDetail();">CLOSE</a></div> <div id="detailContent" style="position: relative; width: 240px; top: 15px; left: 5px; border: 1px solid #F00;">Content whose size i do not know...So if I write anything substantial in here it will go over the edge</div> Thanks in advance for your help. I searched for something I want but I didn't find exactly that, or maibe something is wrong but in IE the page does not look ok. What I want is to have my page looks identical in IE as in FF or OPERA. I will explain here how I done the code PHP Code: <td rowspan="2" width="600" align="left" height="100%" valign="top" > <div class="brand_list_big"> <div class="box_header" style="background-color:#79B602;">CARS LISTED BY BRANDS</div> <div class="box_content" style="width:560px;"> <div class="brand_list_header"><span style="float:left;"><strong>Audi</strong></span><span style="float: right;">Total Cars : 2</span></div> <div class="car_list"> <span class="fleft"><a href="#">audi tt</a></span><span class="fright"><img 1><img 2></span><br> <span class="fleft"><a href="#">Saturn Sky Roadster</a></span><span class="fright"><img 1><img 2></span><br> </div> ... <div class="brand_list_header"><span style="float:left;"><strong>Alfa-Romeo</strong></span><span style="float: right;">Total Cars : 0</span></div> ... div.box_header { width: 99,5%; margin: 1px 1px 1px 1px; padding: 5px 0 5px 0; font-weight:bold; font-size: 12px; font-family:Verdana, Arial, Helvetica, sans-serif; } div.box_content { margin: 0 1px 1px 1px; padding: 5px 5px 5px 5px; height: 100%; scrollbar-face-color:#7098DF; scrollbar-highlight-color:#7098DF; scrollbar-3dlight-color:#FFFFFF; scrollbar-darkshadow-color:#FFFFFF; scrollbar-shadow-color:#919AA4; scrollbar-arrow-color:#FFCC00; scrollbar-track-color:#FFFFFF; } .brand_list_header { width: 99,5%; padding: 2px 0 2px 5px; background-color:#E3FEB1; border: 1px solid #CCCCCC; border-bottom: 0 solid #CCCCCC; margin-top: 10px; overflow:auto; /* I added this now and in ff and Opera everithing is ok, but not in IE*/ } .car_list { border: 1px solid #CCCCCC; background-color:#FFFFFF; clear:both; overflow:auto; } .fleft { float: left; margin: 2px 2px 2px 10px; clear:left; } .fright { float: right; } img.new_img { margin: 2px 10px 0 0 ; /*the img from my code( <img 1>, <img 2> ) have this class*/ } Any Ideea why in IE the divs are not ok ? First I tried to list the cars from a brand using <li> elements but I didn't know how to align the images ( icons ) at the right side, like are now. 10x in advance, waiting for a response see ya Hello, I'm working on a website for a client: http://evoxdesigns.com/rimlox/ http://evoxdesigns.com/rimlox/rimlox.css My current problem is getting the body to scale to 100% height. At the moment, it stretches to 100% of the browser window, which is great, but if if the content within all the nested divs expands to a height larger than that of the screen, the background does expand with it. In my troubleshooting, I gave the body a 1px border and found out that the body remains at the fixed size of the window even though the content within it expands. I tried messing with the overflow property, all to no avail. I'd appreciate any help I can get on this one. What is the method to have a div expand to wrap all the elemetns inside it ? somethings work in IE, some work in Firefox and some work in Safari. I then apply the size to each page separately, but now I have also found out that browsers interpret px differently it seems. my page is www.mmimageart.com, you can go and see in the galleries how if you are using safari, the container div is not wrapping the elements inside. So any help would be appreciatted. Thanks. I'm a newbie to css. I'm trying to convert tables to css and having a bit of a tough time. Latest problem - create a window or container with a one line border with minimum height, say 600px, but the height will expand as the content grows. Any help? Thank you kindly! I'm trying to replicate what I had in html tables with css div. The final (I hope) problem is that as I populate cells with data retrieved from a MySQL data base there are columns that want to expand beyond the default height. When that happens, that cell overlaps the next row. If I use min-height, the cell alignment goes haywire because other cells are below the minimum. The workaround is to increase the default height, but that doesn't make me love divs. Is there a solution to this? Here's my code (stripped down--there'e a lot more to the application, and sanitised for anonymity). Thank you. <style type="text/css" media="screen, print, projection"> body, html { margin:0; padding:0; color:#000; background:LightBlue; } #wrap { width:99.5%; margin:0 auto; background:LightBlue; padding:0px 0px 0px 0px; border: none; } #p { float:left; width:72.5%; padding: 0px 0px 0px 0px; border: 3px solid navy; } # li { border-bottom: 1px solid navy; height: 36px; font-size:small; } #p li.header { border-bottom: 1px solid navy; font-weight:bold; font-size:medium; height: 24px; padding:0px 0px 0px 0px; } #p ul { margin:0; padding:0px; list-style:none; } #p p { font-weight:bold; font-size: medium: padding: 0px 0px 0px 0px; } #title { border-bottom: 1px solid navy; width:100%; } #button { float:left; border-bottom: 1px solid navy; border-right: 1px solid navy; width:10%; } #pt { float:left; border-bottom: 1px solid navy; border-right: 1px solid navy; width:20%; } #c { float:left; border-bottom: 1px solid navy; border-right: 1px solid navy; width:30%; } #ex { float:left; border-bottom: 1px solid navy; border-right: 1px solid navy; width:19%; } #az { float:left; border-bottom: 1px solid navy; border-right: 1px solid navy; width:9%; } #ep { float:left; border-bottom: 1px solid navy; width:11%; } </style> </head> <body> <?php // code to connect to mysql and do do some other stuff goes here $cl=field_already_retrieved_from db; echo "<div id=wrap>"; //wrapper for entire page (the real application does a lot more than this section $result = mysql_query //sql select statment goes here $num_rows = mysql_num_rows($result); echo "<div id='p'>"; //wrapper for p's echo "<div id='title'>"; echo "<ul><li class=header>Lines</li></ul>"; echo "</div>"; //end title while($row = mysql_fetch_array($result)) { $p=$row['p']; $v=$row['V']; echo "<form action='detail.php' method='post'> "; echo "<div id='button'>"; //button to display line detail echo "<ul><li>"; echo "<input type='submit' class='btn' name='line' value ='Detail'><input type='hidden' name='p' value ='$p'><input type='hidden' name='v' value ='$v'><input type='hidden' name='cl' value ='$cl'>"; echo "</li></ul>"; echo "</div>"; //end button echo "</form>"; echo "<div id='pt'>"; echo "<ul><li>"; echo $row['pt']; echo "</li></ul>"; echo "</div>"; //end pt echo "<div id='c'>"; echo "<ul><li>"; echo $row['c'] . "/" . $row['PN']; echo "</li></ul>"; echo "</div>";//end c echo "<div id='ex'>"; echo "<ul><li>"; echo $row['Ex']; echo "</li></ul>"; echo "</div>"; //end ex echo "<div id='az'>"; echo "<ul><li>"; echo $row['az']; echo "</li></ul>"; echo "</div>"; //end az echo "<div id='ep'>"; echo "<ul><li>"; echo $row['ep']; echo "</li></ul>"; echo "</div>"; //end ep echo "</form>"; } // end while (select lines from database) echo "</div>"; //end p--wrap for lines echo "</div>"; //end wrap--entire page mysql_close($con); ?> </body> </html> Hello, i'm trying to make a tableless image gallery, each image is inside <span></span> (i don't know the dimensions of the image, it's resized by server side) while the div container expands fine, the span container does not expand to fit the image, and i also don't know how to vertically center it. i can't use <div> because images can be in the same row. Code: body { margin:0px padding:10px; background-color: #ffffff } body, div,span { font-family: Arial; font-size: 12px; color: #000000 } a { color:#000099 } a:hover { color:#0000ff } div.paging { padding:10px; border:1px solid red; } div.paging span { padding-left:10px; border:1px solid red } div.gallery { padding:10px; border:1px solid red } div.gallery span { margin:20px; border:1px solid green; } div.gallery img { border:1px solid black } this is the result http://addf.net/tests/m_g/gallery.php is float the only option? must i float every element on the page? what if it's a module for another not floated website? i'd rather not use float or a table. if you could help thank you Hey there! First off, take a look he http://apollomix.com As you can see, I have that little chat box on the sidebar. However, for the life of me, I can't figure out how to make it 100% tall! I've tried giving the main content div a height of 100%, the body a height of 100%... everything. It just won't go! What gives? Based on what I read, the parent DIV should be 100% tall, and it should work. I guess not. Any help would be really, really appreciated! Thanks! How do I make a div go to 100% height cross browser? I have a layout like this: ----------HEADER------------- NAVHOLDER | NAV(div inside holder) | NAV(div inside holder) | | | | ----------FOOTER------------- cheers. Hi, I have 3 div boxes in a container, they sit side by side (i.e. 3 in a row) with different amounts of text in each div. The dilemma is that I need all the div's to be the same height as the tallest div. can someone tell me how to do this? thanks Hi all, I am trying to automate everything on my test website and I have one more angle to cover. In effect, I want to adjust the line-height property (which I can do) based on the number of files within a specific folder (PHP and already done). The more files in the folder, the lower the line-height value must be. This is to ensure if I copy additional files into the folder, then the navigation menu (which is PHP reading files in this particular folder) will alter the CSS line-height property accordingly to ensure it can never exceed a certain height. Sounds wierd? go to www.re3.org.uk (next to the RE3 image, I have a list of hyperlinks which are obtained from files within the folder) My problem, when adjusting the CSS property (which is set as cm in *.css file) in javascript, it doesn't correspond correctly, the line-height property in javascript doesn't appear to be work in cm but some other measurement. Does anyone know how to change what unit of measurement Javascript works in? Or does anyone know what unit of measurement javascript uses when adjusting line-height / line-width values? I want to create a mini-algorithm that works out the appropriate line-height based on the image height (got that already) and the number of files in the folder (got that too) so the menu automatically adjusts to fit. Whew! Well I'm running into just a few difficulties trying to enclose a object inside of another container. The problem is that the container does not repeat the background when I lengthen the boxes within it. Can someone with a excellent CSS eye take a look at this and let me know what I'm doing wrong. I've played with overflow:auto; but the problem is that I need to set the width of the container at 990px, and it doesn't seem to work if I statically set the width. http://www.obelix.ca/templates/index.html It seem that everytime I added the image tag, the div'x area get bigger in IE but not in Mozilla/Firefox browser. So, I thought by added the "margin-bottom:-360px;" to the div would fix it but it had an opposite effect. Meaning it worked in IE but Mozilla show a vertical scrollbar. So, does anyone know how can I make the <img> overlap one another without being stacked on one after another in height for IE if I take out the "margin-bottom: -360px;"? Thanks... Code: div.divBox1 { width: 286px; height: 359px; float: left; } div.divClearFloat { clear: both; height: 0px; /* For IE Stupidity (it added some spaces after clearing the float) */ font-size: 1pt; /* For IE Stupidity (minimum height only work with current font-size somewhere) */ } div.divDottedLineAdvertisementSeperator1 { width: 575px; height: 3px; background-color: #ff0000; font-size: 1pt; /* For IE Stupidity (minimum height only work with current font-size somewhere) */ } Code: <div class="divBox1"> <div style="margin-bottom:-360px;"> <img src="images/doctor.jpg" style="position:relative;top:0px;left:0px;z-index:2;"> <img src="images/we_help.jpg" style="position:relative;top:-360px;left:0px;z-index:1;"> </div> </div> <div class="divClearFloat"></div> <div class="divDottedLineAdvertisementSeperator1"></div> <div height = 100% doesn't work inside <table> but if i change height = 900px, it works. anyone know how to fix it? see example code below. thx so much <table border = 1> <tr> <td> mesg </td> </tr> <tr> <td> <div style='HEIGHT:100%; WIDTH:100%; OVERFLOW:auto'> <table border=1 width=100%> <tr><td>stuff</td> <td>more stuff</td></tr> <tr><td>stuff</td> <td>msg </div></td></tr> </table> </div> </td></tr> </table> I tried to use height:auto, and put it into the main container, then I put it in the div that is floated. Nothing works in firefox for me. Ive tried searching on google but I cant find anything that works. Basically, its not just an issue with floats, in general, what is the correct way to set divs, to auto expand to cover what is inside and that works in IE, Firefox and safari, is there a way to ? Thanks in advanced. I'm trying to get a table inside another table which completely fills the parent table, but I cannot get it to work. The simple piece of code illustrates my problem. The red table is inside the blue table but does not cover the entire cell from top to bottom, but only the centre. I want this table to be streched. Obviously height: 100% doesn't work. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> <html> <body> <table> <tbody> <tr> <td> 1<br>2<br>3<br>4<br>5<br> </td> <td style="background: blue;"> <table style="height: 100%; background: red;"> <tbody> <tr> <td style="vertical-align: bottom"> Test </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </body> </html> This is probably a dumb question, but I have a div, with a floated image inside. When the div doesn't have enough text inside to make it taller than the image, the image will stick out the bottom of the div. I've attached a couple of images to show what's happening. I want div to stretch around the image at all times, even if there's only one line of text next to it. Code: <html> <head> <style> body { width: 800px; /* change this value */ margin: 20px auto; } #container { border: 1px solid #f00; padding: 10px; } .floatright { float: right; margin: 10px; background-color: #aaf; } </style> </head> <body> <div id="container"> <h3>some latin text</h3> <p> <img class="floatright" src="some_image.jpg" width="100" height="150" alt="Image" /> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. </p> </div> </body> </html> |