CSS - Help With Divs And Floating Elements
Hello all, sorry if this is a "newb" question, but I am having trouble with the code on my site. The element "#arrival" is not displaying the proper height unless I literally type code in to fill it up the full 400px. I haven't implemented any paragraph styles, I just want to get the basic elements done for this landing page.
How would I go about fixing this? Also, do I have to "float" the "#arrival" element? I would like to have the dog house overlap the first div element of the dog jumping (#dog) like in the jpg. Any help would be greatly appreciated. Here is what it should like: http://i33.tinypic.com/2uh7evm.jpg But this is actually what is happening: http://www.amandambruce.com/DROH/index.html Thanks in advance, Amanda p.s. here is the code directly from the source: Code: <!DOCTYPE html PUBLIC "-//w3c//DTD XHTML 1.0 Transitional//EN" "(URL address blocked: See forum rules)"> <html xmlns="html://(URL address blocked: See forum rules)/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>The Dachsund Rescue of Houston</title> <style type="text/css"> body{ background: url(images/background.jpg) no-repeat top center;} #contain{ width: 800px; height: auto; margin-left: auto; margin-right: auto; } #menu{ width: 466px; height: 98px; float: right; margin-top: 15px; } #dog{ width: 491px; heigth: 257px; margin-top: 19px; margin-left: 22px; float: left; } /* margin-top is the menu plus the remaining pixels (19) so, from the very TOP of the page. I guess you keep "adding" */ #community{ float: right; background: url(images/community_spot.jpg) no- repeat; width: 231px; height: 259px; margin-top: 19px; margin-right: 22px; } #arrival{ clear: right; background: url(images/arrivals.png) no-repeat; width: 800 px; height: 400 px; } p{ font-family: helvetica; font-size: 12pt; color: #000000; padding-left: 10px; margin-right: 10px; } </style> </head> <body> <div id="contain"> <div id="menu"> <a href="about.html"><img src="images/about_btn.png" alt="About button" title="About" border="0"/></a> <a href="adopt.html"><img src="images/adopt_btn.png" alt="Adopt button" title="Adopt" border="0"/></a> <a href="help.html"><img src="images/help_btn.png" alt="Help button" title="Help DROH" border="0"/></a> <a href="resources.html"><img src="images/resources_btn.png" alt="Resources button" title="Resources" border="0"/></a> <a href="contact.html"><img src="images/contact_btn.png" alt="Contact button" title="Contact" border="0"/></a> </div> <div id="dog"> <img src="images/jumping.jpg" border="0"/> </div> <div id="community"> </div> <div id="arrival"> lll </div></div> </body> </html> Reply With Quote Similar TutorialsI have a floating div with a solid background and a z-index set to 20. I have a form "behind" the div. For some weird reason, the drop down elements on the form "bleed through" the div. Is there any way to fix this? Hi! Does floating an inline element automatically converts it to a block-level element? If yes, what does this give for an inline element: float: left; display: inline; ? Is it bad practice to float inline elements directly? (img, span, input, and so on). Thanks I am using a <dl> list to render dates and titles for a press release page. I want to display the date first and then display the title on the same line next to the date. If the title needs to wrap to more than 1 line, it should not wrap below the date - its left margin should be consistent. Simple example: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> dl { width: 100%; } dt, dd { float: left; margin: 5px; } </style> </head> <dl> <dt>12.24.2006</dt> <dd>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi consectetuer cursus lacus. Nullam imperdiet diam sit amet dui. Suspendisse nonummy, ante ut pharetra vehicula, augue neque porta arcu, vel adipiscing lorem augue eu purus. Aenean vulputate pellentesque arcu.</dd> </dl> <body> </body> </html> My problem is that with a long title that wraps to more than 1 line, Firefox is putting the <dd> on its own line - it will not float it next to the <dt> as it should. If you change the title to something shoter like Code: <dd>A ShortTitle</dd> It displays as it should. Any ideas why this is happening? Hi everybody I'm having a problem (only in IE) with the following layout http://www.ruthwhiteyoga.com/shop/test2/list.htm The left fixed width column, right fixed width column and centre stretchy column all sit inside a holding div (100% wide) The left column is floated left, the right column is floated right and the centre column has margin left and margin right values that clear the two floated columns The problem is that in IE the floated product divs (in the centre column) ignore the margin-right. As soon as the content ends in the right column the product divs spill into the area that the margin should be keeping them out of (you might need to alter the width of your window to see this happening) I think the problem is that I can't give the centre column a width (100%) because it also needs a margin to force the content in - 100% plus 230px for the left column plus 230px for the right column will totally screw up the page Beyond sticking these three columns into a table (something I really really don't want to do) or using percentage for all three columns (so I can give the centre column a width value) is there anything I can do about this. Really appreciate any help Hello, can anyone help me with this? I'm having trouble floating some divs and I can't find the problem. 1. navigation should be aligned with the bottom of the h1 logo 2. the content div should come next to the list of brands. The content div should overlap the black bg at the top. www. claeysconsult . be / misskado / index2.html Thanks in advance... Hi im experiencing big problems with creating this layout. I spent whole day with positiooning this divs but i cant do this final layout. Everytime i want to float divs to left DIV 1 and DIV 2 are ok but DIV 3 jump to new line under DIV 2 and dont fit the gap between DIV 3 and div 1 . Can someone please help me ? Thanks ... link to image : xipic.eu/ufiles/njf25uy8_divs.png Hello all. I've got a layout with three columns. The first column contains the navigation and the second two are variable content. All the columns can be any length, and consist of any number of divs; each div is a bordered block of variable-sized content. The problem is if I want to float an image around some text in the second or third column. Since the image is floating, its container doesn't extend fully, and the image overlaps the border and the block below it. However, if I put a "clear: both" spacer within the block, then the container clears elements in the left or right columns, and extends way too far down! What I really need is a way to just clear a single level of nesting, but "clear" seems to be pretty much all or nothing. I've also tried the pseudoclass :after trick to extend the box, but that didn't appear to do any good. It just added the content inside the border of each block, but doesn't enclose the image at all. I hope somebody has suggestions - I actually haven't found anything about this problem, but perhaps I'm just looking for the wrong terms. It seems like a fairly fundamental thing to do... Thanks! [code] <div id="wrapper" style="background-color:black;padding:2px;overflow:visible;"> <div id="left-floating-box" style="background-color:red;float:left;">asdfsadf</div> <div id="right-floating-box" style="background-color:blue;float:right;">asdfsadf</div> </div> [code] here is a problem, warpper div doesnt strech to the height of the floating divs, ofcourse when you get rid of floating then everything work but i need this to work as it intended and that is two floating boxes with in one div and this div would wrap around two floating boxes and that way background would stretch as well. I rember solving this problem. Long time ago, but for some reason i am stock right now with this problem. Any one can refresh or sugest anything. Thank you. I've used divs before and got them to work just fine. I've read previous posts and can't find the answer I'm looking for because it seems so basic. But here is my problem. I simply can't get the divisions to float left or right. They just sit on top of one another. Here is my style sheet code: Code: #container { margin: 0px; padding: 0px; width: 800px; } #header { margin: 0px; padding: 0px; background-color: Blue; } #menu { background-color: Gray; float: left; margin: 0px; padding: 0px; width: 140px; } #content { float: right; margin: 0px; padding: 0px; width: 650px; } #footer { margin: 0px; padding: 0px; width: 800px; } and my HTML: Code: <div id="container"> <div id="header" align="center"> <!-- #INCLUDE VIRTUAL="includes/example_header.aspx" --> </div> <div id="midsection" align="center"> <div id="menu"> <!-- #INCLUDE VIRTUAL="includes/example_menu.aspx" --> </div> <div id="content"> <!-- #INCLUDE VIRTUAL="includes/example_common_content.aspx" --> <p> Garbage. </p> </div> </div> <div id="footer" align="center"> <!-- #INCLUDE VIRTUAL="includes/example_footer.aspx" --> </div> </div> Thanks in advance for your help. Hi there! I'm using this code: CSS: Code: #content { margin-top: 75px; width: 597px; height: auto; } #left { width: 110px; height: 497px; margin: 0px; padding: 0px; float: left; } #right { width: 485px; height: 100px; } HTML: Code: <div id="content"> <div id="left"> </div> <div id="right"> </div> </div> --------- But the right-div goes under or over the left-div. I've tried clear:both; between the div's, but it didn't help. URL Hi, If I have Code: #parent { background-color: red; padding: 2px; margin: 2px; } #child1 { float: left; } #child2 { float: left; } </style> <div id="parent"> <div id="child1"> Some text </div> <div id="child2"> Some text 2 </div> </div> Then the two child divs will appear underneath the parent one, whereas I want the background from the parent one to be the backdrop for the two child divs. if I remove float: left then they appear in it, but underneath each other. I want them side by side. Is this possible with css? I have a container div that contains multiple divs floating left within it. The container css is Code: div.divContainer{ width:100%; } The child divs css is: Code: div.div1{ float: left; width:50%; } When the contents of the left div gets too large (and the browser window too small) the end divs wrap. I have researched this quite a bit and it seems like a solution is to give the container a fixed pixel width. I would like to keep it a relative width. Any ideas? I would even consider placing a horizontal scrollbar on the container rather than having it wrap Thanks I am working on this site for a client and I can't figure out what the hell I'm doing wrong. It doesn't "work" in FireFox, which of course (I assume) means that IE is simply forgiving my errors, but let's not have a religious debate, let's solve problems. http://www.nolower.com/example.php http://www.nolower.com/css/public.css I am curious about two things: 1) Why is my white background (the main div) not showing up on this page? I thought I had cleared every float, yet, still, there it isn't! 2) Why does the background shadow (the main div), a background image that extends into the padding in IE as you'll see, not show up on FireFox? If anyone can help identify what I've done wrong and explain to me what made it break in CSS, I'd be very grateful. I've been trying to figure out the peculiarities of CSS and its very poor cross-implementation (not that tables were ever cross-implemented well either, oi) for about a year now and I always either make a new mistake or find something I haven't figured out yet. Thanks! I'm redoing the layout of my site (www.brohawk.com) using floating divs with negative margins to produce a fluid left column and a fixed right column. I followed an article on A List Apart for the basics and got it working fairly nicely. As a matter of fact, the site works beautifull in Mozilla/Firefox and with minmal errors in NS7. I've even got all but the forums working in Opera. I haven't even begun to work on making it IE compliant. Saving the worst for last. Anyhow, on all the pages except the forums, the divs line up perfectly. However, on the forums page, the right div doesn't stay up top, instead it wraps around under the left div. However, I still get all the space to the right of the left div where the right one should go. Anybody with Opera should be able to check it out and see what I mean. Anyhow, can anybody tell me why it won't float properly on that one page, but it works on all the others? Basically, #bodycont has a background. When I type text into this div, it expands and the background is show. However when I put the divs menu and news into it the background doesn't show. I've had this problem before but I can't remember how to fix it html4strict Code: Original - html4strict Code <div id="bodycont"> <div id="menu"> <img src="imgs/menutop.png" /> </div> <div id="news"> wefwef </div> </div>
css Code: Original - css Code #bodycont { background-image:url(../imgs/background.jpg); width:100%; height:auto; } #menu { width:245px; float:left; } #news{ width:545px; height:auto; float:right; }
I have two div tags that I want to float next to each other. The page looks like this <table>These Tables stretch 100% of the width</table> <table>''</table> <div class="ParentDiv"> <div class="menuholder"></div> <div class="ChildDiv"></div></div> in FF everything works the way I want to. In IE if I shrink down the browser then the second div tag drops below the first. I want to change this so that it does not drop below but remains in the same place. Is there anything I can set to do that? If I remove the float and change the position on the menuholder the childdiv tag does not drop but the menuHolder content does not stretch the size of the parentDiv and gets chopped off at the height of the childDiv Code: .ParentDiv { position: relative; width: 100%; width:expression(document.body.clientWidth < 997 ? '997px' : '100%'); min-width:997px; max-width:100%; overflow:hidden; min-height: 400px; } .ChildDiv { position: relative; width: 100%; min-height: 400px; } .menuholder { background-color: #EFF3F5; color: #eef; position: relative; float: left; left: 0px; top: 0px; overflow: hidden; width: 160px; z-index: 100; } What I have: I have a <div id="content"> that contains the main content of the site. In this <div> I have two other <div>s that are arranged in columns, using float. The left column forms the Navigation for the site and is surrounded by a black border. Here is the problem: If the content on the right is small, the border on the left stretches from top to bottom (since the left div controls the height). However, when there is a lot of content on the right, the border on the left only surrounds the content of the left div and leaves space underneath the bottom border-line. My question: Is there a way to "stretch" the left div so the border touches the top of its parent div on top and the bottom of its parent div on the bottom? Or in other words: Can I force the left div to have the same height as the right div? Here is an example of what I have right now (before tackling the problem): CSS: Code: #content { width: 800px; margin: 0; padding: 0; } #contentNav { width: 140px; float: left; border: thin solid black; margin: 0; padding: 0; } #contentMain { width: 600px; float: right; margin: 0; padding: 0; } HTML: Code: <div id="content"> <div id="contentNav"> <a href="">Link1</a><br /> <a href="">Link2</a><br /> <a href="">Link3</a><br /> </div> <div id="contentMain"> <p>Here comes a lot of text that spans over many lines. </div> </div> I've been beating my head against the wall over this problem for two nights now. I'm working on our new site and everything is formatting well across all major browsers. But when I go to print the page, the results are less than desirable, except for Opera on my Mac. For some reason that browser handles floating divs great. But Safari, Firefox 3 and IE 7 all barf on the divs. Particularly, if the text in my main content area exceeds a page length, the remaining text displayed on subsequent pages is displayed down the page and not at the top like one would expect. Another problem is that sometimes the first page will just show me the header and menu of my content and will begin displaying the main content on the second page. I've played around with clearing floats when printing but this just re-arranges the divs and of course overlaps with other floats. Could one of you experts please take a look at this page in particular and the accompanying main.css file and tell me a quick way to prevent this with using just css attributes. An example page is he www proterraonline com / dev / team.asp While I have a print css linked in the source of the html, the code is the same as in the main.css at the moment. Here's a link to the css file to make life a little easier. www proterraonline com / dev / css / main.css Thanks. |