CSS - Percentage Positioning Issues...
Hi,
First off, I've tried a quick search to see if anyone else has posted this problem, but didn't come up with anything. So, if I am repeating, apologies :-) Anyway, I've got a problem that hopefully someone will be able to help me with. It's probably quite simple, but my CSS is a bit hit and miss ;-) Anyway, firstly, here's the CSS: Code: body { margin: 0; padding: 0; background: #FFFFFF url(images/img01.gif) repeat-x; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; color: #8E959B; } #header { width: 100%; height: 225px; margin: auto; padding: 12px 0 0 0; } #logo { float: left; width: 208px; height: 208px; margin: 0px 0 0 14px; padding: 0 15px 0 0; border: 3px solid #EB850C; } #logo h1 { padding: 120px 0 0 0; text-align: center; letter-spacing: -3px; font-size: 2em; font-weight: normal; } #logo h2 { margin-top: -10px; text-align: center; font-size: medium; } #logo a { text-decoration: none; text-transform: lowercase; } #logo a:hover { color: #990000; } #splash { position: absolute; left: 250px; margin-right: 10px; top: 100px; border: 3px solid #EB850C; width: 73%; max-width: 73%; height: 115px; } #menu { float: right; padding: 0 0 0 0; } #menu ul { height: 55px; margin: 0; padding: 41px 0; list-style: none; } #menu li { display: inline; } #menu a { border: 3px solid #EB850C; display: block; float: left; width: 80px; height: 22px; padding-top: 12px; text-align: center; text-decoration: none; text-transform: lowercase; letter-spacing: -1px; font-size: 1em; } #menu a:hover, #menu .active a { color: #FFFFFF; } And the HTML: Code: <body> <div id="header"> <div id="logo"> <h1><a href="#">Company Logo Image</h1> <h2></a></h2> </div> <div id="menu"> <ul> <li ><a href="#">About</a></li> <li><a href="#">News</a></li> <li><a href="#">Careers</a></li> <li><a href="#">Calendar</a></li> <li><a href="#">Contact</a></li> </ul> </div> <div id="splash">This is the page heading montage image</div> </div> </div> </body> The problem is, I need the splash div to resize depending on the width of the screen. The idea being a cheat so depending on different resolutions, the different the size of the div and with a background-image set, the image will appear to expand/contract depending on the width of the screen. It's gonna be a repeating montage image. If the window is over, say, 80% wide, then it works fine. Thing is, if you shrink the width of the window past about 80%, then the div starts to go off the right hand side of the screen... Hopefully I've made myself reasonably clear? Any ideas? Thanks! Similar TutorialsHi all, I have a page that is generated through PERL, but I cannot get the positioning right. There are graphics, 1 - 9 depending on what the user chooses, that I need to display at the top of the page. Below this, I need to place text descriptions of the graphics. However, the text is displaying under the graphics. The code that I am using for the CSS is: Code: .MainWindow{ position: absolute; max-width: 800px; width: expression(document.body.clientWidth > 800? "800px": "100%" ); font-family:Trebuchet MS, Arial, Helvetica, sans-serif; font-size:Medium; color:#AF31F4; background-color:white; Height: auto; margin: 0 auto ; } .ShowCards { position: absolute; vertical-align: top; margin: 0 auto; top: 2px; width: 640px; height: auto; Left: 200px; COLOR: #AF31F4; FONT-FAMILY: Verdana, Helvetica, sans-serif; FONT-SIZE: 11pt; FONT-WEIGHT: bold; border-color:Red; border-style:solid; } .Location2_3 { position: absolute; top: 110px; left: 160px; width: 85px; height: 110px; text-align: center; } .Location2_5 { position: absolute; top: 110px; left: 310px; width: 85px; height: 110px; text-align: center; } .Location3_4 { position: absolute; top: 220px; left: 235px; width: 85px; height: 110px; text-align: center; } .Text1 { position: absolute; top: 100px; top-margin: 20px; left: 10px; width: 500px; } This of course is not the complete CSS file, it is only representative. If you need/want to see the complete file, you can go here And the HTML that gets generated is: Code: <Body> <DIV CLASS="MainWindow"> <div id="printReady"> <DIV CLASS="ShowCards"> <DIV CLASS="Location1_4"> 1<BR> <img src="../tiles/thumbs/ansuz.jpg"> </DIV> <DIV CLASS="Location2_5"> 2<BR> <img src="../tiles/thumbs/daeg-r.jpg"> </DIV> <DIV CLASS="Location2_3"> 3<BR> <img src="../tiles/thumbs/fehu.jpg"> </DIV> <DIV CLASS="Location3_4"> 4<BR> <img src="../tiles/thumbs/nauthiz.jpg"> </DIV> </DIV> <DIV CLASS="Text4"> Rune 1<BR> <font color="#0000FF">Name: Ansuz</font><BR> <font color="#0000FF">Position 1</font>: Past feelings and desires<br> <font color="#FF0000">Keywords:</font> ... Text deleted for space ...<BR> <font color="#FF0000">Meaning:</font> ... Text deleted for space ...<P> Rune 2<BR> <font color="#0000FF">Name: Fehu</font><BR> <font color="#0000FF">Position 3</font>: Present feelings and desires<br> <font color="#FF0000">Keywords:</font> ... Text deleted for space ...<BR> <font color="#FF0000">Meaning:</font> ... Text deleted for space ...<P> Rune 3<BR> <font color="#0000FF">Name: Daeg Reversed</font><BR> <font color="#0000FF">Position 2</font>: Feelings and desires of others<br> <font color="#FF0000">Keywords:</font> ... Text deleted for space ...<BR> <font color="#FF0000">Meaning:</font> ... Text deleted for space ...<P> Rune 4<BR> <font color="#0000FF">Name: Nauthiz</font><BR> <font color="#0000FF">Position 4</font>: Your heart's deepest desires. If this rune is positive these desires will come to fruition in the next four months <br> <font color="#FF0000">Keywords:</font> ... Text deleted for space ...<BR> <font color="#FF0000">Meaning:</font> ... Text deleted for space ...<P> </DIV> </DIV> </BODY> If you would like to see an example of this, go here Choose a layout in the drop down on the top left and follow the instructions. Will only take a few seconds, it is not a long process...... Thanks for any help or suggestions. Jim Hello I've been developing a new website for my dad.. Unfortunatly i cant seem to get some of the things to look how i want them. so i was wondering if you could help, as some of you have been a great help to me on previous websites. the pages in question are the following: http://visitours2london.com/v2/ (in internet explorer) the middle conent drops below the sidebars. (in firefox its fine) http://visitours2london.com/v2/tours2.html (both in i.e. and firefox doesnt come out right) i cant get the titles of the dt tags to align to the right hand side.. and in i.e. the back to top text jumps to the far right, overlaying onto side bar two.. All pages are xhtml valid... link to check is on bottom of the page... Ignore everything else on the website, its simply those two pages that im working on.. other aspects of the website will either not load or not work properly as ive not finished them. Using Firefox, the current state of the site I am working looks like I want it to look, yet in IE 6 it does not look correct, surprise. (IE7 looks great). I've tried several things, and I am completely lost as to a solution, I'd love some help, or suggestions, thanks. UTC Site I am recoding the site jthensley dot com (The forum wouldn't let me list the site needing assistance) to HTML 5 and CSS. I've redesigned some features, which are basically already in the new layout, at jthensley dot com / 2012alpha The 2 horizontal neon lines and the vertical line are simply repeated outside of the header by the CSS. However, one problem I have is that the vertical line that is repeating becomes unaligned with the header if the browser window is expanded. Is there anyway to have it as a repeating background, set to begin at a certain pixel position, and move to the right to maintain alignment with the header as the page is expanded? Secondly, at the bottom, you have the copyright line, which I plan to use as a repeating background or image, as well, and my picture to the right, standing on top of the copyright line. Idealy, I would like the picture of myself to be in a certain area, and push down as page contents make the page longer, but maintain it's "link" with the footer. Any suggestions on how to achieve that? Thanks for your help! This is quite a refresher/learning experience for me! The CSS I have already written is below. * { margin: 0 auto; padding: 0; } body { font-size: 62.5%; font-family: Helvetica, sans-serif; color: white; background-color: #000000; background-image: url(images/horzneon.png), url(images/horzneon.png), url(images/verneon.png); background-position: 0px 137px, 0px 172px, 250px 0px; background-repeat: repeat-x, repeat-x, repeat-y; } ul#nav { height: 185px; width: 1024px; margin: 0 auto; background: url(images/header.jpg) no-repeat; } height: 185px; width: 1024 px; I'm having some issues with the positioning of a link in my header. For some reason in IE 7, it does not line up below the search box like it shows in IE 8, Firefox, Chrome and Safari. I cannot figure out for the life of me, what's wrong. http://trinebay.net/cart/ is the site. You can see in the header the advanced search is the link that wont align in IE7 and probably IE6 as well. Thanks for the help guys I am trying to position two buttons on a line. They should each sit in the middle of one half of the line. Here's my code: Code: <html> <head> <style type="text/css"> .clear { /* generic container (i.e. div) for floating buttons */ overflow: hidden; width: 100%; } a.button { background: transparent url('http://www.oscaralexander.com/tutorials/img/bg_button_a.gif') no-repeat scroll top right; color: #33C; display: block; float: left; font: bold 16px arial, sans-serif; height: 24px; margin:0 auto; padding-right: 18px; /* sliding doors padding */ text-decoration: none; } a.button span { background: transparent url('http://www.oscaralexander.com/tutorials/img/bg_button_span.gif') no-repeat; display: block; line-height: 14px; padding: 5px 0 5px 18px; } a.button:active { background-position: bottom right; color: #22B; outline: none; /* hide dotted outline in Firefox */ } a.button:active span { background-position: bottom left; padding: 6px 0 4px 18px; /* push text down 1px */ } </style> </head> <body> <div> <div style="float:left; width:50%; background-color:#EEE"> <a class="button" href="#" onclick="this.blur();"><span>Learn More</span></a> </div> <div style="float:right; width:50%; background-color:#DDD"> <a class="button" href="#" onclick="this.blur();"><span>Buy Now!</span></a> </div> </div> </body> </html> And here's a link to the test page: http://rentalocal.thad.com/test Does anyone know what I've done wrong? Thanks, Thad For a search tool, I have a "results toolbar", horizontally across the top of the results page. Within this toolbar (position: relative) I have a span containing the current page, absolutely positioned at top: 8px; left: 5px; What I get when rendering however, is the following: Right: http://tim.komta.com/images/css/Firefox.gif Wrong: http://tim.komta.com/images/css/IE.gif More accurately, I should say that I get what I expect in Firefox, and not what I expect in IE, which is not overly surprising. Anyway, what am I doing wrong? If I change the text-align of the box from right (current) back to left, it's still overlaid on top of the images, but on the left, like it's supposed to be. It kinda seems like IE is making the images the bounding box for absolute positioning. Any thoughts? MPEDrummer Hi, Just wondering it anyone can help... I am trying to get my left hand navigation to sit at the top of the cell and no matter what I change it won't budge! You can see what I am working on at www. freedomwhalewatch .com.au /Stirling /index.html as you can see the left hand navigation is sitting towards the bottom... anyone have any suggestions as to how I would move it up to be directly underneath the logo? To see my working files just use the right click and view page source. Any help or suggestions would be much appreciated. I am a newbie to css! Cheers, Jen ** UPDATE - sorry guys i spelt the url incorrectly! http://www. freedomwhalewatch .com.au/Stirling /index.html EDIT: OK, I've worked out all of the issues except the fourth one, which doesn't really have to do with CSS specifically. Why do line breaks insert gaps? The problem is especially prevalent in IE. First issue: I'm trying to position one image over another image and its inserting this big gap! As seen on http://www.zacwittedesign.com/olive/pool.html we have the "about the pool" image position on top of the big image to the left side, but you can see there is a big gap above the big image. If I simply comment out the 'about the pool' image, the gap goes away and all is fine. I thought relatively placed elements were not supposed to affect the flow of elements beneath them? Can you see anything wrong in my code? Second Issue: There are two issues with the layer on the top of the page where the dots should be coming out of 'new projects' (id=projects_layer). It should be positioned over top.jpg as seen in hotstuff.html. In that page I manually moved it down by adding an additional 60px to the relative offset, but the space where it would have occupied remains and pushes the whole page down. Everything should look like it does in portfolio.html which doesn't currently use layers. You can see a version without my manually shifting it down and demonstrating the third issue at pool-valign.html. Third Issue: The vertical-align of all the images inside the projects layer. For the layout to be correct, the images need to be top-aligned or they won't line up with the dots and they'll slightly cover the button images beneath them. I have a style property set vertical-align:top; but it doesn't seem to do anything. Do I misunderstand the vertical-align property? There's also a small gap beneath the images when viewed with IE. I've changed the background color of the layer so you can more easily see the problem. Fourth issue: You've probably noticed in my code that I insert and HTML comment for every line break. That is because if I don't, IE reads the line beaks as non-whitespace and inserts both vertical or horizontal gaps between the images. Whats the deal there? Fifth Issue: In IE there is a one or two pixel gap above right.jpg where the tim olive logo is. This doesn't happen on firefox and it doesn't happen on pages that don't use layers like portfolio.html. ...And I haven't even tried it on a mac browser yet... Hello, I'm relatively new to using CSS as the foundation of a site, as i've only ever built sites for family/work etc using tables. I have used it previously for styling and so on, but not as intensively as i now am. It's great, but a couple of issues are giving me a headache - the fun of web design, hey?... I'm experiencing two problems, and have spent a lot of time describing them (with examples and images) on the following page - fnb4wd.com.au/4x4wh/help/help.htm - not wanting to clutter up the forum with my explanations and too many images. The first is to do with the 100% height trick - my "wrapper" div is not expanding with my "content" div - but i do not believe faux columns are possible for my design (if someone proves me wrong, great!) as i don't have two full height columns, but one content column and a vertical menu div... The second issues is with a Horizontal menu i am using as main navigation. In both FireFox & Chrome, the menu shifts down so the text links are unreadable unless hovered over. In IE, it's positioned as i want (with Comp View Settings turned on for IE8). So, if anyone could shed come light on my problems, i'd love to hear some ideas. The full explanation, complete with working examples and images (as well as my code) can be seen at fnb4wd.com.au/4x4wh/help/help.htm. Thanks in advance, Azerus85 If I make a wrap, and put other elements in the wrap, and say I want those elements to be x% wide, am I saying x% wide of the window or the wrap? So I have read a bunch of different results from my google searches and none seem to do what I would like. I'm beginning to think that there isn't really a solution at this point in time. Here is my setup: Code: <div id='container'> <div id='header'></div> <div id='menuBar'></div> <div id='main'> <div id='content'></div> </div> <div id='footer'></div> </div> 'header', 'menuBar', and 'footer' are all fixed height. 'main' MAY have a sub-menu div. When it does have this sub-menu, I would like for that sub-menu to be full height and 20% wide. Otherwise, I would like for 'content' to be as wide as possible. Currently I'm floating the sub-menu left and as a result the text in 'content' wraps around it after the bottom. In case my description makes no sense... Default Behavior: Current Behavior: Desired Behavior: It's so pretty and colorful I *could* create a second template for pages with a sub-menu, but I would prefer not to have to resort to that. Hi i've got a question... i have a text area block. When i assign a height of 200% to the block it doesnt seem to do anything, but when i assign a height in pixel eg 200px, it works? Hi, I'm trying to do a two column layout which spans across the whole screen. This would be easy if I was just using percentages because I could just go: Left: width:20%; Right: width:80%; But I need the left bar to be a fixed width and the right bar to span the rest of the screen. There might be something really simple here that I'm overlooking but at the minute I can't think of how I would do it... Joe I hope I can explain this in a way that makes sense. I have a table layout where the number of columns is variable (sometimes it can have 1 column, sometimes it can have up to 9 columns), depending on what data is filled out on a previous form. The code in question: Code: <tr> <td> <div style="float: left; width: 13px"><img src="arrow.gif"></div> <div style="float: left; width: 93%;">My explanatory text goes here!</div> </td> <td> Column 2 Text </td> <td> Column 3 Text (and so on) </td> </tr> The two divs there need to float next to each other -- the first div is a little 13x13 arrow, the second div is some explanatory text. I can not just float the image left (and not put the text in a div), because the client wants the text to be left aligned in the div, not wrapping around the image. The issue: If there are less than 5 or 6 columns, it works beautifully. If you put more columns in there, then the second div appears below the first div. I've been fiddling with the widths on the second div, but it has to be a percentage (not a set number of pixels), because the number of columns is variable (as is the width of those columns). How can I make the columns float next to each other regardless of the width of the table cell that they are within? Any help is appreciated. I have a left div which is fixed let is say 400px and the right div should extend to the edge of the screen. How can i get it to extend. If i don't give any width to the right div: The right div has other dives which has got dotted bottom border, these dotted border will not extend to the end any ideas? cheers Hi all!! I've just finished this website relifeservizi.com but I have experienced some problems with browsers compatibility. .Links. In the index page relifeservizi.com links are buttons (images) you can click and they should have a complete border but it does work only for textual links, for the images I have only the bottom border. But I don't mind because I like it this way. The problem is that Firefox displays always the border at the bottom of each image, white Chrome and Safari don't. The only link without border is the first one, that is the company's logo and I really can't understand why!!! .Googlemaps. I embedded a googlemap here relifeservizi.com/contatti.htm with percentage sizes, width e height in %. It does work both with Chrome and Safari but not with Firefox, displaying it small. .Vimeo. Same problem for a video I embedded from vimeo. relifeservizi.com/relife.htm I used percentages in size and it displays correctly with Safari and Chrome but again not with Firefox. This is pretty much irritating, because I'm really not able to understand what is the problem and I do need that link underline on hover... And it's much more irritating because I'm a Firefox user anyway u___u I think this is more of a css problem than php thats why its here I can get percentage bars to work without text on them, but not with text, the bar is either pushed below the text, or the text is pushed onto 3-4 lines, depending on how wide the bar is So far i have: The php PHP Code: $poke[] = '<div class="percentage"> <span style="position:relative;">'.$text.' ('.round($per, 2).'%)</span> <div class="perc" style="width:'.$per.'%;"></div> </div>'."\n"; the css Code: .percentage { background-color:#800000; -moz-border-radius: 5px; -webkit-border-radius: 5px; border: 1px solid #000; height:15px; font-size:10px; z-index:2; } .perc { visibility:visible; height:15px; z-index:3; background-color:#000; -moz-border-radius: 5px; -webkit-border-radius: 5px; } This is how it looks with that code Sorry if this is a common problem. I tried a search but didn't find anything that seemed helpful. I've got "frame" (not a <frame>) around the content of my site and I need this frame to expand vertically if necessary, according to the content. I've done this by having a 1px high image, set to 100% height and an exact pixel width. The frame is a table, three cells wide, with the side images in the two outermost cells and the content in the central cell. It's the side images that cause a problem. What I've got works fine in Firefox but in IE6, the sides of the frame don't display, or the image displays but doesn't stretch (I can't tell 'cos the images are only 1px high). Here's the basic table layout: Code: <table id="frameTable" border="0"> <tr> <td> <img id="FrameLeftImg" src="resource/frameleft.png" /> </td> <td> <?php /*Add constructed page data*/ ?></td> <td> <img id="FrameRightImg" src="resource/frameright.png"/> </td> </tr> </table> And here's the CSS for the side images: Code: #FrameLeftImg { position: relative; width: 26px; height:100%; } #FrameRightImg { position: relative; width: 28px; height:100%; } The table is contained in a div that is absolutely positioned by pixels but has no value specified for width and height. Anyone know what I'm doing wrong? |