CSS - Keeping Layer On Same Height
I am working on aligning a pricelist with product and price.
The procuct is on the left, and the price should align to the right on the same line. When I try to use float: right in the div for the price it jumps down a line, if I use text-align right in a relative devision it also jumps doen a line. I also tried adding align:right to the b tag. Any ideas how to get this done? I am trying to avoid tables. Thanks Similar TutorialsI'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> I'm quite fluent in xhtml, css, and other crap...but I'm not sure why this doesn't work -> the height attribute is set to a percentage, yet it doesn't work...I know its acceptable i checked the css reference. view source on this Validated xhtml strict 1.01 EDIT: I FIGURED IT OUT... I NEEDED TO PUT THIS html, body { height:100% ; width:100% } Hello I thought I could make it, but what I got so far is jumping over the screen, so please a need some help. I got a image with two transparant shapes. Behind those shapes I would like to show 2 other images. |-------1-------| | |-----| |----| | | |...2..| |..3..| | | |____| |____| | |_____________| Image 1 should be on top z-Index Image 2 should under image 1, a part of the image should be visible. Image 3 should under image 1, a part of the image should be visible. Now the issue, image 2 and 3 should be dynamically replaceable. Please help 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! I have a set of background images that work well in giving the impression that there is a solid page on screen. However, as you can see here , once I start introducing structure it falls apart and I'd really () like to know why. (The CSS validates OK and I've given temporary borders to the divs to help show where on the screen they should appear). 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> I've never done much CSS work, but I know this has to be an easy fix. Each DIV appears to be 10px higher when viewed in IE. I want them to be 8px high and they end up being 18px high. In Firefox, Netscape, and Opera it works fine. Anyone mind correcting this imbarrassing little problem? Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" > <head> <title>IE 10px Padding Problem</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> body { margin:0px; } #container { position:relative; margin:auto; width:730px; } #header { height:110px; } .textualtop { border:1px solid #000000; height:8px; } .textualbottom { border:1px solid #000000; height:8px; } </style> </head> <body> <div id="container"> <div id="header"></div> <div class="textualtop"></div> <div class="textualbottom"></div> <div class="textualtop"></div> <div class="textualbottom"></div> <p>Notice how in IE6 each DIV is 10px higher then in FF. Why is it doing this?</p> </div> </body> </html> Hello everybody! I have been having a big problem with my webpage for a long time now and hope I can find an answer to my problem with your help. I want a div that contains the content of my pages (which varies in length depending on the individual page) to stretch the length of my page, but it only stretches the length of the window. Here's the HTML and CSS: HTML (I only included the very basic structure): <html> <body> <div class="container"> <div id="content"> <div id="..."></div> <div id="..."></div> <div id="..."></div> <div id="..."></div> </div> </div> </body> </html>` CSS: html, body { height: 100%; font-family: Arial; font-size: 10px; color: #000000; background: #FFF url(../../images/body.png) no-repeat center 40px; margin: 0; position: relative;} .container { height: 100%; width: 960px; margin-right: auto; margin-left: auto; position: relative;} #content { width: 939px; min-height: 100%; position: relative; top: 210px; left: 6px; box-shadow: 0px 0px 8px #666; -moz-box-shadow: 0px 0px 8px #666; -webkit-box-shadow: 0px 0px 8px #666; background-color: #FFF;} I tried to set the content div to overflow: auto, but that includes a scroll bar for the content div that I do not want. It does, however, create the desired effect of the shadow and background of the #content div all the way to the end of the page. Am I missing anything? I thought min-height would work, but it doesn't! It only stretches the content div to page height and everything else is overflow, but without the content div's background color and shadow. Does anybody maybe see where the problem lies? Thank you so much in advance for your help. Hello Just recently I had an idea for a page I wanted to make, the design is basically a 3-column layout with no traditional header or footer, the height of all three columns should run the length of the window/page height the left and rightmost column would have a fixed width or a width in em, the center column width should fill the space in between. If the content is short all columns should extend to the height of the page window, but if the content in any of the columns is longer than the window height they should all extend to reach the bottom of the page and accommodate the content length In my first attempt things didn't go so well, results varied wildly across browsers so I decided to start from scratch bit by bit Bellow is the point at which I reach consistent but undesired behaviour, I have validated and tested the code in Firefox 3/Pale Moon, Internet Explorer 8, Chromium 9, and Opera 11 I would like the end result to work in the above browsers as well as IE7 if possible I should point out now that im not interested in using faux-columns, the layout should not require images, I also wish to have absolute-positioned elements in the columns some time later Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Three Columns</title> <style type="text/css"> *, html, body { margin: 0; padding: 0; font-size: 100%; } html, body { width: 100%; height: 100%; } #maincontainer { position: relative; height: 100%; background: #eee; } #left { position: absolute; top: 0px; left: 0px; width: 200px; background: #fbb; height: 100%; } #mid { position: relative; margin: 0 200px 0 200px; background: #efe; height: 100%; } #right { position: absolute; top: 0px; right: 0px; width: 200px; background: #bbf; height: 100%; } </style> </head> <body> <div id="maincontainer"> <div id="left"> left start<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left<br /> left end<br /> </div> <div id="mid"> mid start<br /> mid<br /> mid<br /> mid<br /> mid<br /> mid<br /> mid end<br /> </div> <div id="right"> right start<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right<br /> right end<br /> </div> </div> </body> </html> In the above example it works as long as the content within the columns is shorter than the window height, but if you re-size the window so that the text in the right or left column goes beyond the page, and then scroll to the bottom, the columns do not extend to the bottom of the page so there is a large gap where the content overflows beyond the column What I would like to do from this point is make the columns extend to the bottom of the page when this happens, but I'm not sure how best to proceed I also have a version of the above code which uses floated left and right columns instead of absolute positioned ones, would it be better to work from that? or does it not really matter Thanks in advance Hi How do I get a <div> to stay at the bottom, constantly, even if a layer above it gets resized so that its longer than the page in the browser. I have one <div> and then the footer <div> but the upper <div> gets resized to about 1000px and over laps the footer <div>, how do I get the footer <div> to keep at the bottom ? Hi, I have started to get to grips with CSS but I am currently just playing - I have not designed any serious pages but am about to. I wondered if it is possible (I am sure it is but I cannot work out how) to use a h1 tag in the middle of a paragraph <p> without making it start a new line. Does anyone know of a method to force the text within the h1 tag to just flow within the sentance? For example if the above block was a paragraph the word CSS on the first line could be included within a h1 tag but it would remain on the line as it currently is (however in this case it would be forced to appear as capital letters, but I can take care of that part myself). Thanks for your time Hi the I wonder if there is a way to keep spiders away from certain sections of my web pages? For example, keep them away from the nav_bar, but index the rest of the html page? Someone told me it could be done by CSS but I've tried to search for it without any luck. Any suggestions would be greatly appreciated. Sincerely, Ponch I'm having problems with keeping the border of an div tight in against the div's content. At the following URL http://alphaworks.co.uk/problems/box/ I want the next and prev divs to be a little larger than the text inside them and then the outer prev_next div should be a little bigger than the two divs inside it but not stretching to the width of the page as it does now. Can someone show me the error of my ways? Thanks, Geoff Hello, I'm stumped on how to float an image to the left, and still keep it in the flow of the document. Here is an example off my head. Code: #container { border: 1px solid #000; } img.floatleft { float:left; } div { display: inline; } <div id='container'> <img src='myimage.jpg' class='floatleft'> <div>text</div><br> <div>text</div><br> <div> <div id='container'> <img src='myimage.jpg' class='floatleft'> <div>text</div><br> <div>text</div><br> <div> The image will exceed the bounds of 'container' if the image is larger than the text is tall. How can I get around this? Thanks again for the help. webg <div>text</div> Hi, I have a container with a border that works fine , but when I float 4 elements that are in a row, the container shrinks, and they are outside the container. How can I align four boxes, and keep them in the container? here's the example: http://www.caillouette.com/alpha-dream/ thanks I believe this has been asked before, but I'm unsure what search terms to use... Basic one column CSS layout. How to keep the footer at the bottom of the window even when content doesn't reach that far? I am trying to have an element that will float above the others on the page and also be centered. When I make the position absolute, it will float above the others, but won't center (dynamically with window resize) and if I make the position auto, it will center but not float above the others. Here is the style: Code: .main { position:auto; margin: 0px auto; text-align: center; width: 800px; background-color:red; z-index:1; } Thank you If you look at the bottom of the page at www.res-technologies_DOT_com/index.php?jos_change_template=restech2 in both IE and FF, you will see that it looks fine in IE, but in FF the page length is extended by exactly the height of the header image at the top of the page. Trying to figure out what's causing this is driving me nuts! Can anyone help? thx dh Hi all, I have a 2-column layout for my web pages plus a header and footer section. The left column contains a navigation menu (which grows and shrinks depending on the current menu selection), and the right column contains the main text and other information. I float the nav menu left. No problem. But when the footer is displayed (and I have set "clear: both" on the footer element to try and keep it at the bottom), it will appear somewhere in the middle of the menu in cases where the menu is long (vertically) and the main content area contains only a few lines of text. My current method to drop the footer below the menu is very klunky, and probably what most people do (unless they know of a better way). Yes, the series of <br /> tags before printing the footer. Is there a better way of ensuring that the footer is placed where it should (below all other content) so I don't have to insert all those <br /> tags? My CSS for the page layout is: Code: #doc { /* Main document area */ margin-left: 5%; margin-right: 5%; margin-top: 5px; border: solid 1px #900; } #logo { text-align: center; background: #c30000; } #main { margin-left: 150px; margin-right: 0%; padding: 10px; border-left: solid 1px #c00; background: #fff; color: #000; } #nav { position: absolute; margin-left: 0%; float: left; padding: 0px; border: 0px; top: 110px; width: 150px; /* Same as margin-left setting in #main */ color: #000; } #footer { clear: both; margin-left: 0%; margin-right: 0%; border-bottom: 2px solid #906; background-color: #c00; color: #ddd; font-weight: bold; text-align: center; line-height: 1.5; } And a typical html page would be structured thusly: Code: <!-- USUAL HTML BEGINNING STUFF HERE --> <body> <div id="doc"> <!-- Logo image --> <div id="logo"> <!-- LOGO GOES HERE --> </div> <!-- Main content window --> <div id="main"> <!-- MAIN CONTENT GOES HERE --> </div> <!-- Navigation menu --> <div id="nav"> <!-- NAV MENU CODE HERE --> </div> <!-- footer --> <div id="footer"> <!-- FOOTER CODE HERE --> </div> </div> </body></html> Is my CSS coding incorrect, or is this a universal problem? Any help/suggestions will be much appreciated. I am not an expert on developing websites, but I've been able to get our site up and running without much challenge. I used a menu I found on www.dynamicdrive.com that allowed you to have our menu in a horizontal or verticle layout. We don't use frames in our site but we wanted a frames-type look. So we use the menu in the vertical layout. What I'd like to do is find a way to keep the menu on the screen as people scroll down. I've seen other websites do this and have looked at a couple that were recommended from a previous post, but I can't figure out how to make it work propertly. Our website is www.indyartistgroup.com. If someone could take a look at the site and suggest some ideas on how to make the menu on the left hand side stay on screen no matter how low you scroll I would appreciate it. I'm out of options at this point. Thanks for the help. John |