CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 8th, 2003, 06:23 PM
STEELV STEELV is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 192 STEELV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 1 m 29 sec
Reputation Power: 0
Send a message via Yahoo to STEELV
CSS: Form Elements

I want to modify form elements. For example, I would like to change the background color/border style/border color of my input boxes, as well as my submit buttons. I would also like to change the spacing that is automatically placed under a FORM element, as it messes up my layout. Thanks in advance!

Reply With Quote
  #2  
Old September 8th, 2003, 07:00 PM
jerom jerom is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Posts: 1,014 jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 17 h 34 m 25 sec
Reputation Power: 9
The safe option is to define a CSS class and add this class to your elements.
Code:
.myinputs {
	background-color: red;
	border: 1px solid blue;
}
<input type="text" name="mytext" class="myinputs">


The more modern browsers also support CSS attribute selectors (IE5.5 does not support it):
Code:
input[type="text"], input[type="submit"] {
	background-color: red;
	border: 1px solid blue;
}


Check here for all CSS properties: http://www.w3.org/TR/CSS2/propidx.html

Hope this helps,
Jeroen

Reply With Quote
  #3  
Old November 7th, 2003, 09:42 AM
sturgel sturgel is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 2 sturgel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Jerom, this does not work for SELECT tags though. I can't get the background color to change for a select tag using a CSS class. Here is the code using ASP to populate the drop-down list.:

<STYLE TYPE="text/css">
.viewmode {background-color:transparent; border:1px solid #BE9D9D}
.editmode {none}
</STYLE>

<select size="1" id="BSite" name="BSite" class="viewmode" style="width: 396; height:396">
<%Response.Write("<option selected value=""Null""></option>")
Do While Not SiteRs.EOF
if SiteRs.fields("SiteID") = fSiteID then
Response.Write("<option selected value=" & SiteRs("SiteID") & """>" & _
SiteRs("SiteNumber") & " - " & SiteRs("SiteDescription") & "</option>")
else
Response.Write("<option value=" & SiteRs("SiteID") & """>" & _
SiteRs("SiteNumber") & " - " & SiteRs("SiteDescription") & "</option>")
end if
SiteRs.movenext
Loop
Set SiteRs=Nothing
%>
</select>

The ASP code above works though I have modified it here. The point is the class="viewmode" doesn't work for the SELECT tags but does work for the INPUT tags.

Any idea why?

Quote:
Originally posted by jerom
The safe option is to define a CSS class and add this class to your elements.
Code:
.myinputs {
	background-color: red;
	border: 1px solid blue;
}
<input type="text" name="mytext" class="myinputs">


The more modern browsers also support CSS attribute selectors (IE5.5 does not support it):
Code:
input[type="text"], input[type="submit"] {
	background-color: red;
	border: 1px solid blue;
}


Check here for all CSS properties: URL

Hope this helps,
Jeroen

Reply With Quote
  #4  
Old November 7th, 2003, 11:34 AM
jerom jerom is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Posts: 1,014 jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 17 h 34 m 25 sec
Reputation Power: 9
IE has problems with 'transparent' at times...
The background works fine in my Mozilla and Opera7 browsers.
If you specifically give it a color, IE will display it (unless there's a background-color for the option elements defined. If you define a background color for an option, IE 5.5 applies it to the selectbox as well.).

Opera is the only one that really gets the border of a select box right (try a border of 100px).
Mozilla seems to be the only one that lets you correctly define a border for a selectbox option. Opera simply ignores it.

Jeroen

Reply With Quote
  #5  
Old November 7th, 2003, 11:50 AM
sturgel sturgel is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 2 sturgel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Specifying a color works perfectly. Your right, transparency is a problem with SELECT boxes. Thanks Jeroen for your quick reply!

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > CSS: Form Elements


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway