CSS - Making A Fieldset And Legend Look Like A Label
Not the best title, but I couldn't think of a better way to describe what I am trying to do.
I currently use css to position form elements and their labels nicely without the use of tables. I now want to be able to add fieldset tags, encapsulating a bunch of radio or checkboxes, and a legend tag, and have that legend tag appear exactly as my current label tags do. Easier to look at the demo page I think: http://markdw.com/formTest.html Looks fantastic in FF, almost perfect in IE, but not so good in Safari (all on a PC). I can fix the positioning of the fieldset in Safari by removing the top:-18px and margin-top:-18px styles, but no matter what I do I cannot get the LEGEND to show up on the page. The same applies to IE6 I just noticed. a) I hope the code is useful and/or interesting to others, and b) I hope someone will be able to help me with the safari issue Many thanks. Similar TutorialsHi Guys, I'm trying to figure out if a certain formatting is available for Fieldsets, specifically, the legend styling. In the fieldset, the legend is typically displayed in the top left corner of the fieldset. I'm wanting to have TWO legends. One in the top left, and one in the top right. Here's two examples. A normal one, and one with two legends that I would like. (i photoshopped the 2nd one). Is this possible? Just wondering if there are any css tags that would be able to produce a fieldset/legend look like this... The idea of being able to get a link to show up on the right side there is what i'm trying for. thanks for reading... Hello! I am using some pretty simple css to format a form for my website. I really like the way using Fieldset & Legend allows for quick and easy formatting of the form but I have one small problem. When I give the fieldset a background it goes above the border of the legend and doesn't look right. I've seen forms that have worked around this problem but I'm not sure how. Any suggestions or help would be appreciated! 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"> <title>ALE Join Form</title> <head> <style type="text/css"> fieldset { border: 2px solid #87AFC7; width: 50%; background: #F5F5F5; } legend { color: #fff; background: #87AFC7; border: 1px solid #fff; padding: 2px 6px } </style> </head> <body> <form action="#" method="post"> <fieldset> <legend>ALE Membership</legend><br><br> <!-- Provide a dropdown menu option field with sauces. --> <input type="hidden" name="on0" value="Type">Type of Sauce <select name="os0"> <option value="Select a type">-- Select a type --</option> <option value="Red">Red sauce</option> <option value="Green">Green sauce</option> </select></p> <br /> <!-- Provide a dropdown menu option field with prices. --> <input type="hidden" name="on1" value="Size">Size <select name="os1"> <option value="06oz">6 oz. bottle - $1.00 USD</option> <option value="12oz">12 oz. bottle - $2.00 USD</option> <option value="36oz">3 12 oz. bottles - $3.00 USD</option> </select></p> <br /> <!-- Display the payment button. --> <input type="submit" name="submit" value="submit" /><br><br> </fieldset> </form><br><br> <fieldset> <legend>Thank You</legend> <center> <p>Your something is complete!</p><br> </center> </fieldset> </body> </html> Below is a link to a terrible picture of the form (sorry it's not online): http://www.leadershipeducators.org/redesign/images/users/Jared/profile.jpg been tearing my hair out with this problem I've been doing an expanding menu for drupal and functionally it works perfect. You click on the legend, it expands the fieldset. However I'm having major difficulties on the CSS side of things. The problem is that when I adjust the height of the legend to fit the background image, it doesn't push the other fieldsets down in IE 7 and 8 but it does in Firefox and (oddly) IE6. Given that means a ~20 pixel gap between menu items in Firefox compared to none in IE7,8 it means the menu always looks ugly in one of the two sets of browers. Here's the CSS in question (displays ok in IE7,8 but spaced out in FF): Code: fieldset.accordian { border:none; margin-top:8px; padding-bottom:3px; width:205px; } legend { background-image: url('images/menubg.png'); background-repeat: no-repeat; margin:0; padding:0; width:205px; line-height:37px; height:37px; } Within the LEGEND tag, how would I position the radio buttons to the far right? I thought something like the following would work, but wasn't sucessful. .radios {text-align: right;} Thanks Code: <fieldset> <legend> Some Text <select><option value="1">One</option><option value="2">Two</option></select> <span class="radios"> <input type="radio" name="r" id="r" value="1">one <input type="radio" name="r" id="r" value="2">two </span> </legend> <table> <tr><td>bla</td><td>bla</td></tr> <tr><td>bla</td><td>bla</td></tr> <tr><td>bla</td><td>bla</td></tr> </table> </fieldset> Hi guys, sorry if its newbie question, don't work with CSS so long. I've just read a nice article about styling CSS forms (Fancy Form Design) and it looked really nice, so I tried to apply it immediately. However, some problems occured, things are never so easy I guess . First problems occurs with styling of group of form elements: they are dropped one line down (below its label, resp. legend) in IE 5.5/6.0 and also moved to the right (in IE 5.5-7.0) for some reason. Also, styling of fieldsets' legends works odd: first legend is styled differently than the others (one would guess that all of them will be styled in same way). Could you give me pls a little hint on these problems? Here's the test page with applied form styling: http://147.32.122.251/hsh2t/index.php. General CSS: http://147.32.122.251/hsh2t/forms.css IE (5.5-6.0) only CSS: http://147.32.122.251/hsh2t/forms-ie.css does fieldset have a width attribute rather than having it spread across the whole screen or should i just put it inside a DIV tag? I can't seem to set any padding on the fieldset element with ie7 Has anyone else had these problems and is there a way I can fix this. I even set the fieldset element to a block level element but that didn't work either. example http://section31.us/scripts/testing/xhtml/fieldset.html Hi, I currently have the following layout in a fieldset: [IMG]EDIT: I'll just go ahead and make some spam posts now so I can post an image link[/IMG] Please ignore the language. What I basically want to achieve is making the radio buttons align to the right and the labels to the left. The source for this is like this: html4strict Code: Original - html4strict Code <fieldset> <legend>Beantwoord a.u.b. met helemaal oneens tot helemaal eens</legend> <ol> <li> <label for="q0">Question1</label> <input type="radio" id="q0" name="q0" value="1">1</input> <input type="radio" id="q0" name="q0" value="2">2</input> <input type="radio" id="q0" name="q0" value="3" checked="true">3</input> <input type="radio" id="q0" name="q0" value="4">4</input> <input type="radio" id="q0" name="q0" value="5">5</input> <input type="hidden" name="qid0" value="4" /> </li> <li> <label for="q1">Question2</label> <input type="radio" id="q1" name="q1" value="1">1</input> <input type="radio" id="q1" name="q1" value="2">2</input> <input type="radio" id="q1" name="q1" value="3" checked="true">3</input> <input type="radio" id="q1" name="q1" value="4">4</input> <input type="radio" id="q1" name="q1" value="5">5</input> <input type="hidden" name="qid1" value="6" /> </li> <li> <label for="q2">Question3</label> <input type="radio" id="q2" name="q2" value="1">1</input> <input type="radio" id="q2" name="q2" value="2">2</input> <input type="radio" id="q2" name="q2" value="3" checked="true">3</input> <input type="radio" id="q2" name="q2" value="4">4</input> <input type="radio" id="q2" name="q2" value="5">5</input> <input type="hidden" name="qid2" value="7" /> </li> <li> <label for="q3">Question4</label> <input type="radio" id="q3" name="q3" value="1">1</input> <input type="radio" id="q3" name="q3" value="2">2</input> <input type="radio" id="q3" name="q3" value="3" checked="true">3</input> <input type="radio" id="q3" name="q3" value="4">4</input> <input type="radio" id="q3" name="q3" value="5">5</input> <input type="hidden" name="qid3" value="24" /> </li> <li> <label for="q4">Question5</label> <input type="radio" id="q4" name="q4" value="1">1</input> <input type="radio" id="q4" name="q4" value="2">2</input> <input type="radio" id="q4" name="q4" value="3" checked="true">3</input> <input type="radio" id="q4" name="q4" value="4">4</input> <input type="radio" id="q4" name="q4" value="5">5</input> <input type="hidden" name="qid4" value="40" /> </li> </ol> </fieldset> <fieldset> I already tried making them float but this kinda messed everything up as some questions are multi-line. Is the best way to do this separating the labels and inputs into two floating divs or is there a way that would look cleaner code-wise? Tim The border around the fieldset in IE7 is messed up. The right border is shifted to the left several pixels. It looks fine in IE6. In FF the border isn't shifted but there is less padding on the right side of the fieldset than the left. I can't figure that one out either. If I zero out all the padding & borders the input/textareas push a few pixels out the right side of the fieldset. Looks fine in IE6. So has anyone seen either of these issues and might know how to correct them? Here is the page in question Thanks! Hello All, I am having a bit of a problem with IE and fieldsets. I am not sure what exactly is going on. Take a look at this site in Firefox (I'm currently running version 3.5.2). You will see that it displays correctly. The site also displays correctly in IE8. I am now testing it against IE6/7. I have worked out most of the problems with it, but can not figure out what is causing this issue. The pages to look at are Board Members, Tech News, and Association. The link is: http://209.159.189.187/index.html One further, minor, issue that hopefully is simple involves the UL LI items on the About Us page. I used the reset css file to clear everything, and now whenever the LI item contains text that spans more than a single line, the second level does not indent itself to align with the first line. Like I said, it is a minor thing, but I would appreciate knowing what setting controls that. Thanks everyone. I have a form label styled from an external stylesheet. I don't understand why some style options don't seem to work. For example, setting the width of the label seems to have no effect. But setting the font does work. I assume it is because of some parent div style? The stylesheet is from a template in which I am attempting to make some additions. I'm actually having the same problem with unordered lists. Could someone explain what would cause some style options to be ignored? I can post the stylesheet, but it is rather long. Thanks. Hello. I have code like this one Code: <div class='captionCell cbregName'> <label for="cbpplan10">AVATAR DESIGN</label> </div> how to hide just that label. Since there is many <div class='captionCell cbregName'> but labels are named different like for="cbblane9"... Hi, I am using fieldset to group checkboxes. fieldset { border:none; autoHeight:true; } Several fieldset groups are used inside td (table). In firefox 3.6.17, the layout comes properly. The fieldset automatically adds a line break for every tr-td combination, the layout shows fine. But in IE 8.0.6001, the fieldset does not add a line break for every td/tr. So I have to add an additional blank/empty tr/td to add a line break. Doing so adds 2 lines in FF. How to overcome this problem? What is the ideal css style to be used so that the display comes properly in both IE and FF? I know everyone who has tried designing emails for Outlook 2007 has had their share of headaches. But I encountered a bug recently where Outlook 2007 is not rendering my fieldset elements correctly. Based on Microsoft's own documents, Outlook 2007 should have full CSS support of the <fieldset> and <legend> elements. Here is my html and css: Code: <fieldset style="border:1px solid #99CCFF; padding-left:10px; padding-right:10px; padding-bottom:10px;"> <legend style="font-weight:bold; text-transform:uppercase;">Warranty Items</legend> ** Content here *** </fieldset> In every other email reader it looks as it should. But in Outlook 2007 there is no border and no padding. Each <legend> element appears as if it were an inline element. Has anyone had any luck with this sort of problem? Thanks! Hey guys, I'm new to the forums and would appreciate any help... I've never used fieldsets before, until now, and check out: http://www.koofers.com/contact.php A horizontal bar shows up in IE... and the globe in the top right of the screen goes off the monitor! And in FireFox, if I add bullet points to the content, the text actually goes outside of the fieldset. I know now the more I read that fieldsets are pretty much just for forms and such, but I really like the cool effect they give! And yes, I know... I shouldn't be using tables for my design, I should be doing crazy sweet things in CSS, but I'm still learning and don't have the time to totally re-design it in CSS (even if I could get it working!) Any help would be appreciated. Hello, Can I apply a top and bottom border to a fieldset but using an image to define a custom border line? How can I do this? Thank You, Miguel Hi I'm new to CSS and this site, so please excuse any stupidity in the code and presentation of this query! The following CSS (error.css): Code: body {background-color: white;} title {font-style: italic} thead {font-weight: bold; border-bottom: thick double} td {width: 5em; border-bottom: thin solid black; border-top: thin solid black; background-color: green} table {border: hidden} .Xaddress {border-left: thin solid black; font: 1em bold; color: yellow; text-align: left} .title {border-left: thin solid black; text-align: center; border-bottom: thick double; border-top: hidden} caption {font: 2em bold} #intro {position: static; color: black; height: 20%; backXground: #cccccc;} #addresses { position: relative; left: 5em; height: 60%; color: black; height: 10em;} #table1 {position: absolute; top: 4em; left: 1em; z-index: 10; color: black; background: #cccccc;} #table2 {position: absolute; top: 5em; left: 6em; z-index: 9; color: black; background: #ff00ff;} #footer {position: static; z-index: 10; color: black; height: 20%; backXground: #00ff00;} and xhtml (error.html): 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" lang="en" xml:lang="en"> <html> <head> <link rel="stylesheet" type="text/css" href="error.css" /> <script type="text/javascript"> //Bring a span element and descendents to the front and send its span siblings and their descendents to the back function bringToFront(id) { if (id != null) { if (document.getElementById(id)) { //Send all parent's descendents in spans to the back var span=document.getElementById(id).parentNode.getElementsByTagName("SPAN"); var s=0; var c=0; while (span[s]) { setzIndexOfBranch(span[s],9); s++; } //bring id and descendants to the front setzIndexOfBranch(document.getElementById(id),10); } } } //Set the zIndex of a node and all of its descendants function setzIndexOfBranch(node,value) { if (node.style != undefined) { node.style.zIndex = value; } var c=0; while (node.childNodes[c]) { setzIndexOfBranch(node.childNodes[c],value); c++; } } function parseXML() { text="<root>"; text=text+"<heading>XML CSS HTML test</heading>"; text=text+"<table1data>"+"<table>"+ "<caption>"+ "First table"+ "</caption>"+ "<thead>"+ "<td class="title">Column1</td>"+ "</thead>"+ "<tr>"+ "<td>row1</td>"+ "</tr>"+ "<tr>"+ "<td>row2</td>"+ "</tr>"+ "<tr>"+ "<td>row3</td>"+ "</tr>"+ "</table><br/>Some text after table 1<br/>"+ "</table1data>"+ "<table2data>"+"<table>"+ "<caption>"+ "Second table"+ "</caption>"+ "<thead>"+ "<td class="title">Column1</td>"+ "</thead>"+ "<tr>"+ "<td>row1</td>"+ "</tr>"+ "<tr>"+ "<td>row2</td>"+ "</tr>"+ "<tr>"+ "<td>row3</td>"+ "</tr>"+ "<tr>"+ "<td>row4</td>"+ "</tr>"+ "</table><br/>How can I make these 2 tables appear inside the addresses fieldset ?<br/>"+ "<br/>How can I make the addresses fieldset always fill @60% of the height ?<br/>"+ "<br/>Note the size of each table will vary but can assume to be less than 6 rows.<br/>"+ "</table2data>"; text=text+"</root>"; try //Internet Explorer { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.loadXML(text); } catch(e) { try // Firefox, Mozilla, Opera, etc. { parser=new DOMParser(); xmlDoc=parser.parseFromString(text,"text/xml"); } catch(e) { alert(e.message); return; } } document.getElementById("table1").innerHTML= xmlDoc.getElementsByTagName("table1data")[0].childNodes[0].nodeValue; document.getElementById("table2").innerHTML= xmlDoc.getElementsByTagName("table2data")[0].childNodes[0].nodeValue; document.title= xmlDoc.getElementsByTagName("heading")[0].childNodes[0].nodeValue; } </script> </head> <body onload="parseXML()"> <h1>Positioning test script</h1> <span> <fieldset id="intro"> <legend>header</legend> <span id="to"></span><br/> Header text </fieldset> <br/><br/> <fieldset id="addresses"> <legend>addresses</legend> <br>This is in the addresses fieldset</br> <span id="table1" onclick="bringToFront('table1')"></span> <span id="table2" onclick="bringToFront('table2')"></span> <br>This is in the addresses fieldset...................................................................................and I would hope for it to appear beneath the tables above. Table 2 may not exist.</br> </fieldset> <br/><br/> <fieldset id="footer"> <legend>footer</legend> This is all <br/><br/><br/><br/><br/><br/><br/><br/> footer text<br/> <br/>Down to here. </fieldset> </span> </body> </html> produces overflow in the middle fieldset. I would like the tables in this fieldset to be contained by the fieldset. It's prettier. That would also make the footer fieldset visible, so it's essential ! Can anybody help please ? Also the text which should appear below these tables. Any idea why it isn't positioned inline after the tables end ? Thanks. Hello. I'm nesting inputs within labels to enable me to position the inputs underneath their labels. (I use relative positioning for the labels and absolute positioning to move the inputs underneath and slightly to the right.) For one label I don't want any text to appear. I could use a non-breaking space but I'd ideally like to keep the label but just not show the text. But I can't hide it because it contains the input What would be a good way to approach this? (I've given the label a class to identify it/them.) Code: <form id="myForm" method=""> <label>Email<input type="text" id="txtEMail" /></label> <label>Password<input type="text" id="txtPWord" /></label> <label class=" lblHidden " >Login<input type="image" src="images/login.jpg" id="btnLogin" /></label> </form> [It occurred to me to set the width to 0 but I'm not so keen on this approach and it might interfere with my positioning.] Andy. PS I could post my css if it's useful (?). Edited: width:0px doesn't do anything anyway, because it contains an image. Greetings, I'm trying to create a fieldset that has rounded corners and a solid border. From what I gather IE displays rounded corners by default, Firefox does not. The code below makes Firefox display rounded corners, but when a border is applied rounded corners won't display on IE. Is there anything I can do to enable rounded borders? Thanks, fieldset { border:3px solid #000000; -moz-border-radius: 8px; border-radius: px; background: #C4FC02; margin: 0 0 1em 0; position: relative; } |