CSS - Reduce Vertical Space Between Form Elements?
How do I reduce the vertical space between form elements that I put inside a div?
I have text "username" with the textbox below it but there is like 25 pixels of vertical space between them. Brad Similar TutorialsHi guys, I've tried for days but can't solve the problem. I wanna position a text field and button in the middle of a div or table. FF displays well, IE of course not (always on top). Vertical alignment etc doesn't work! Any suggestions? Hi everyone -- first post here in the forums. I hope I can get some pointers on how to get my page to display correctly in IE. I have 2 div tags at the top of my page that are built sorta like this: Code: <div> <ul> <li> some thing (images in my case, and a search bar) </li> </ul> </div> My css for these elements has "list-style:none;" -- and this works great in modern browsers like firefox, chrome, safari, opera... but the old dinosaur which 30% of my visitors still use doesn't handle this all right. See, I am displaying these list elements in a single horizontal row, but IE wants them in a single vertical column. UGH. I have a post with a screen shot from firefox and IE at this link: http://corneveaux.com/blog/new-animated-banner-and-internet-explorer-sucks So, I am sure its something I have done wrong -- but I cannot get my arms around the problem with firebug or IE developer tool bar. I am a total CSS newb here, so any tips much appreciated. Oh, and I checked and indeed my CSS validates. Thanks everyone! I have a region with a div, an image and another div stacked vertically. For some reason, there are a few pixels of blank space between the image and the bottom div. http://www.brucethorn.com/index.php...maritime-sunday On another page, I have regions with a "line-height + vertical-align:middle" centering of an image that make up thumb nails. There too is a few pixels of blank space, but at the top and images, pushing them down and slightly outside of the div that contains each of them. http://www.brucethorn.com/index.php/paintings I suspect these are the same problem, but I could be wrong. The issue is most visable in FF, and noticable in Opera. I only see something sporadic for the second occurence in IE Code: body {background-color:#999999; margin:0px; padding:0px; border:0px; text-align:center; font-family:"Courier New", Courier, mono;} h1.header {height:16px; width:800px; _width:776px; font-size:100%; font-weight:bold; margin:0px 0px 0px 24px; text-align:left; background-color:#333333;} h2.header {margin:0px; font-size:90%; font-weight:bold;} div {text-align:left;} h2.infoleft {text-align:left; height:16px; width:576px; font-size:90%; margin:0px 0px 0px 24px; _margin:0px 0px 0px 12px;float:left;} h2.inforight {text-align:right; height:16px; width:176px; font-size:90%; margin:0px 24px 0px 0px; _margin:0px 0px 0px 0px;float:left;} div.black {background-color:#000000; color:#999999;} div.block {margin:8px 24px 8px 24px; text-align:justify; font-size:90%;} div.block2 {margin:8px 0px 8px 12px; _margin:0px 0px 0px 4px;} div.block3 {margin:8px 0px 0px 12px;} img {border:0px; margin:0px; padding:0px;} img.left {float:left;} img.right {float:right;} div.bar {height:16px; width:auto; text-align:center;} div.title {height:48px; width:800px; margin:auto;} div.content {height:392px; width:800px; margin:auto; text-align:center;} div.subbar {height:16px; width:800px; background-color:#333333;} div.menu {height:18px; width:480px; float:left; margin:30px 0px 0px 20px;} div.copyright {height:16px; width:800px; margin:auto; text-align:right; font-weight:bold; font-size:75%;} div.scroll {height:344px; width:800px; margin:8px 0px 0px 0px; overflow:auto;} div.filmunit {height:128px; width:128px; border:4px; border-style:solid; border-color:#000000; background-color:#999999; margin:8px; padding:0px; float:left; text-align:center; line-height:128px;} img.filmimage {vertical-align:middle;} My site I am redesigning this site for a theater camp company. I want to create the effect of stage lights shining with a image rollover and am partly there. I am stuck now because I want to use an HR as the cross beam with images of stage lights directly below (take a look at the site to understand). I do not know how, or if it's possible, to line up the images directly below the HR (bar) so there is no space at all. Any help? This is my first css based site...i'm having a nightmare time and wonder why this is so much better than tables when its taking me 4 hours in css what takes me 5 minutes with tables? that being said if you go he www . chhs . unh . edu / v3 . html on the right side here is the issue: in FF the contained divs are larger than the containing div in IE there is like 20 pixels of space at the top of the first containted div here is the code for this section, the sidebar is the container and the other 2 are the divs inside, quicklinks is the first one. Code: .twoColFixRtHdr #sidebar1 { width: 300px; float:right; text-align:left; background-color:#00F; padding:0px; display:inline; line-height:100%; } div#quicklinks{ display:block; width:300px; margin: 0px 0px 0px 0px; background-image:url(/images/v2/quicklinks_bg.png); background-position:top right; background-repeat:no-repeat; background-color:#AEAE5D; padding: 5px; color:#FFF; vertical-align:top; } div#photo_gallery_links{ width: 300px; margin: 10px 0px 0px 0px; background-image:url(/images/v2/photosbg.png); background-position:top right; background-repeat:no-repeat; background-color:#283C6F; padding: 5px; color:#FFF; } can anyone help me? i haven't used a board like this in like 8 years so i'm sorry if i'm doing it wrong. thanks! i have two divs on top of eachother with images in each. there is a space i can't get rid of in IE..looks perfect in firefox. i've tried cutting out the margins and padding to no avail. seems like ie regularly has spacing problem from google searches but none of their fixes have worked yet. I'm going through hell trying to make a site look the same in IE and Firefox. The biggest problem is the gaping spaces IE adds between elements. What is the best way to fix this? Example at patrolmag.com/new. Any advice or help would be most appreciated. P.S. How the page looks in Firefox 3 is ideal. I just need to make at least IE7 come somewhere close to matching it. Hi, I'm trying to avoid using absolute positioning (and using a margin or padding) to vertically place two divs. clear:both seems to be close but it clears double the amount of space that I want. 1. What determine's how much space is cleared? 2. Is it a problem that neither of the divs is floated? http://www.sabahseaside.com/sti/testindex.php Code: #homecontent { position:relative; margin:10px; } #homecontent p { text-align:justify; margin:0 1em 2em; } .hometop { margin:0; padding: 0; border: 1px solid black; } .homebottom { margin:0; padding: 0; border: 1px solid black; clear:both; /*margin-top:4em;*/ } http://www.sabahseaside.com/sti/layout.css Oh yeah, and the images in those divs are floated! AHHH! I am trying to style a css layout. I keep getting a vertical space between two different block containers. here is the html: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title></title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="default.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="menu"> </div> </div> </div> </body> </html> Here is the CSS: Code: #wrapper{ margin: 0 auto; width: 977px; } #header { margin: 0; background: url(images/header_01.jpg) no-repeat 0 0; width: 977px; height: 198px; } #menu{ margin: 0; background: url(images/header_02.jpg) no-repeat 100% 0; float: left; width: 977px; height: 44px; position:relative; top: 100% } My theory: the top part of the header is 154 px tall. The bottom part is 44px tall. That makes 198px height. so with header being 198px tall, and the smaller image with a relative position 100% down from the top should correctly line up the two images. But yet I have a HUGE gap?!?! Why? Even if I put 154px instead of 100% for top ... it will not line up correctly. Hi all, after my last query it was suggested that my use of absolute positioning for every element was not necessary. I should go with the flow. So I copied a basic page structure and twiddled a little. Here is the result so far html link css link A couple of questions. 1. Would you say I'm on the right track, or should I be looking at a different style structure? 2. The page appears in ie to have gaps around the elements. In Mozilla it looks like I hoped it would look. How to close up gaps in ie. I'm trying padding, margin, negative values etc, Checking in the morning in hope of miraculous fix. No luck so far. Any help, advice appreciated. Thanks Solar.. I am trying to style a form using CSS instead of tables but am getting unwanted space above form elements when i use float:right to position them to the right of the prompt text. I have spent some time reading about the problem which appears to be an error with IEs rendering of CSS. I have tried several solutions posted on the web with no success. Can anyone recommend a solution to my problem. Thanks. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> <style type="text/css" media="screen"> .form { font-size:10px; text-align:left; } .form input { width: 100px; font-size: 9pt; border: 1px solid #891C46; margin-left: 12px; padding-top:0px; float:right; } .form select { width: 100px; float:right; font-size: 9pt; border: 1px solid #891C46; } .form textarea { width: 100px; float:right; font-size: 9pt; border: 1px solid #891C46; } .form li{ list-style-type: none; clear:both; } .form img{ padding-top:10px; float:right; } </style> </head> <body> <table cellpadding="0" cellspacing="0" width="500"> <tr> <td width="50%" valign="top" class="form"> <ul> <li>Your name:<input name="textfield" type="text"></li> <li>Your email address:<input name="textfield" type="text"></li> <li>Your company:<input name="textfield" type="text"></li> <li>Your position:<input name="textfield" type="text"></li> <li>Subject:<select name="select"><option>Digital Advertising</option></select></li> <li>Query/comment:</li> <li><textarea name="textarea" cols="20" rows="8"></textarea></li> <li><img src="/carlton-newsite/img/contactus/send.gif" name="send" width="50" height="25" id="send"></li> </ul> </td> <td valign="top">sfasfasfasdfasdfasdfasdf</td> </tr> </table> </body> </html> Argh. Tried a number of variations on this probably simple task. Nonetheless: In this example how do I get the 'sidebar' to fill the vertical space of the container, and ensure the 'footer' remains positioned at the bottom (which it currently does) http://www.mandgweb.net/css_test/css_test.html Thank you Hi, Can anyone help me please? I'm not very good at CSS and I want to change something on a template that I have bought. All I want to do is reduce the whitespace by 50% above and below the currency/language/shopping cart at the very top of my site. Can anyone take a look at the css file and tell me how to do it please? The site is at bank of flowers .co .uk Thanks Trev Hi everyone, I am having a problem where my text is resonably small and the paragraph spaces between them look silly because they seem much too big for the font size. Please have a look at my example below: CSS: Code: div.orange{ background-color: #993400; color: #FFFFFF; width: 174px; font-size: 10px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-weight: none; text-align: justify; padding: 3px } .orangeHilight{ color: #000000; font-weight: bold; } HTML: Code: <div class="orange"><p>DO YOU KNOW?</p> <p class="orangeHilight">Suppliers are shown per your choice of category:</p> <p>PLATINUM suppliers are shown first, with details of their companies and hospitality experience, contact details and a link to their own web sites for a closer look at their products. They also have pictures in the listing.<br> GOLD suppliers are shown next, but without pictures.<br> SILVER suppliers are listed with limited information and contact details.</p> <p>We also have a number of free listings for suppliers not currently registered with Hotelstuff. These are suppliers who may be of interest to you. Our toll free desk can help you with current contact information.</p></div> See what I mean. So is there anyway to reduce the space between paragraphs? Thanks to anyone who can help me out! Kenneth I am simply trying to align a form (text field and submit button) to the bottom of its containing div. My method works with text, but not the form... it just stays up at the very top. The CSS: Code: #search { padding: 0 25px 0 0; float: right; } #srchbox { height: 118px; position: relative; } #srchbox .form { bottom: 0; position: absolute; } The HTML: Code: <div id="search"> <div id="srchbox"> <p class="form"> <form> <input type="text"><input type="submit" value="Go"> </form> </p> </div> </div> I know that a form shouldn't be expected to act like text... but I don't know how to go about getting to align at the bottom. Thanks! hello everyone, 'tis my frist post... Just had'a quick question I'm working on a page, and l'm trying to create a text input with a background image, that has NO border, so that it nests inside of a table cell with no excess fluff. However the input has a 1 pixel high "line" that spans across the top of the element, and a 1 pixel high "line" across the bottom as well. I can't seem to get rid of it, is it possible? here's the code, l was trying to get to work with this: Code: <HTML> <HEAD> <style> /*Left searchBar Cap*/ td.leftCap{ background-color: #c0c0c0; background-image: url('images/searchBar_1x1.gif'); background-position: 0px 0px; width: 28; height: 50; padding-top: 0; padding-bottom: 0; padding-right: 0; padding-left: 0; } /*right searchBar Cap*/ td.rightCap{ background-color: #c0c0c0; background-image: url('images/searchBar_1x3.gif'); background-position: 0px 0px; width: 34; height: 50; padding-top: 0; padding-bottom: 0; padding-right: 0; padding-left: 0; } /*searchBar Top bar*/ td.searchTop{ background-color: #c0c0c0; background-image: url('images/searchBar_1x2.gif'); background-repeat: repeat-x; background-position: 0px 0px; width: 425; height: 16; padding-top: 0; padding-bottom: 0; padding-right: 0; padding-left: 0; } /*searchBar Bottom*/ td.searchBottom{ background-color: #c0c0c0; background-image: url('images/searchBar_3x1.gif'); background-repeat: repeat-x; background-position: 0px 0px; padding-top: 0; padding-bottom: 0; padding-right: 0; padding-left: 0; width: 425; height: 15; } /*center of searchBar*/ td.searchCen{ background-color: limegreen; background-position: 0px 0px; width: 425; height: 19; padding-top: 0; padding-bottom: 0; padding-right: 0; padding-left: 0; } BODY { background-color: #c0c0c0; background-attachment: scroll; margin-top: 0; margin-bottom: 0; margin-right: 0; margin-left: 0; } /*input*/ .input { background-image: url('images/searchBar_2x1.gif'); color: #191919 border-width: 0px; padding: 0px; border-style: hidden; border: 0; border-top-width: 0px; border-bottom-width: 0px; font-family: Comic Sans MS (cursive); font-weight: extra-bold; font-size: 10pt; width: 425; height: 19; } </style> </HEAD> <BODY> <center> <form> <table cellpadding="0" cellspacing="0"> <tr><td> <table cellpadding="0" cellspacing="0"> <tr> <td class="leftCap"> </table> <td> <table bgcolor="#c0c0c0" cellpadding="0" cellspacing="0" border="0"> <tr> <td class="searchTop"> <tr> <td class="searchCen"> <input type="text" size="40" class="input" value="search google ... "> <tr><td class="searchBottom"> </table> <td> <table cellpadding="0" cellspacing="0"> <tr> <td class="rightCap"> </table> <td> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td bgcolor="#c0c0c0" align="center"> <a onClick="javascript:searchGoogle();" href="#"> <img border="0" src="images/searchBar_1x4.gif" width="113" height="50"></a> </table></table> </form> <script> query = document.forms[0].elements[0].value; function searchGoogle(){ if(query){ url = "http://www.google.com/search?hl=en&lr=&q="+query+"&btnG=Search"; window.open(url); }} </script> </BODY> </HTML> Thanks for your help! Samantha G. hey What i want is to have one line with a select box and a submit button on it. But when i put those 2 elements in a form it takes up 2 lines. How can i make it so that the form wont require an extra line? Hello all. I'm trying to get the form layout to mimic a table like structure so that all the input elements line up. I have the following: 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> <title>Search Home</title> <style type="text/css"> .csc-mailform-field label { width: 10em; } #mailformformtype_mail { margin-top: 1em; } </style> </head> <body> <form action="contact/contact-form/" id="mailform" enctype="multipart/form-data" method="post" onsubmit="return validateForm('mailform','First_Name,First%20Name,Last_Name,Last%20Name,Email,Email,Email_Message,Ema il%20Message','','','')"> <fieldset class="csc-mailform"> <div class="csc-mailform-field"> <label for="mailformFirst_Name">First Name</label> <input type="text" name="First_Name" id="mailformFirst_Name" size="14" value="" /> </div> <div class="csc-mailform-field"> <label for="mailformLast_Name">Last Name</label> <input type="text" name="Last_Name" id="mailformLast_Name" size="14" value="" /> </div> <div class="csc-mailform-field"> <label for="mailformSuffix">Suffix (e.g. Ph.D., M.D.)</label> <input type="text" name="Suffix" id="mailformSuffix" size="14" value="" /> </div> <div class="csc-mailform-field"> <label for="mailformEmail">Email</label> <input type="text" name="Email" id="mailformEmail" size="14" value="" /> </div> <div class="csc-mailform-field"> <label for="mailformPhone_Number">Phone Number</label> <input type="text" name="Phone_Number" id="mailformPhone_Number" size="14" value="" /> </div> <div class="csc-mailform-field"> <label for="mailformCompany">Company/Institution</label> <input type="text" name="Company" id="mailformCompany" size="14" value="" /> </div> <div class="csc-mailform-field"> <label for="mailformEmail_Message">Email Message</label> <textarea name="Email_Message" id="mailformEmail_Message" cols="14" rows="5"></textarea> </div> <div class="csc-mailform-field"> <input type="submit" name="formtype_mail" id="mailformformtype_mail" value="Send Message" class="csc-mailform-submit" /> </div> </fieldset> </form> </body> </html> I thought that by setting the width of the labels, it would force the inputs to all line up but apparently this does nothing. Also I did not place the size attributes on the input, this is a form generated by a CMS. Suppose I have: 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> <script type="text/javascript"> //********************************************************** // This function adds another field to the form based on // what field name is passed in. //********************************************************** function add_item(field) { if(!document.getElementById) return; //Prevent older browsers from getting any further. var field_area = document.getElementById(field + '_field'); var all_inputs = field_area.getElementsByTagName("input"); //Get all the input fields in the given area. // Find the count of the last element of the list. It will be in the format '<field><number>'. If the // field given in the argument is 'friend_' the last id will be 'friend_4'. var last_item = all_inputs.length - 1; var last = all_inputs[last_item].id; var count = Number(last.split("_")[1]) + 1; if(document.createElement) { //W3C Dom method. var li = document.createElement("li"); var input = document.createElement("input"); input.id = field+count; input.name = field+count; input.type = "text"; //Type of field - can be any valid input type like text,file,checkbox etc. li.appendChild(input); field_area.appendChild(li); } // end if(document.createElement) else { //Older Method field_area.innerHTML += "<li><input name='"+(field+count)+"' id='"+(field+count)+"' type='text' /></li>"; } // end else } // end function add_item(field) //********************************************************** </script> </head> <body> <form> <table> <tr> <td><label for="images">Images (for banner and sidebar)</label></td> <td> <ul id="images_field"> <li><input type="text" id="images_0" name="images_0" /></li> </ul> </td> <td><input type="button" id="button" value="Add another image" onclick="add_item('images');" /></td> </tr> <tr> <td colspan="3"> <label for="misc">Misc. (anything that falls outside of the above categories)</label><br /> <textarea rows="3" cols="3" id="misc" name="misc"></textarea> </td> </tr> <tr> <td colspan="3"><input type="submit" id="submit" value="Submit project" /></td> </tr> </table> </form> </body> </html> When I click the add another image button, it will create a new form field for another image. But it keeps stacking them on top of the elements below it. I would like for everything below it to be shifted down when a new element is inserted. I tried the clearfix method but couldn't get it to work. Thoughts? Edited to say that this behavior only appears in FireFox. |