Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > CSS and form width problems

Reply
Thread Tools

CSS and form width problems

 
 
William Krick
Guest
Posts: n/a
 
      04-05-2006
When I use the <form> tag and give it a background color, by default,
the form's width is 100%.

I would like it to behave like a table and have it constrict to fit the
content inside of it.

Is this possible with CSS?

Or do I have to resort to something ugly like putting a table around
the form?

 
Reply With Quote
 
 
 
 
Jim Moe
Guest
Posts: n/a
 
      04-06-2006
William Krick wrote:
> When I use the <form> tag and give it a background color, by default,
> the form's width is 100%.
>
> I would like it to behave like a table and have it constrict to fit the
> content inside of it.
>

form { display: table; }
But that is not supported by IE.
Another way is to float the element: form { float: left; }. In the
absence of an explicit width rule, it shrinks to fit its contents. But
then you have to deal with a floating element.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
 
Reply With Quote
 
 
 
 
BootNic
Guest
Posts: n/a
 
      04-06-2006
> "William Krick" <(E-Mail Removed)> wrote:
> news:(E-Mail Removed) ups.com....
>
> When I use the <form> tag and give it a background color, by
> default, the form's width is 100%.
>
> I would like it to behave like a table and have it constrict to fit
> the content inside of it.
>
> Is this possible with CSS?
>
> Or do I have to resort to something ugly like putting a table around
> the form?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content=
"text/html; charset=windows-1252">
<style type="text/css">
form{
display:table;
color:#0000FF;
background-color:#E6E6FA;
border:#800080 0.1em solid;
}
input{
display:block;
margin:0.3em;
}
</style>
<!--[if IE]>
<style type="text/css">
form{
width:1px;
overflow:visible;
}
</style>
<![endif]-->
<title></title>
</head>
<body>
<form action="#">
<div>
<input><input type="submit">
</div>
</form>
</body>
</html>

--
BootNic Wednesday, April 05, 2006 9:32 PM

Genius is eternal patience.
*Michelangelo*

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS question: Using height/width at 100% with fixed-width borders/margin/padding cera HTML 1 08-18-2007 02:59 AM
Textbox width scaling to width of data not width of page? AndrewF ASP .Net 1 10-10-2005 04:38 PM
css - setting width based on browser width ppcguy HTML 3 08-26-2005 06:51 AM
CSS min-width, max-width, and min-height with display:inline Lois HTML 1 12-27-2004 03:03 AM
Table width and columns width kris HTML 11 11-18-2003 06:49 AM



Advertisments