CSS for <select> & <input type=text>

liunx

Guest
hi,<br />
<br />
I have this for taxt area:<br />
<br />
TEXTAREA<br />
{background-color: #F7F7F7;<br />
border: #7F9DB9 1px solid;<br />
color: black;<br />
font-family: Verdana, Tahoma, Arial;<br />
font-size: 8pt;<br />
font-weight: normal} <br />
<br />
How can I apply it to input type text and select form items?<!--content-->My CSS<br />
<br />
<br />
.formfield {<br />
border: 1px dotted #000;<br />
color: #000;<br />
background-color: #ccf;<br />
width: 100px;<br />
font-family: 'Trebuchet MT', 'lucida sans unicode', helvetica, verdana, arial, sans-serif;<br />
font-size: 8pt;<br />
<br />
}<br />
<br />
.formbutton {<br />
border: 1px solid #000;<br />
color: #000;<br />
background-color: #69c;<br />
font-family: 'Trebuchet MT', 'lucida sans unicode', helvetica, verdana, arial, sans-serif;<br />
font-size: 8pt;<br />
}<br />
<br />
<br />
Input field<br />
<br />
<input type="text" name="name" size="20" class="formfield" onFocus="this.style.background='#eee'" onBlur="this.style.background='#ccf'"><br />
<br />
<br />
Textarea<br />
<br />
<textarea type="text" name="name" rows="5" cols="30" class="formfield" onFocus="this.style.background='#eee'" onBlur="this.style.background='#ccf'"></textarea><br />
<br />
<br />
Select<br />
<br />
<select name="name" class="formfield" onFocus="this.style.background='#eee'" onBlur="this.style.background='#ccf'"><br />
<br />
<br />
Button<br />
<br />
<input type="submit" value="Go" name="submit" class="formbutton" onMouseOver="this.style.background='#ccf'" onMouseOut="this.style.background='#69c'"><br />
<br />
<br />
HTH<!--content-->Thats a great effect thank you. I'm building a commercial e-commerce application. Should I worry about compatibility with Netscape 4 as CSS is impossible with it!<!--content-->NS4's marketshare is continually dwindling.<br />
<br />
Unless a significant amount of your visitors use NS4, I wouldn't worry about it.<!--content--><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br />
<br />
<html><br />
<head><br />
<title>Untitled</title><br />
<style><br />
TEXTAREA, input, select<br />
{background-color: #F7F7F7;<br />
border: #7F9DB9 1px solid;<br />
color: black;<br />
font-family: Verdana, Tahoma, Arial;<br />
font-size: 8pt;<br />
font-weight: normal} <br />
</style><br />
</head><br />
<br />
<body><br />
<form><br />
<input><br><br><br />
<textarea></textarea><br><br><br />
<select><br />
<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option><br />
</select><br />
</form><br />
</body><br />
</html><br />
<br />
<br />
<br />
<br />
(this would apply to all textareas, inputs, and selects. For specific cases, use classes.)<!--content--><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><br />
<br />
<html><br />
<head><br />
<title>Untitled</title><br />
<style><br />
.red<br />
{background-color: red;<br />
border: #7F9DB9 1px solid;<br />
color: black;<br />
font-family: Verdana, Tahoma, Arial;<br />
font-size: 8pt;<br />
font-weight: normal} <br />
<br />
.blue<br />
{background-color: blue;<br />
border: #7F9DB9 1px solid;<br />
color: black;<br />
font-family: Verdana, Tahoma, Arial;<br />
font-size: 8pt;<br />
font-weight: normal}<br />
<br />
.yellow<br />
{background-color: yellow;<br />
border: #7F9DB9 1px solid;<br />
color: black;<br />
font-family: Verdana, Tahoma, Arial;<br />
font-size: 8pt;<br />
font-weight: normal}<br />
</style><br />
</head><br />
<br />
<body><br />
<form><br />
<input class="red"><br><br><br />
<textarea class="blue"></textarea><br><br><br />
<select class="yellow"><br />
<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option><br />
</select><br />
</form><br />
</body><br />
</html><br />
<br />
<br />
<br />
<br />
and here is an example using classes.<!--content-->I'm back again :)<br />
<br />
How can I make:<br />
<br />
<input type="text" name="name" size="20" class="formfield" onFocus="this.style.background='#eee'" onBlur="this.style.background='#ccf'"><br />
<br />
<br />
Work by pulling info from the style sheet.<br />
<br />
e.g. <input type="text" name="name" size="20" class="formfield" onFocus="class.onFocus" onBlur="class.onBlur"><!--content-->class.onFocus<br />
<br />
that is invalid. what is it you are trying to do?<!--content-->Scoutt...Brooky wants to get this effect:<br />
Originally posted by brooky <br />
<input type="text" name="name" size="20" class="formfield" onFocus="this.style.background='#eee'" onBlur="this.style.background='#ccf'"><br />
<br />
(the background color change) Using info from the CSS file. Try this:<br />
<input type="text" name="name" size="20" class="formfield" onFocus="this.className='onFocusClassName'" onBlur="this.className='onBlurClassName'"><br />
I don't really recommend using "onFocusClassName" and "onBlurClassName" but just replace those with the approprite classes from your CSS. (You'll have to make 2 classes...like formfieldF and formfieldB and that code will swap them.)<!--content-->Works a treat thanks :)<!--content-->
 
Back
Top