|
|
|
|
![]() ![]() |
Nov 15 2005, 10:30 PM
Post
#1
|
|
|
Member [ Level 1 ] Group: Members Posts: 32 Joined: 25-October 05 Member No.: 9,279 |
I have read (or glimse through) all the CSS 2 specification and google a lot but found no solution for the following problem. Anyone can help?
The basic idea is the input field for the type text, password is quite small, so I want to change its width by CSS CODE input { width : 400px; } However, this affects the width of the radio button too (in most current browser). Is there anyway that I can apply this CSS to input field which is of the type text or password ONLY? The tricky part is I MUST NOT use any additional attribute in input field, like class or id... |
|
|
|
Nov 15 2005, 11:22 PM
Post
#2
|
|
|
Advanced Member Group: Members Posts: 102 Joined: 21-August 05 Member No.: 8,003 |
I rarely work with forms, so I don't have any ideas besides using class/ids. Why exactly are you avoiding the use of class and id?
|
|
|
|
Nov 16 2005, 01:18 AM
Post
#3
|
|
|
Hedonist at large Group: Members Posts: 610 Joined: 30-July 05 From: another realm Member No.: 7,524 |
Well... without any class or id attribute, I don't think it's possible to do it. Besides, why don't you want to use them?
|
|
|
|
Nov 16 2005, 01:20 AM
Post
#4
|
|
|
Member [ Level 1 ] Group: Members Posts: 32 Joined: 25-October 05 Member No.: 9,279 |
Well, I always try to avoid as much class and id as I can since along the way when we writing code, once in a while I will forget to put these attribute in. Even though I will eventually figure out where in my code I missed, it's still better to have a "global" setting which will makes sure consistency for me.
|
|
|
|
Nov 16 2005, 02:42 AM
Post
#5
|
|
|
Techno-Necromancer Group: Members Posts: 1,018 Joined: 13-January 05 From: The Net Member No.: 2,127 |
There is one possible solution, although 1) i have never tested it, and 2) I don't know if it is valid CSS.
Try this: CODE input:text { width: 400px; } The alternative is to simply pecify width in the html tag without using css, or nest the input in a <style> tag. ~Viz |
|
|
|
Nov 16 2005, 05:12 AM
Post
#6
|
|
|
Member - Active Contributor Group: Members Posts: 78 Joined: 1-September 05 Member No.: 8,258 |
You can match <input> elements that have the type=text property in CSS2 by using the rule "input[type=text] { }". However, I highly doubt that this is fully supported by many browsers, and so your best choice would probably be to nest the input inside a span like viz said.
Notice from vizskywalker:
Edited on user's Request, next time, report the post instead of making another one though
|
|
|
|
Nov 16 2005, 08:51 AM
Post
#7
|
|
|
Super Member Group: Members Posts: 595 Joined: 4-September 04 Member No.: 228 |
QUOTE(Retaining @ Nov 16 2005, 07:12 AM) You can match <input> elements that have the type=text property in CSS2 by using the rule "input[type=text] { }". However, I highly doubt that this is fully supported by many browsers, and so your best choice would probably be to nest the input inside a span like viz said. This is the way to do it. It is good coding style to define the type attribute for all form fields, although "text" is assumed the default. This is in fact supported in many browsers, but not in Internet Explorer (surprise, surprise If you really need the option and can't come up with other solution, you might wish to try Dean Edwards IE7: http://dean.edwards.name/IE7/ It fixes most if IE CSS issues, with no need for users to install anything. |
|
|
|
Nov 16 2005, 08:53 AM
Post
#8
|
|
|
Super Member Group: Members Posts: 595 Joined: 4-September 04 Member No.: 228 |
Change: "It is good coding style to define the type attribute for all form fields" to "It is good coding style to define the type attribute for all form fields anyways"
You absolutely need to define the attribute in order the CSS2 attrribute matching to work. |
|
|
|
Nov 16 2005, 10:03 PM
Post
#9
|
|
|
Super Member Group: Members Posts: 572 Joined: 25-April 05 From: Nashville Tennessee Member No.: 4,340 |
QUOTE(vizskywalker @ Nov 15 2005, 08:42 PM) There is one possible solution, although 1) i have never tested it, and 2) I don't know if it is valid CSS. Try this: CODE input:text { width: 400px; } The alternative is to simply pecify width in the html tag without using css, or nest the input in a <style> tag. ~Viz Try this CODE <input type="text" style="width:400px" /> you can use a sty;e with most HTML elements such as the input, the above code will make a test box that is 400px wide and yes it is valid so embed the style into the tag you are concerned with when you told it input (width:400px then all input types took on that attribute, just use it in those input fields by whatever type you want to effect because you have text inputs, submit inputs, password input, checkbox inputs radio button inputs and so on, so you need to just put the style in those you want to make bigger.
|
|
|
|
Nov 17 2005, 02:56 PM
Post
#10
|
|
|
Member [ Level 1 ] Group: Members Posts: 32 Joined: 25-October 05 Member No.: 9,279 |
QUOTE(Houdini @ Nov 16 2005, 05:03 PM) Try this CODE <input type="text" style="width:400px" /> you can use a sty;e with most HTML elements such as the input, the above code will make a test box that is 400px wide and yes it is valid so embed the style into the tag you are concerned with when you told it input (width:400px then all input types took on that attribute, just use it in those input fields by whatever type you want to effect because you have text inputs, submit inputs, password input, checkbox inputs radio button inputs and so on, so you need to just put the style in those you want to make bigger.You didn't read my orginal post. I said that there must be no additional attribute put in HTML code. `style` here is an attribute, and yes, I can't use it. I searched the internet for the whole 3 days and read the CSS2 specification over and over again... and probably I have to admit that they don't support it (at least for now). |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 30th August 2008 - 04:07 AM |