CSS - Vertical Align Images In Divs
I've been having problems trying to vertically align an image within a div. I'm trying to align it to the bottom of the div. CSS as follows:
#col1r1 { float: left; height: 40%; width: 33%; display: inline; text-align: right; } div#col1r1 div#image { bottom: 66%; left: 60%; color: black; vertical-align: bottom; } div#col1r1 div img.pagegr { width: 60%; } HTML: <div id="col1r1"> <div id="image"><img class="pagegr" src="images/blah.gif" alt=""></div> </div> Unfortunately this code will be appearing on multiple pages with a different image on each page - some portrait, some landscape, and of varying sizes - otherwise, I would have added some blank space to the top of image itself to make it fit and sit nicely aligned with the bottom of the box. I'd really appreciate some help. Thanks in advance. Similar Tutorialsi really need to vertical align a div to always be at the bottom of a main div... Code: <div class="container"> <div class="menu"></div> </div> i want .menu to always be at the bottom of .container .... no matter the height of the container div I know a lot of people have made posts about vertical aligning but nearly all were involving text. I'm trying to vertically align a small image, but every time i do it within the img tag it screws up the adjacent text on IE and only IE. I know it has to do with how vertical align is supposed to be used, specific blocks or inline or something. How would I go about vertically aligning that small arrow image on the top properly. http://chics.onivertneb.com/align.htm Hi, Below is part of my code. Sorry could not upload everything otherwise code would look cumbersome, also could not load images but each image is 234 X 110. What I have is a left column. I firstly want to place a list and then three divs, each div containing an image (with text), that is also a link. I assumed with normal flow the list would appear first and then the divs, one after another. For some reason the divs go to the top of the column and are hidden by the list. I want a normal flow so that the list appears first and then the divs. Any suggestions? I would be grateful for all help. 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>Test Page</title> <style type="text/css"> h1, h2, h3, h4, h5, h6, p{ margin:0; padding:0 } img { border:none } a{color:#000;text-decoration:none} a:hover { text-decoration: underline; } body { color:#000; font-family:Verdana, Geneva, sans-serif; } #wrap { min-width: 71.08em; margin:auto; overflow:hidden; } #left { width: 17.38em; padding: 0; border: 0.125em solid #FF0000; } #left.column { text-align: justify; } #left ul { margin: 0; padding: 0; } #left ul li { list-style-type: none; } #left ul li a, #left ul li a.first_in_list { float: left; display: block; width: 16em; margin-left: 0.4em; padding: 0.28em 0 0.28em 0.25em; background-color: #FFD700; border-top: 1px dotted #FFFFFF; font-family: arial, verdana, sans-serif; font-size: 1em; font-weight: normal; color: #000000; } #left ul li a:hover { text-decoration: none; } #left ul li a:hover span { text-decoration: underline; } #left ul li a.first_in_list { width: 16em; font-size: 1em; font-weight: bold; margin-top: 1.8em; padding: 0.8em 0 0.8em 0.25em; border-top: none; } #leftVLink, #leftSLink, #leftGLink { text-align: right; border: none; margin: 0.3em 0 0 1em; } #leftVLink a:link,#leftSLink a:link,#leftGLink a:link { color: #333; width: 15em; height: 7em; display: block; font-size: 0.95em; font-family: Verdana; } #leftVLink a:hover,#leftSLink a:hover,#leftGLink a:hover { color: #000; text-decoration: underline; } #leftVLink { min-width: 14em; background: #fff url(leftVLink1.gif) no-repeat left top; margin: 1.5em 0 0 1em; padding: 0.6em 0.5em 0 0; } #leftSLink { background: #fff url(leftSLink1.gif) no-repeat left top; padding: 0.6em 0.5em 0 0; } #leftGLink { background: #fff url(leftGLink1.gif) no-repeat left top; padding: 1.4em 0.5em 0 0; } </style> </head> <body> <div id="wrap"> <div id="left" class="column"> <ul> <li><a class="first_in_list" href="#"> Shopping Directory</a></li> <li><a href="#">► <span>Latest</span></a></li> <li><a href="#">► <span>Phone Finder</span></a></li> <li><a href="#">► <span>iPhone finder</span></a></li> <li><a href="#">► <span>Deal Finder</span></a></li> <li><a href="#">► <span>Phones + FREE gifts</span></a></li> <li><a href="#">► <span>Shop by brand</span></a></li> <li><a href="#">► <span>Sim free phones</span></a></li> <li><a href="#">► <span>Coming soon</span></a></li> <li><a href="#">► <span>New and exclusive</span></a></li> <li><a href="#">► <span>Trade in</span></a></li> <li><a href="#">► <span>Compare phones</span></a></li> <li><a href="#">► <span>Mobile services</span></a></li> </ul> <div id="leftVLink"><a href="#" title="voucher codes and offers">Voucher codes<br />and offers</a></div> <div id="leftGLink"><a href="#" title="gift ideas: be inspired by our gift ideas">Be inspired by<br />our gift ideas</a></div> <div id="leftSLink"><a href="#" title="safe shopping: advice for safe shopping">Advice for<br />safe shopping</a></div> </div> </div> </body> </html> I cannot figure this out. I've tried adding clear: both in several places, I've tried overflow: hidden and I've tried cursing. Nothing works! How can this be fixed so that in IE6 the divs are not staggered vertically?? Code: <div style="height: 38px; margin: 0px; padding: 0px; width: 140px;"> <div style="float: left; height: 38px; width: 38px;"><img style="border: 1px solid #444444; vertical-align: middle" src="http://www.diversifieddesigns.com/GRAPHICS/Spacer.gif" alt="" width="38" height="38" border="0"></div> <div style="float: right; height: 38px; width: 102px;">copy</a><br>copy</a></div> </div> <div style="height: 38px; margin: 0px; padding: 0px; width: 140px;"> <div style="float: left; height: 38px; width: 38px;"><img style="border: 1px solid #444444; vertical-align: middle" src="http://www.diversifieddesigns.com/GRAPHICS/Spacer.gif" alt="" width="38" height="19" border="0"></div> <div style="float: right; height: 38px; width: 102px;"><img style="border: 1px solid #444444; vertical-align: middle" src="http://www.diversifieddesigns.com/GRAPHICS/Spacer.gif" alt="" width="38" height="8" border="0"></div> </div> Hi, Does anyone know how to veritcally align text using CSS? like <tr valign='middle'> when using tables. My page is on: http://www.3003online.com/demos/ecoceylon/v2/ You can see a difference in the "Home - About Us - Products - Contact Us" links when viewing from IE and Mozilla Firefox. Basically, I would like the text to be centered vertically in the bar... but CSS by default puts it on top. I tried adding padding,which helped in IE... but Firefox still shows the links a bit higher than they should be.,... any ideas how to fix this? Also, a different problem in case anyone knows how to fix it... you can see a small brown bar on the top bar. It is 50px in height. But I have no idea how to make its width as wide as the remainder of the page (this would change with different resolutions). The main content of the page is 760px wide. I would like a brown box next to that, which is 50px in height and the remainder width. Any ideas? "width: auto;" doesn't work unfortunately [ this is a follow up to my previous thread http://forums.devshed.com/showthread.php?t=270438 Any help would be greatly appreciated. Thanks very much. What I'm trying to do... I have some navigation links, a few pictures, and someone's name on the left hand side of the page. I want everything except for the name to be at the top.... the name is to be at the bottom. Is there a specific way to accomplish this? The content area will generally extend as high as 600 or so px, so would like the name to appear at the very bottom lined up with the content box. Thanks. Not sure exactly what code you need to see, but here's the left hand column: CSS: Code: body {width:770px; height:100%; } .nav_links {vertical-align:top; width:150px; } .nav_links a{display:block; border-top:1px solid black; text-decoration:none;} HTML: Code: <!-- Left Nav Menu --> <div class="nav_links"> Link 1 Link 2 Link 3 Link 4 Link 5 </div> <!-- End Left Nav Menu --> <!-- Misc. Pictures (Left Column)--> <div> <div style="float:right;"> <img src="images/left_pic_1.jpg" alt="Pic1" style="width:50px; margin-bottom:10px;" /><br /> <img src="images/left_pic_2.jpg" alt="Pic2" style="width:50px;" /> </div> </div> <div style="clear:both;"> <div style="float:right;"> <img src="images/left_pic_3.jpg" alt="Pic3" style=" width:50px; margin-bottom:10px;" /><br /> <img src="images/left_pic_4.jpg" alt="Pic4" style="width:50px;" /> </div> </div> <!-- End Misc. Pictures (Left Column) --> <!-- Name --> <div class="name" style="vertical-align:bottom;"> First M. Last </div> <!-- End Name --> Hi I want to know if it is possible to vertical align the text in these div tags and how it's done. 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> <style type="text/css" media="all"> #1 {width:15%} #2 {width:20%} #3 {width:25%} #4 {width:20%} #5 {width:20%} #1,#2,#3,#4,#5 { float:left; overflow:hidden; display:inline-block; height:128px; text-align:center; } </style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <div id="1"><a href="#"><img name="" src="" width="100" height="125" alt="" /></a></div> <div id="2"><a href="#">fffffffffffggfgf fg gd</a></div> <div id="3"><a href="#"> dfg dfg dg d</a></div> <div id="4"><a href="#"> dgd gd d</a></div> <div id="5"><a href="#"> gdf gdg ddg</a></div> </body> </html> Greets, dabomb_gent for example if there is a container div which holds an inner div, if i want the content of the inner div to appear exactly at the bottom edge of the inner div i have used the following code, #outer{ position: relative; float: left; width: 900px; height: 200px; } #outer .inner{ position: relative; float: left; width: 500px; height: 200px; vertical-align: bottom; } however the content of the inner div is starting at its default location which is top left of the inner div instead of using margin-top or padding-top, or positioning methods for the inner div to position the content at the bottom edge can the vertical-align: bottom; be used as this will be very accurate placed at the bottom edge even if the content increases the content will always appear at the bottom edge, unlike other methods where the margin-top, padding-top, and positioning, these values will have to be changed whenever content increases or decreases. please advice. thanks. How can i make #mydiv DIV (the main layout div), be vertically aligned to middle? http://www.dinal.ru/new/max/index2.htm I've read a lot of docs about vertical alignment in internet, but I haven't found a good cross-browser solution, which doesnt't destroy my current layout. Thank you in advance Artashes I'm trying to put a line of text on the bottom of a box. Code: <div style="width:500px;height:500px;background:black;vertical-align:bottom;"> This is a black box </div> <div style="width:500px;height:500px;background:black;vertical-align:baseline;"> This is a black box </div> What the above code displays: Code: ------------------------- | This is a black box | | | | | | | | | | | | | | | ------------------------- What I want it to display: Code: ------------------------- | | | | | | | | | | | | | | | This is a black box | ------------------------- Hello to all of you, I am doing my first steps in respect to CSS programming and wonder if I can get some hint here. I have created a table, with two different line colors, and a changing line background color with hover. Basically everything works as expected - just the vertical-align command does not respond at all. Am I doing something wrong? What could be the reason, and how can I continue investigating? I am using the CSS stylesheet, in connection with a Joomla 1.5 CMS. Please see the code below: Code: table.general { text-align: left; vertical-align: top; width: 100%; border-collapse: collapse; } table.general th { text-align: center; font-size: 15px; color: white; font-style:bold; height: 30px; background-color:#95B3D7; border: 3px solid #FFFFFF; } table.general tr.row1 { background-color: #f1f1f1; } table.general tr.row2 { background-color: #e0e0e0; } table.general tr.row1:hover { background-color: #CCCCCC; } table.general tr.row2:hover { background-color: #CCCCCC; } table.general td { border: 3px solid #FFFFFF; padding: 4px; } The classes are being used in the following form: Code: <table style="width: 320px;" class="general"> <col span="4" width="80"></col> <tbody> <tr> <th>head A</th> <th>head B</th> <th>head C</th> <th>Alface</th> </tr> <tr class="row1"> <td>Topic A</td> <td>65</td> <td>215</td> <td>35</td> </tr> <tr class="row2"> <td>Topic B</td> <td>2</td> <td>2,3</td> <td>1,2</td> </tr> <tr class="row1"> <td>Topic C</td> <td>68</td> <td>55</td> <td>13</td> </tr> <tr class="row2"> <td>Topic D</td> <td>44</td> <td>50</td> <td>33</td> </tr> <tr class="row1"> <td>etc.</td> <td>494</td> <td>611</td> <td>238</td> </tr> </tbody> </table> Thank you in advance for your kindness! Is not working for me, or I'm not using it right. Here is my problem: http://www.kingtoad.net/development/kingtoad.net/ I want the "navigation" to align to the top even with the "content". I can't seem to get it up there though. Any suggestions would be nice. Hi, I am trying to use the vertical-align property to make some text appear in the middle of a div (set float:left). However it is not working. Following is some sample code I have done for testing: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>ccc</title> <style> div{ width:16.7em; height:6.8em; border:1px solid black; vertical-align:middle; float:left; } </style> </head> <body> <div>hello</div> </body> </html> Is this possible? Thanks and Regards, Sim085 I have a div container that changes size depending on the information inside it... i also have a navi bar that is on everysingle page.... and i want it to always be 20px from the bottom.... i tried vertical-align:bottom and put a margin-bottom:20px on it... but the vertical-align didnt seem to work... i must be missing something Thanks for taking the time to read my question. I have an image that I want to place in the middle of a contaier. I have <center></center> around the <img /> tag, but I can't get it to center vertically with the css below. What am I doing wrong? Thanks, Brad CSS: Code: img.contentimg { vertical-align: middle; } HTML: Code: <div class="textbox1"><center><img class="contentimg" src="images/house1.jpg" /></center></div> i am trying to vertical align the "go" button next to the text field. i've also tried to use margin's on the go button.. but it just messes up... anyhow, here is a link... http://defunctgames.com/helpfix/page2.htm thanks I've got an image that is 75px high. Right beside it, I have a H1. I want to vertically align the H1 in the middle of the image. Vertical align doesn't work, and for some reason, setting the line height to the height of the image doesn't work either. Okay, I have an unordered list of images (im usings lists for ajax reasons). I have formatted the list to look much like a 4x4 table. Each cell has an image in it. I need to make the images vertical-align middle. at the moment the code i have is this: Code: <ul style="margin:0;padding:0;list-style-type:none;"> <li style="text-align: center; width: 140px; background-color: #e7e7e7; height: 150px;float: left;"><div style="height: 150px;"><a href="#"><img src="image.gif" style="vertical-align: middle;" ></a></div></li> <li style="text-align: center; width: 140px; background-color: #e7e7e7; height: 150px;float: left;"><div style="height: 150px;"><a href="#"><img src="image.gif" style="vertical-align: middle;" ></a></div></li> <li style="text-align: center; width: 140px; background-color: #e7e7e7; height: 150px;float: left;"><div style="height: 150px;"><a href="#"><img src="image.gif" style="vertical-align: middle;" ></a></div></li> <li style="text-align: center; width: 140px; background-color: #e7e7e7; height: 150px;float: left;"><div style="height: 150px;"><a href="#"><img src="image.gif" style="vertical-align: middle;" ></a></div></li> </ul> I added the div in hopes that this would help the vertical align, however it still aligns at top. Any ideas? I MUST use the list. Thanks for any help! Hi, I'm trying to vertically align an element in my layout which is xhtml strict but it's not working. Here's the page: http://www.valeit.com/ben/test.htm The text should be vertically aligned in the middle of the layout but I can't seem to work it out. All the CSS is on the page - can anyone see what I'm doing wrong? Many thanks Kevin Hello all, Is there a good way to have the text in a select box be vertically aligned? I have the following: Code: <select style="height: 12em; width: 12em;"> <option value="a">A</option> <option value="b">B</option> </select> Which puts the text in the upper left but I would like it to be in the dead center. I tried vertical-align but it did not work. |