CSS - Aligning A Div At The Bottom Vertically
So I'm still on my quest to be able to create my 1st entirely CSS site, and need some help as I'm not sure how to do this. I want to be able to align a navigation list at the bottom right of the content area. Also while I'm at it, I want the site to be at a minimum 462px (just an example), but would like for it to increase in height if the content itself expands beyond the 462. And the navigation menu, I'd like to somehow keep at the bottom right of the viewable area.
Thanks... here's the code... HTML Code: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <link rel="stylesheet" href="style.css" type="text/css" charset="utf-8" /> </head> <body> <div class="outer"> <div class="logo"> <img src="images/logo.gif" /> </div> <div class="spacer"> </div> <div class="nav"> <a href="#">Link 1</a><br /> <a href="#">Link 2</a><br /> <a href="#">Link 3</a><br /> <a href="#">Link 4</a><br /> <a href="#">Link 5</a><br /> <a href="#">Link 6</a> </div> <div class="content"> <p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." </p> </div> </div> </body> </html> CSS Code: Code: body {padding:0px; margin:0px; } div.outer {background-image:url('images/bg2.jpg'); background-repeat:no-repeat; width:770px; height:462px; } div.logo {text-align:right; padding:10px; height:75px; } div.spacer {float:left; width:200px;} div.nav {float:right; text-align:right; padding:20px; } div.content {background-image:url('images/bg3.jpg'); width:400px; padding:20px; } .nav a{text-decoration:none; color:black; font-size:20px; font-family:"sans serif", verdana, arial; } .nav a:hover{text-decoration:underline; } Similar TutorialsI started out working out a page thinking this *should* do what I want and lo and behold it did work in IE6 http://www.fogcat.co.uk/example/test002.html But when looking at Firefox it goes all odd. If you remove all the internal "imagediv" div from the "imagechunk" div it nearly works but doesn't algin the "link text" like IE. I'm told that display:inline-block is not properly supported, which is probably the root of my problems. What I want a set of divs down the page (the "imagedivs") Each div will contain An image - but that image will be nested inside a div - it's returned that way from a php function. Images may be of varying height so I can't use pixel values at top margins or anything like that. A link to another page The link should be positioned to the right of the image and aligned vertically with the centre of the image. This is one of those things that's a doddle with tables, but I'm trying to train myself to think CSS. What obvious thing am I over looking? Code: +--------------------------------------+ | +----------------+ | | | .............. | | --- <div> | | : : | | ... <img> | | : : | Link here | | | : : | | | | .............. | | | +----------------+ | +--------------------------------------+ +--------------------------------------+ | +----------------+ | | | .............. | | | | : : | | | | : : | Link here | | | : : | | | | .............. | | | +----------------+ | +--------------------------------------+ Hi, Just upgraded my monitor and am now operating on a 1280*1024 resolution. Previous website I have built have been for 1024*768 resolutions. Problem is now that some of my images are placed at the top of the screen when I want them in the middle... not with a load of blank space beneath them. I want the blank space equally around them. Anyway, I'm specifically talking about the website I have: http://www.atari-music.co.uk The front and home-pages suffer from this problem when viewed on > 1024*768 resolutions. I have attempted to fix the problem (though it is not in the code for the on-line version) by putting this into the style sheet:- IMG.middle { vertical-align: middle; } In the HTML for the image map I have:- <IMG class="middle" src="images/home.jpg" height="570" width="760" alt="ATARI - The Official Website" border="0" usemap="#siteMap"/> Am I not referencing the CSS code correctly? The image is still sitting, vertically aligned to the top. Cheers, Rob. Hi guys, I am trying to display two forms with several elements on a page. I would like to place the two forms on the webpage so that one is displayed on the left and the other on the right of the screen. Something like this URL http://craigbaldwin.com/blog/wp-content/uploads/2008/12/52.jpg I have written the following test and the forms are placed correctly inside the left and right divs. Code: <HTML> <Head> <style type="text/css"> div.wrapper { position: relative; clear: both; width: 100%; border : 1px solid #000000; } div.left { float: left; width: 50%; background: #ffffff; border : 1px solid #000006; } div.right { float: right; width: 50%; background: #ffffff; border : 1px solid #000001; } </style> </Head> <Body> <div class="wrapper">Wrapper <div class="left">Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box Left Box </div> <div class="right">Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box Right Box </div> </div> </Body> </HTML> A couple of problems with the above. 1. In Internet explorer the divs are aligned correctly but in firefox it gets all messy. 2. As long as the window is maximised then i the divs are aligned vertically correctly. If i resize the browser window then they are no longer aligned vertically. Is there a way to make them always next to each other from left to right even if the window is resized? (try resizing the window for the example i showed above) Thanks I have a navigation bar that contains four images (side by side) as well as three text links. They all live within a <div> with the following properties: #gNav { width:768px; height:19px; text-align:left; vertical-align:middle; } i need for the three text links to line up directly in the middle (vertically) of that <div>. To achieve this in IE6 and NN+, I attach the following style to the text. .nookum { font-size:.9em; vertical-align: 25%; color:#FFFFFF; } I just learned that the vertical-align property is not recognized by IE5 and IE5.5, so in those versions, the text aligns at the bottom of the <div>. Anyone know of any workarounds or other methods of vertically aligning text that will work in these two versions of IE? I'm wworking on a CSS template and I'm trying to vertically align two divs.... one on top of the other with a five pixel margin between the two.... However, unless I use a bunch of HTML breaks (which will result in an uneven template), I can't figure out how to do it. I've tried to vertical-align them and etc. Any help is appreciated. Oh, I know my code could be a bit more clean, this is just a comp. I've also tested this on FF so far. I doubt IE will return favourable results either. My example: www.efacln.com/Untitled-1.html My CSS code: Code: #container { MARGIN: 5px; } #header_container { border-color: black; BORDER-STYLE: solid; BORDER-WIDTH: thin; BORDER-LEFT: none; BORDER-RIGHT: none; WIDTH: 100%; } #header_content { BORDER-COLOR: black; BORDER-STYLE: solid; BORDER-WIDTH: thin; BORDER-TOP: none; BORDER-BOTTOM: none; WIDTH: 600px; HEIGHT: 100px; MARGIN-LEFT: auto; MARGIN-RIGHT: auto; } #kirk_news { BORDER-COLOR: black; BORDER-STYLE: solid; BORDER-WIDTH: thin; WIDTH: 550px; HEIGHT: 100px; FLOAT: left; POSITION: absolute; MARGIN-TOP: 5px; MARGIN-RIGHT: 2.5px; } #navigationblock { BORDER-COLOR: black; BORDER-STYLE: solid; BORDER-WIDTH: THIN; WIDTH: 410px; POSITION: relative; FLOAT: RIGHt; MARGIN-TOP: 5px; MARGIN-LEFT: 2.5px; } #scott_news { BORDER-COLOR: black; BORDER-STYLE: solid; BORDER-WIDTH: thin; width: 410PX; MARGIN-TOP: 1 px; MARGIN-TOP: 5px; } </STYLE> At http://www.rietgors.tudelft.nl/combo/ you can see what I'm trying to do. I'd like the two elements to have either the same top or bottom, or have both elements centered vertically in the enclosing DIV. Can this be done using just CSS? I need the text "world leaders in spirometry" to be on the same base line as the text in the logo image for Vitalograph to the left of it. This is what I want it to look like image link This is what does look like web page link Here is the CSS css link How can I get abosolute vertical placement of the text best for firefox and IE? I know I could put the tage into the logo as one image, but for SEO I would like to have the text there if possible. Thanks! I have #sidebar on my website and within the sidebar which contains two smaller divs (Calender and Archive) inside it which are styled by #sidebar div When I put these two divs in, Calender wasn't where I wanted it to be, at the very top of the sidebar. It was a few pixels lower. To fix I went to #sidebar div and changed the top margin to -1px and now it's at the very top. Is this a sensible fix? I've checked in Chrome 2.0, Safari 4.0, Firefox 3.5 and IE 8 and it looks to be OK but there's a nagging feeling in my head that I shouldn't have needed to do this. Here is the HTML: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link href="main.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="wrapper"> <div id="header">Content for id "header" Goes Here</div> <div id="navcontainer"> <ul id="navlist"> <li id="active"><a href="#" id="current">Link1</a></li> <li><a href="#">Link2</a></li> <li><a href="#">Link3</a></li> <li><a href="#">Link4</a></li> <li><a href="#">Link5</a></li> </ul> </div> <div id="content">jkjk</div> <div id="sidebar"> <div id="calender"><h3>Calender</h3> <p>fjkfjdklfjkljfsk</p></div> <div id="active"><h3>Archive</h3> <p>fjdkfjkfjk</p></div> </div> <div id="footer">Content for id "footer" Goes Here</div> </div> </body> </html> And here is the main.css: Code: @charset "utf-8"; /* Main style */ body { padding: 0; margin: 0; background-color: #000; text-align: center; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; } .wrapper { text-align: left; margin: 0 auto; width: 750px; } /* Header */ #header { background-color: #996666; margin-top: 35px; margin-bottom: 5px; height: 90px; padding: 0; border: solid 1px #F00; } /* Nav Bar */ div#navcontainer { background-color: #996666; border: 1px solid #F00; margin-bottom: 5px; } div#navcontainer ul { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-weight: bold; color: #000; text-align: center; margin: 0; padding-bottom: 5px; padding-top: 5px; } div#navcontainer ul li { display: inline; margin-left: -4px; } div#navcontainer ul li a { padding: 5px 10px 5px 10px; color: #000; text-decoration: none; } div#navcontainer ul li a:hover { color: #FFF; } #active a { } /* Main Content */ #content { background-color: #996666; float: right; width: 500px; border: 1px solid #F00; margin-bottom: 5px; } /* Sidebar Styles */ #sidebar { background-color: #996666; float: left; width: 243px; border: 1px solid #F00; } /* The Divs that house Calender and Archive */ #sidebar div { background-color: #800040; } /* The 'Calender' and 'Archive' text */ #sidebar div h3 { background-color: #FF0; font-size: 85%; text-align: center; text-decoration: underline; margin-top: -1px; /* Remove this line and the calender 'box' should drop a few pixels from the top */ } /* Footer */ #footer { background-color: #996666; border: 1px solid #f00; clear: both; padding: 0; margin: 0; } If someone could take a look that would be great. I've commented it up for you so you should be able to find the divs easily. The code has been verified. I'm not a great web designer by any stretch of the imagination. I'm learning as I go along so hopefully someone with more knowledge can help me out. Hi Guys, I'm trying to align some text along an image. The problem is, I want two lines of text to the right of the image, aligned to the top. If I put a <BR> tag between the two lines, the second line gets placed below the image. Here's what I have so far. img.top {vertical-align:text-top;} <a href="http://company.com/graphics/thumb.jpg"> <img class="top" src="http://company.com/graphics/thumb.jpg"> </a> <a href="company.com">sample text</a> <a href="company.com">second line</a> Any ideas? I've tried like every switch for the vertical-align property... Hi, I am trying to achieve a layout which uses unordered lists. Within the LI, there is an image and some text. The images are all different heights though. The issue i'm having at the moment is how can I make the text vertically align within the LI? Keep in mind that I can't put a height on as each image changes height. And these lists will be generated dynamically probably - so I don't really want to specify individual heights for each one... To make it even more difficult, the text may end up spanning onto two lines at some stage if i have to enter a larger description - so that also needs to be kept in mind. I've been looking around all morning for examples of how to do this and I can't find anything - so any help would be greatly appreciated!!! Here is what I'm trying to achieve: http://www.joshsphotos.com/user_interface/final_look.gif Here is the HTML at present: http://www.joshsphotos.com/user_interface/ And the CSS: http://www.joshsphotos.com/user_interface/css/style.css Thanks! hey all, here's my test page http://www.pyesnflpool.com/ at the top... Im trying to get the two links (Register & Recover Your Password) to be beside the arrows and Email Pye beside the mail image it is running off two scripts, one for the links (snippetSideLine)and the other is holding together the header (elementTopPage) As you can see on side-b I was making some effort to align them to the bottom with no success, my thoughts were to align to the bottom and than do a padding-bottom: 15px; or whatever, because I tried padding-top:120px to side-a which put the links in the right spot but left the rest of the page all over the place any help is much appreciated, thanks Code: <!-- snippetSideLine --> <div> <?php if (isset ($this->User) && !empty ($this->User)) { if ($this->User->Type == 1) { ?> <a href="../admin/index.php">Admin Panel</a> <?php } ?> <a href="../members/myaccount.php">My Account</a> <a href="index.php?Logout">Logout</a> <?php } else { ?> <a href="../members/register.php">Register</a> <a href="../members/forgotten.php">Recover Your Password</a> <?php } ?> </div> <!-- End: snippetSideLine --> Code: <!-- start: elementTopPage --> <style type="text/css"> #wrapper { text-align: left; vertical-align: text-bottom; margin: 0px auto; padding: 0px; border:0; width: 850px; } #side-a { float: left; width: 458px; height: 167px; background: url('../images/top_left.jpg') no-repeat; } #side-b { float: right; width: 168px; height: 167px; vertical-align: text-bottom; vertical-align: baseline; background: url('../images/top_right.jpg') no-repeat; } #content { float: left; width: 224px; height: 167px; background: url("../images/top_bg.jpg") repeat; } </style> <!-- elementTopPage --> </head> <body> <div id="wrapper"> <div id="container"> <div id="side-a"> <?php $this->Snippet ('SideLine'); ?> </div> <div id="content"> </div> <div id="side-b"> email pye </div> </div> </div> <!-- End: elementTopPage --> Is there a way to align something from the bottom of the page? Hello, Let's say this... I have an element that has a height of 600px. I have an element inside of that element that I want aligned to the very bottom. How could I accomplish this feat? I'd like to have a container, a row, really. And I'd like text aligned to the top of the div, and then some more text aligned to the bottom of the div, like this: ------------------------------------------ Top text Bottom text ------------------------------------------ The thing is, I can't use tables, so if someone knows how to accomplish in a completely tableless way, I'd appreciate it! I did try the following, but it didn't work: Code: .mainDiv{ position: relative; float: left; width: 150px; } .mainDiv .upper { top: 0; position: absolute; } .mainDiv .lower { bottom: 0; position: absolute; } I have decided to move another of my sites over to css, but I seem to be stuck at the first problem. I have added a small code sample... What I am wanting to do is remove the table and acheive the same result with css and div tags. How can I align text to the bottom right with css like the sample code? PHP 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" lang="en"> <head> <title>Text aligned bottom right</title> </head> <body> <table border=0 height="90px" width="100%"> <tr><td style="vertical-align: bottom;background:white;text-align:right;"> <a href="">Home</a> | <a href="">About</a> | <a href="" >Contact</a> </td></tr></table> </body> </html> Ok, so I just used Pagination for the first time (Yay). I'm creating a make shift shopping cart, and was trying to align "Add to Cart" to show at the bottom of the product listing. Right now, the products show 5 per row, and the format is: image of item item name price Then there is some padding and I want the submit button to appear at the very bottom of the div (within the a href if possible). I have the a href set as display:block, so when hovered over, the area is gray. I want the submit button to be within that area. I have tried with several variations (I did move the </a> to after the </form> line: - Placed the <form> lines within a separate div and tried aligning it to the bottom using margin-bottom - Tried styling the <input> using margin-bottom as well. My knowledge of divs isn't really that good as I never really used them much before, so I'm sure it's something simple enough. Right now when I do place it in the <a href></a> area, the Add to Cart button shows up right under the item_name... so it's staggered as item names may take up 1, 2, or 3 lines. And keeping it under the link area makes the button too far down. If you need further info, let me know. Here's the code to pulling the info from the products table: Code: $query = "SELECT `id`, `image`, `item_name`, `msrp` FROM products $limit"; $result = mysql_query($query, $conn) or die(mysql_error()); $i == 0; while($row = mysql_fetch_array($result)) { extract($row); $i ++; $image_loc = "images/products/" . $image; $j = $i/5; $display .= "<div id=\"store\"><a href=\"view_item.php?id= ".$id."\"><img src=\"".$image_loc . "\" style=\"width:100px; padding-bottom:5px;\"><br />" . $item_name . "</a>"; if ($logged_in != 'false') { $display .= "<form action=\"add_cart.php\" method=\"post\">"; $display .= "<input type=\"hidden\" value=\"".$id."\">"; $display .= "<input style=\"margin-left:20px;\" type=\"submit\" value=\"Add to Cart\">"; $display .= "</form>"; $display .= "</div>"; } if (is_int($j)) { $display .= "<div style=\"clear:both;\"></div>"; } else { } } Here's the CSS: Code: #store {width:150px; float:left; padding-bottom:30px; padding-left:15px; padding-right:15px; } #store a{display:block; text-decoration:none; padding:10px; height:200px; } #store img{border:0; } #store a:hover{background:#ccc;} Hi, I'm having a problem which I though should be fairly simple, but I've been hacking at it for many hours now. I want to align blocks horizontally at the bottom of a containing block. The containing block has a fixed height while the contained block do not. Here's a mockup of what I want: URL How should I modify the following code so that it renders like the above? Code: <div style="height:50px"> <div style="float:left">one</div> <div style="float:left">two</div> </div> Thanks! I seem to have messed up while slicing...If my font size is too large, it'll mess up my table positioning...I'd like to know if there's any way to align text to the bottom of a table collumn? Is there anything I can put in my style sheet to do this? Am I not being clear enough? Please help. EDIT : I've got a picture uploaded. See how on the left there's that white space? And under "Welcome" there's also a lot of space? I figure if I could align the text to the bottom, it'd fix both problems. =/ Please view: http://www.archanix.com/aib/about/ Notice the red square aib logo towards the bottom of the page. I have been successful in aligning the image to the bottom of the div. But because I'm using position:relative; bottom:72px; it pushes my footer down farther than I want. Any way i can get around that? Any help would be greatly appreciated. Thanks, Jesse |