webForumDet fria alternativet

Enkelt sätt att stilsätta textfält?

HTML & CSS

5 svar · 565 visningar · startad av Danne V

Medlem sedan aug. 20068 090 inlägg
Frågan#1

Eftersom flera input-element i ett formulär påverkas i ett formulär om man bara stilsätter taggen "input" så använder jag klasser.

Men jag har alltid undrat (och letat efter svar men inte hittat) om man inte kan stilsätta själva taggen med hjälp av någon slags selektor?

Typ:

input:text field

Kan man det?

Medlem sedan mars 2006296 inlägg
#2

Japp! Attribute selectors http://www.w3.org/TR/css3-selectors/#attribute-selectors

input[type="text"] {}

Stöds av de flesta webbläsare men inte IE tidigare än version7...
http://www.quirksmode.org/css/contents.html

Medlem sedan jan. 2005953 inlägg
#3

Det finns

input[type=text]

Tyvärr stöder inte alla webbläsare det.

Edit: Lite för långsam... :(

Medlem sedan aug. 20068 090 inlägg
#4

Ah, sepåfasen! Tack.

Följdfråga: Kan man t.ex. fixa med

input[type=textarea]
input[type=radio]
input[type=list]

osv också då?

Medlem sedan juni 20019 519 inlägg
#5

Danne V skrev:

Ah, sepåfasen! Tack.

Följdfråga: Kan man t.ex. fixa med

input[type=textarea]
input[type=radio]
input[type=list]

osv också då?

ja Nate.A postade w3 dokumentation om det: http://www.w3.org/TR/css3-selectors/#attribute-selectors

Medlem sedan mars 2006296 inlägg
#6

Det med, men textarea har en egen tagg..
Du kan specificera vilket attribut som helst.
href, title, alt mm.. du kan t.o.m

[att^=val]
Represents an element with the att attribute whose value begins with the prefix "val". If "val" is the empty string then the selector does not represent anything.
[att$=val]
Represents an element with the att attribute whose value ends with the suffix "val". If "val" is the empty string then the selector does not represent anything.
[att*=val]
Represents an element with the att attribute whose value contains at least one instance of the substring "val". If "val" is the empty string then the selector does not represent anything.

från : http://www.w3.org/TR/css3-selectors/#attribute-selectors

249 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
125 ms — deklarationer (db)
0 ms — hämta statistik (cache)
121 ms — hämta tråd, inlägg och bilagor (db)
124 ms — ändringar (db)