Tải bản đầy đủ (.docx) (38 trang)

BIỂU MẪU STYLE VÀ CASCADING STYLE SHEET

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (495.84 KB, 38 trang )

CHƯƠNG VII. BIỂU MẪU STYLE VÀ CASCADING STYLE SHEET
VII.1. FORM
VII.1.1. FORM là gì?
a. Chức năng của FORM











































 !"



#$%&

'"



'(
)
*

*


&


'''

'

*+





' 

*

+

+



&







&

&



#$%+



'





 ,



&
)
'




&




'

*



'-

+

&

'

+

#$% 
.*



'

+

&


)

*

'

#$%+

$/

*0
.+








)
' 1

2

''

*







+



&

'"







)+

'


)
*

+












1



'





3

*



+



 control4'

'
2 5&


'&

'



#$%



'



'"





'
6'

2


)





"


)


&







'

/

*0
2 1



*

'"








'

&





+

*





&7

'"

1899$:;9

':$;<$;<=
$*'
5


2*

+

''

/&

'


)
#$%








9''>9''
b. Thành phần của FORM
1

'

+


'

.*

<FORM...>...</FORM>.
?

'





2
)
'"



&

+&+





'











'



&
1'

+

'

2*

7
<FORM METHOD=POST ACTION="URL">
Toàn bô ̣ các thành phần khác bên trong form năm ơ đây
</FORM>
5

'"



METHOD
"

'

'+


)
*


)
'@&

'




&

 1

A'

*


POST, GET





2'


'

*


POST

5

'"


ACTION
+

'

'*

+

"


BCD

'"


)




/

*0
)
*



'

2
VII.1.2.Các thành phần trong FORM
#+
)
'



*


'





'

'. %


+&
)
'"



&*

*

'
)
+





'

a. Hộp văn bản – TextBox
E



*

+


)




'
)
*



/"

'

E





)
+



'

7
=''2.F
5

+

'



*

7
<INPUT TYPE="TEXT" NAME="Tên" SIZE="n">
5+

5GH5*

'










*

5/'/Tên *

'








&

*



'

&"








'

 Tên

&

'
''+

'I
b. Hộp mật khẩu – Password
E



'

*

+


)





'

'



/"

'

E



'


+



'

7
5

+

'




*

7
<INPUT TYPE="PASSWORD" SIZE="n">
5+


PASSWORD
*

'



+

'





'

*




&"










 
E



'









)
)



"

'

'



"

'"





'

"

'

'

'

'&






J 
D&

7!



'

"

'



J+

'&'

"



'











"

'



&



;K)+













)


)




'



/'

 #




)
*



'




c. Vùng văn bản – Text Windows

!



+



'







 !







7
1'



'*


7
<TEXTAREA NAME= OTenVung" ROWS=m COLS=n> Van ban hien
thi</TEXTAREA>
'+

Tên vu
̀
ng*

'







*





&"

















 #



+

'



L+




)




'

L'"


)






/

'

'




!"



7
<TEXTAREA NAME="COMMENTS" ROWS=5 COLS=50> Bạn cần phải
thường xuyên cập nhật các mẫu virus mới nhất</TEXTAREA>
d. Các lựa chọn – Radio Button
1




'

*



'



''

"





+





'
'




' #

'



7
1'



'7
<INPUT TYPE="RADIO" NAME="Tên_nhóm_nút"
VALUE="giá_trị_được_chọn"> Nhãn nút
5+


RADIO
*

'












'

Cnha
̃
n nu
́
t i*

/"

'


)
/

'





'
!"




7



)
+

'



'+

'M?'M*

7
<INPUT TYPE="RADIO" NAME="PAYMENT"
VALUE="Mastercard">Master Card
5"



''

'"


NAME
+




'


PAYMENT
*

'



'
C

N

'

*





''N

''


'

'"


VALUE
+





'-

'

*





*



L?'L D&




'
)

?'*



'



*





?'*


)


''




)








' 5

'

'&
)


'



'/

'"

"



L5

'"





?'1L
%"
)




'

'*

'





'


)
E5?D'
D&



'


'"

#:?G

'







'






'

 5"



''"

'


'





'+








NAME =[PAYMENT].
5

'



'

'

'

'




'

'"

CHECKED"
)
*



+

+





)

'
e. Ô đánh dấu – CheckBoxes
O+



+


+





'



*



 O








7
1'



'7
<INPUT TYPE="checkbox" NAME="Tên nhóm nút" VALUE="giá

trị được chọn"> Nhan o i
!"



7
6





'



'

+







+

'


'




'

+




!"



'

+

'

/+

'

'*

7
<INPUT TYPE="CHECKBOX" NAME="DELIVERY"

VALUE="Overnight">Overnight ý nghĩa của các thuộc tính
cũng tương tự như của nút radio.
5

'

+





'



'



'

'"


CHECKED


+



+





)

'
f. Danh sách lựa chọn – thành phần SELECT
1'

+

'

*

7
<SELECT NAME="MENU" SIZE="5">
<OPTION>Menu item 1
<OPTION>Menu item 2
<OPTION SELECTED>Menu item 3
<OPTION>Menu item 4
<OPTION>Menu item 5
<OPTION>Menu item 6
<OPTION>Menu item 7
<OPTION>Menu item 8
</SELECT>

'+

'

'"


SIZE
/

+









'

"

'

&'







OPTION SELECTED
/

+

*





+

+

 
1

'

'

/






P'+Q''R'S
SIZE=1
7


'









&"





'

'"


SIZE
'+



)
' 
?

+





SELECT"







'



 5


'"

MULTIPLE




+










g. Hộp chọn tệp
1



'





'






''

'

'

 !"





6



'



'=K'"



'

1.*
)










'


1



'7
<INPUT TYPE="FILE"́NAME="fileName">
6

''



'

'/'&

'

3




'=K4'"

''



)
+



'

'"


VALUE


'





&
h. Nút Send và Clear
6






+
)
+

/'"









'-

+

/







+

*

'

+

7
$M



'-

+ 
1*M/





*

*

'

+


 
E

'+

*





&



7
?
)
+

'



'

&*

7
<INPUT TYPE="SUBMIT" VALUE="Send form">

<INPUT TYPE="RESET" VALUE="Clear form">
'+

/"

'

'



$21*2

'

'"


VALUE

)


'

'

''

 %"

)
'

'&

/



'&

&






T

+UT+

*

U
i. Nút nhấn – Push Button
#




'

L$'L

LC'L*



2






-&+

'

'

'

'



'

+







)


+

/

*"




''

'

'

?
)


+


'



'

'

-

'



&*


<Button type="button" name="Tên nút"> Nhãn nút
</BUTTON>
Tên nu
́
t+

'



nha
̃
n nu

́
t*


)

)


'

'

' #




''"



'

'

&"




'

'"



'&'



nha
̃
n nu
́
t


"




<BUTTON type="button" name="Tên nút"><IMG SRC="Tệp
ảnh" ALT="Dòng chữ thay thế"></BUTTON>
D&

7







)
'&'

'



IMG 6+






'image map

'



IMG

'

''



BUTTON











/

*"





'

'

'



'


'"





 

  

  '

  

  

'   onclick, ondblclick, onmousedown,
onmouseup, onmouseover, onmousemove, onmouseout
...
 ;


'"



&

$'
)


)


+



&
j. Nút nhấn bằng hình ảnh
1

'

'



'

'

'





'"





<INPUT type="image" NAME = "Tên nút" SRC="Tên ảnh">
6



'2+



+





'

+

/&'"



/*


'




'M'



"



 1



*



&+



+



 
name.x=x-value name.y=y-value



+&*

V'



'

'"





'Wx-value, y-value*



'

+


#



/


*"





'

'

+



+





'

'"




)'

"




'"











7



''


image map

'
k. Các trường ẩn
1

'






'

'2+



+



''
$
!"



7
<INPUT TYPE="HIDDEN" NAME="previous-url" VALUE="URL">



)
'+

'




'*

'''

#$%



'+

'




'''

+

"

BCD

'+



+








"


=:16
?

'"




)
*

+

+

'

+




$X''*

'





'
'



7
<INPUT TYPE="HIDDEN" NAME="subject" VALUE="membership
form">



)


&+

/"

'

+

)


'

'"


VALUE






+

M
X''*
l. Nhãn
5

**
1



'+
)




)


+





'

'"

value
1

'





*

 text fields, checkboxes, radio buttons, menus




)


+

 1

'



'



'/"

'



'"



+

*



L
)
L')*



'
5&+

'

E5?D

'




LABEL
+




)


'





+






1

'

YD:=GDZ Y>D:=GDZ  dùng  +

+

"
)
'




LABEL.
5

'"

.[C


'

**
<LABEL for="Id">
5

'"



&




)
'



+



'



9 9*


'
+



'



+




#



'

'"

2'"



+

*




'



+






'

'


LABEL
+/

' 
1

'






'
LABEL




''



+




!"



7
<FORM action="..." method="post">
<TABLE>
<TR>
<TD><LABEL for="fname">First Name</LABEL>
<TD><INPUT type="text" name="firstname" id="fname">
<TR>
<TD><LABEL for="lname">Last Name</LABEL>
<TD><INPUT type="text" name="lastname" id="lname">
</TABLE>

</FORM>
8


)


'

'"

.[C





)


''



+








'

'"


FOR

'



+







''




LABEL
D




&

''





LABEL
"





''



+



 1


)
*



)


'

+

''


&'



+



 
!"



7


)
A'




'/'2* 
<FORM action="..." method="post">
<P>
<LABEL>
First Name
<INPUT type="text" name="firstname">
</LABEL>
<LABEL>
<INPUT type="text" name="lastname">
Last Name
</LABEL>
</P>
</FORM>
VII.1.3. Thêm tính cấu trúc cho FORM
a. FIELDSET và LEGEND
5



 FIELDSET





'

'




+





*-

 #$%)





'

'

'
)
)/

*"


&


2
5



LEGEND





'







'FIELDSET
1

'

'"


align = top|bottom|left|right
• top:*+


'

"

'

2*' &*



'



+

 
• bottom:*+

'

"





2*' 
• left:*+


'

"

'

 
• right:*+

'

"





2*' 
!

<FORM action="..." method="post">
<P>
<FIELDSET>
<LEGEND>Personal Information</LEGEND>
Last Name: <INPUT name="personal_lastname"
type="text">
First Name: <INPUT name="personalỴfirstname"
type="text">
Address: <INPUT name="personalỴaddress"
type="text">

</FIELDSET>
<FIELDSET>
<LEGEND>Medical History</LEGEND>
<INPUT name="history_illness" type="checkbox"
value="Smallpox"> Smallpox
<INPUT name="history_illness" type="checkbox"
value="Mumps"> Mumps
<INPUT name="history_illness" type="checkbox"
value="Dizziness"> Dizziness
<INPUT name="history_illness" type="checkbox"
value="Sneezing"> Sneezing
</FIELDSET>
<FIELDSET>
<LEGEND>Current Medication</LEGEND>
Are you currently taking any medication?
<INPUT name="medication_now" type="radio"
value="Yes">Yes
<INPUT name="medication_now" type="radio"
value="No">No
<BR> If you are currently taking medication, please
indicate it in the space below:
<TEXTAREA name="current_medication" rows="5"
cols="50">
</TEXTAREA>
</FIELDSET>
</FORM>
5@&

'
)



'

7
Hình VII.1. Kết quả ví dụ
VII.2. Cascading style sheet
$'&*$'*\R'+Q'S-']\^'_+`I'E5?D
+R3%&E5?D4 ?QI''a'bcd^R''&*
'eI^^f*`S 5c\&'g*\-f
e'&*'I+_e'P'P'\V''_'
VII.2.1. Inline Style
?R'+Q'S-']h%&E5?D*\V'&*+R 5^'_
'&+i'&*hfc'jE5?D''^+`_'k'
' $b'&+i^'_'_elV+V*m''VhnIQ
be'&+i'm'V3be'&+iS'o4
1^V'&+i'&*h'7
5&+i'&*'
!P'V'+_'&+i'&*
$jpV*'&*'^'_P'V'&*+R\dP'
''\'
?R'T*'&*U*\R''&*\+`V\R'c'j+Qe' $'&*
q'`'r'dVc'jhR'_QR'*o\+^ ?R'*
'&*+`+ksI'R'S
STYLE
'hVc'j !SpP'
tV\h
<H1>
3EF4'\\+u'^'_V'R'S
STYLE

h'v
H1

<H1 STYLE=”color:red”>
#P'tI'+_jR'*'&*r'w*x\+^'
dI+t'`'&*3$'&*[X'4 $'&*[X'q'`]'R'S\
1$$q'`V'&* _I'R'S'7
Dmumt'y''R'S'&*1$$
5&+iz+c'h'ymt'\zP'
!Sp'R'S1$$2'MK''\2'''%E5?D EQ
'/'M*'\'/':*
5{&/R'Sp+_/^]'| 5gI*'&*+_VV
'R'Sh't
<P>
H+mo+&'9''G/*7
<HTML>
<HEAD>
<TITLE>Setting Properties</TITLE>
</HEAD>
<BODY>
<P style = “color:aqua; font-Style:italic; text-
Align:center;”> This paragraph has an inline style
applied to it
<BR>
<P> This paragraph is displayed in the default style.
<BR>
<P>Can you see the <SPAN style =
color:red>difference</SPAN>in this line
</BODY>
<HTML>

Hình VII.2. Sử dung Inline Style
VII.2.2. Giới thiệu Style Sheet
$'&*'*\\'-d*0\+f_V'&* $'&*''d
em\e_}hR''\*eE5?D^g+`+'\
@Q\ 5'b'P'^'_sf^R'~+_
|\V'\*eE5?Dh' Qe''•^'_+k€k'S\b
/r'ehVc'j'R''\'mVe|+Qe' !Sp'^
'_'mR''&*'+ks'v
<H1>
*\z•\\\/
EQ'vc'j
<P>
+`+o\+uo2':*
5^'_+ks'''&*\'t'R'k'S‚'&*'
6+^'&*'^'_+`*P'+_'r'dV''R''+_'m
R'em'S`+ƒr'-'' 5^'_+ksf
'&*'\*P'x'\R''ahV'+_f
vf''mV'
?R''^'_^'&*'P^'&*'+`
/V+k+^'@&e'gjpV_'k'-&oc+kh
^ !SpR''v
<H1>
*+`_'kIR'+kmV+m\V*f
•a& %IeI'&*''^'_/V+kV\'v
<H1>
+`_'k''@&e'
!fQ'*0'&P''^'_Ir'we'&*'\oE5?D
%I'b'P'@„e1$'&*$'31$$4+`V'@&e'
q'`'t' 1$$*\R'…+`V''_(*1'
3'n]*\TN1U4I'V'@&e'

VII.2.3. Javascript Style Sheet
#'q'`V'&*' #^•`'`'&*'\+`
P''t<$'\I@+t'`'\*e‚%'[X'
?*3%[?4 6+ksR''&*''^'_V_7
T'/'>1$$UMM5'n`\&^'@xV1$$
T'/'><$'U‚5'n`\&^'@xV<$''&*'
6IxV<$''c'j
<STYLE>
'd/V+k'R
'SV'vh+t'`'\*e
5@+t'`'\*eVc'jE5?D+`+t/jV
+t'` ?R'+t'`^V'R'S\^'_+`'&a+_+ks
em\'&*hc'j ?R''R'S'df^'_m'+RR'+t
'`oR''aV'R'S !SpR''+`+t/jR'+t
'`'\*e t'`'\*e^R''R'SV'v 5R'SV'v^
R'+t'`EA t'`EA^R''R'S]*\*\^'_+`'&
a\'&+i+`&c
Document.tags.H2.color = “limegreen”
!Sp7
<HTML>
<HEAD>
<STYLE TYLE = “text/javascript”>
tags.P.fontSize = “25pt”;
tags.P.marginLeft = “15pt”;
tags.H2.color = “hotpink”;
</STYLE>
</HEAD>
<BODY>
<H2>This is an H2 element with a style applied</H2>
<BR>

<P>This is a paragraph element
</BODY>
</HTML>
5r'dVc'jV+f'yP'yc'j
<BODY>
#P't
rR''&*Q+k'r'dVc'j'R''\*e'^'_+Q''&*
&c'c'j
<BODY>
m{m&''@&e''7
!Sp7
<HTML>
<HEAD>
<STYLE TYPE = “text/javascript”>
tags.body.color=”red”;
</STYLE>
</HEAD>
<BODY>
<H2>This is an H2 element</H2>
<BR>
<P>This is a paragraph element
</BODY>
</HTML>
Hình VII.3. Hỗ trợ một style bình thường
!Sp7
<HTML>
<HEAD>
<STYLE TYPE = “text/css”>
BODY {color:limegreen}
</STYLE>

</HEAD>
<BODY>

×