SlideShare a Scribd company logo
1 of 8
Tùy biến hiển thị danh sách
(List)
• Mặc định các thẻ list (danh sách) trong HTML sẽ được hiển thị
dựa trên quy tắt hiển thị ở các trình duyệt cho các thẻ đó. Ví dụ
khi bạn sử dụng <ol> thì sẽ hiển thị danh sách có đánh số, thẻ
<ul> sẽ hiển thị dấu chấm tròn cho mỗi mục con bên trong.
Nhưng với CSS, bạn có thể tùy biến lại được cách hiển thị của
nó, chẳng hạn như bạn muốn dùng hình ảnh thay cho dấu
chấm tròn ở thẻ <ul> chẳng hạn.
• Và để tùy biến danh sách trong CSS, chúng ta sẽ sử dụng
thuộc tính list-style để làm.
Quy tắt viết thuộc tính list-style
• Ở thuộc tính này, bạn có thể viết giá trị theo thứ tự như sau:
• list-style: <list-style-type> <list-style-position> <list-style-image>;
• Trong đó, 3 giá trị mình ghi bên trong kia là 3 thuộc tính con của list-
style nhưng bạn có thể viết vào thẻ này cùng lúc mà không cần viết
từng thuộc tính. Cụ thể:
• list-style-type: Thay đổi loại hiển thị của danh sách.
• list-style-position: Tùy chỉnh vị trí hiển thị các dấu đầu dòng của mục
con nằm bên trong danh sách hoặc bên ngoài danh sách.
• list-style-image: Sử dụng hình ảnh làm các dấu đầu dòng cho danh
sách.
Sử dụng thuộc tính này cho phần tử nào?
• Các thuộc tính mà mình đề cập trong bài này đều sẽ sử dụng để tùy
biến hiển thị cho các phần tử <li> trên website. Tuy nhiên bạn có thể
sử dụng cho bất kỳ phần tử nào khác nếu phần tử đó có thêm thuộc
tính display: list-item.
list-style-type
• Ở giá trị này bạn sẽ thiết lập kiểu hiển thị cho các dấu đầu dòng trên
mỗi thẻ <li>, bạn có thể thiết lập nó hiển thị thành số hay chữ cái
hoặc ký tự tùy thích. Nó có một số thuộc tính thông dụng như sau:
• disc: Kiểu nút tròn có nền bên trong,
• circle: Kiểu nút tròn nhưng có viền nhưng không có nền.
• squre: Kiểu ô vuông có nền.
• decimal: Kiểu số thứ tự.
• lower-roman: Kiểu số La Mã in thường.
• upper-roman: Kiểu số La Mã in hoa.
• none: Xóa các dấu đầu dòng.
list-style-position
• Với thuộc tính này chúng ta chỉ có duy nhất hai giá trị là:
• inside: Hiển thị dấu đầu dòng bên trong block.
• outside: Hiển thị dấu đầu dòng bên ngoài block.
list-style-image
• Nếu bạn chán với kiểu hiển thị các dấu đầu dòng là ký tự thì có
thể chuyển sang sử dụng hình ảnh (tốt nhất là một icon nhỏ)
với thuộc tính list-style-image này. Cách dùng rất đơn giản như
sau:
• list-style-image: url('link ảnh');
Ví dụ sử dụng list-style cho các phần tử khác
• Ở đầu bài mình có nói là các thuộc tính list-style này chỉ có thể
áp dụng cho các phần tử <li> vì mặc định các phần tử này sẽ
hiển thị theo kiểu list item (tức là mục danh sách). Nếu bạn
muốn sử dụng cho các phần tử khác thì bắt buộc phải cần
chuyển nó về kiểu hiển thị list item này. Bạn có thể chuyển kiểu
hiển thị của nó với thuộc tính display: list-item. Dưới đây là một
ví dụ về hiển thị danh sách với thẻ <p>.

More Related Content

Viewers also liked

Sử dụng cloud9 để học php
Sử dụng cloud9 để học phpSử dụng cloud9 để học php
Sử dụng cloud9 để học phpSon Nguyen
 
ứNg dụng xml
ứNg dụng xmlứNg dụng xml
ứNg dụng xmlSon Nguyen
 
Anypoint runtime manager v1
Anypoint runtime manager v1Anypoint runtime manager v1
Anypoint runtime manager v1Son Nguyen
 
Mule intelli j tips
Mule intelli j tipsMule intelli j tips
Mule intelli j tipsSon Nguyen
 
Anypoint mq queues and exchanges
Anypoint mq queues and exchangesAnypoint mq queues and exchanges
Anypoint mq queues and exchangesSon Nguyen
 
Increase revenue and reinvigorate your business with api
Increase revenue and reinvigorate your business with apiIncrease revenue and reinvigorate your business with api
Increase revenue and reinvigorate your business with apiSon Nguyen
 
Alerts and SLAs
Alerts and SLAsAlerts and SLAs
Alerts and SLAsSon Nguyen
 
Cloud hub and mule
Cloud hub and muleCloud hub and mule
Cloud hub and muleSon Nguyen
 
Let api change your relationship with your doctor
Let api change your relationship with your doctorLet api change your relationship with your doctor
Let api change your relationship with your doctorSon Nguyen
 

Viewers also liked (12)

Mule roles
Mule rolesMule roles
Mule roles
 
Sử dụng cloud9 để học php
Sử dụng cloud9 để học phpSử dụng cloud9 để học php
Sử dụng cloud9 để học php
 
Mule jms
Mule   jmsMule   jms
Mule jms
 
ứNg dụng xml
ứNg dụng xmlứNg dụng xml
ứNg dụng xml
 
Anypoint runtime manager v1
Anypoint runtime manager v1Anypoint runtime manager v1
Anypoint runtime manager v1
 
Mule intelli j tips
Mule intelli j tipsMule intelli j tips
Mule intelli j tips
 
Anypoint mq queues and exchanges
Anypoint mq queues and exchangesAnypoint mq queues and exchanges
Anypoint mq queues and exchanges
 
Mule users
Mule usersMule users
Mule users
 
Increase revenue and reinvigorate your business with api
Increase revenue and reinvigorate your business with apiIncrease revenue and reinvigorate your business with api
Increase revenue and reinvigorate your business with api
 
Alerts and SLAs
Alerts and SLAsAlerts and SLAs
Alerts and SLAs
 
Cloud hub and mule
Cloud hub and muleCloud hub and mule
Cloud hub and mule
 
Let api change your relationship with your doctor
Let api change your relationship with your doctorLet api change your relationship with your doctor
Let api change your relationship with your doctor
 

More from Son Nguyen

Wsdl connector introduction
Wsdl connector introductionWsdl connector introduction
Wsdl connector introductionSon Nguyen
 
Android intergrate with mule
Android intergrate with muleAndroid intergrate with mule
Android intergrate with muleSon Nguyen
 
Mule flow overview
Mule flow overviewMule flow overview
Mule flow overviewSon Nguyen
 
Mule flow and filter
Mule flow and filterMule flow and filter
Mule flow and filterSon Nguyen
 
Handle exceptions in mule
Handle exceptions in muleHandle exceptions in mule
Handle exceptions in muleSon Nguyen
 
Spring security integrate with mule
Spring security integrate with muleSpring security integrate with mule
Spring security integrate with muleSon Nguyen
 
Message processor in mule
Message processor in muleMessage processor in mule
Message processor in muleSon Nguyen
 
Expression language in mule
Expression language in muleExpression language in mule
Expression language in muleSon Nguyen
 
Mule with data weave
Mule with data weaveMule with data weave
Mule with data weaveSon Nguyen
 
Using spring scheduler mule
Using spring scheduler muleUsing spring scheduler mule
Using spring scheduler muleSon Nguyen
 
Composite source in bound and out-bound
Composite source in bound and out-boundComposite source in bound and out-bound
Composite source in bound and out-boundSon Nguyen
 
Batch job processing
Batch job processingBatch job processing
Batch job processingSon Nguyen
 
Using message enricher
Using message enricherUsing message enricher
Using message enricherSon Nguyen
 
Finance connectors with mule
Finance connectors with muleFinance connectors with mule
Finance connectors with muleSon Nguyen
 
Google drive connection
Google drive connectionGoogle drive connection
Google drive connectionSon Nguyen
 
Using properties in mule
Using properties in muleUsing properties in mule
Using properties in muleSon Nguyen
 
Mule integrate with microsoft
Mule integrate with microsoftMule integrate with microsoft
Mule integrate with microsoftSon Nguyen
 
Anypoint connectors
Anypoint connectorsAnypoint connectors
Anypoint connectorsSon Nguyen
 
Mule esb basic introduction
Mule esb basic introductionMule esb basic introduction
Mule esb basic introductionSon Nguyen
 

More from Son Nguyen (20)

Wsdl connector introduction
Wsdl connector introductionWsdl connector introduction
Wsdl connector introduction
 
Android intergrate with mule
Android intergrate with muleAndroid intergrate with mule
Android intergrate with mule
 
Mule flow overview
Mule flow overviewMule flow overview
Mule flow overview
 
Mule flow and filter
Mule flow and filterMule flow and filter
Mule flow and filter
 
Handle exceptions in mule
Handle exceptions in muleHandle exceptions in mule
Handle exceptions in mule
 
Spring security integrate with mule
Spring security integrate with muleSpring security integrate with mule
Spring security integrate with mule
 
Message processor in mule
Message processor in muleMessage processor in mule
Message processor in mule
 
Expression language in mule
Expression language in muleExpression language in mule
Expression language in mule
 
Mule with data weave
Mule with data weaveMule with data weave
Mule with data weave
 
Using spring scheduler mule
Using spring scheduler muleUsing spring scheduler mule
Using spring scheduler mule
 
Composite source in bound and out-bound
Composite source in bound and out-boundComposite source in bound and out-bound
Composite source in bound and out-bound
 
Batch job processing
Batch job processingBatch job processing
Batch job processing
 
Using message enricher
Using message enricherUsing message enricher
Using message enricher
 
Finance connectors with mule
Finance connectors with muleFinance connectors with mule
Finance connectors with mule
 
Google drive connection
Google drive connectionGoogle drive connection
Google drive connection
 
Using properties in mule
Using properties in muleUsing properties in mule
Using properties in mule
 
Mule integrate with microsoft
Mule integrate with microsoftMule integrate with microsoft
Mule integrate with microsoft
 
Jms queue
Jms queueJms queue
Jms queue
 
Anypoint connectors
Anypoint connectorsAnypoint connectors
Anypoint connectors
 
Mule esb basic introduction
Mule esb basic introductionMule esb basic introduction
Mule esb basic introduction
 

Tùy biến hiển thị danh sách

  • 1. Tùy biến hiển thị danh sách (List)
  • 2. • Mặc định các thẻ list (danh sách) trong HTML sẽ được hiển thị dựa trên quy tắt hiển thị ở các trình duyệt cho các thẻ đó. Ví dụ khi bạn sử dụng <ol> thì sẽ hiển thị danh sách có đánh số, thẻ <ul> sẽ hiển thị dấu chấm tròn cho mỗi mục con bên trong. Nhưng với CSS, bạn có thể tùy biến lại được cách hiển thị của nó, chẳng hạn như bạn muốn dùng hình ảnh thay cho dấu chấm tròn ở thẻ <ul> chẳng hạn. • Và để tùy biến danh sách trong CSS, chúng ta sẽ sử dụng thuộc tính list-style để làm.
  • 3. Quy tắt viết thuộc tính list-style • Ở thuộc tính này, bạn có thể viết giá trị theo thứ tự như sau: • list-style: <list-style-type> <list-style-position> <list-style-image>; • Trong đó, 3 giá trị mình ghi bên trong kia là 3 thuộc tính con của list- style nhưng bạn có thể viết vào thẻ này cùng lúc mà không cần viết từng thuộc tính. Cụ thể: • list-style-type: Thay đổi loại hiển thị của danh sách. • list-style-position: Tùy chỉnh vị trí hiển thị các dấu đầu dòng của mục con nằm bên trong danh sách hoặc bên ngoài danh sách. • list-style-image: Sử dụng hình ảnh làm các dấu đầu dòng cho danh sách.
  • 4. Sử dụng thuộc tính này cho phần tử nào? • Các thuộc tính mà mình đề cập trong bài này đều sẽ sử dụng để tùy biến hiển thị cho các phần tử <li> trên website. Tuy nhiên bạn có thể sử dụng cho bất kỳ phần tử nào khác nếu phần tử đó có thêm thuộc tính display: list-item.
  • 5. list-style-type • Ở giá trị này bạn sẽ thiết lập kiểu hiển thị cho các dấu đầu dòng trên mỗi thẻ <li>, bạn có thể thiết lập nó hiển thị thành số hay chữ cái hoặc ký tự tùy thích. Nó có một số thuộc tính thông dụng như sau: • disc: Kiểu nút tròn có nền bên trong, • circle: Kiểu nút tròn nhưng có viền nhưng không có nền. • squre: Kiểu ô vuông có nền. • decimal: Kiểu số thứ tự. • lower-roman: Kiểu số La Mã in thường. • upper-roman: Kiểu số La Mã in hoa. • none: Xóa các dấu đầu dòng.
  • 6. list-style-position • Với thuộc tính này chúng ta chỉ có duy nhất hai giá trị là: • inside: Hiển thị dấu đầu dòng bên trong block. • outside: Hiển thị dấu đầu dòng bên ngoài block.
  • 7. list-style-image • Nếu bạn chán với kiểu hiển thị các dấu đầu dòng là ký tự thì có thể chuyển sang sử dụng hình ảnh (tốt nhất là một icon nhỏ) với thuộc tính list-style-image này. Cách dùng rất đơn giản như sau: • list-style-image: url('link ảnh');
  • 8. Ví dụ sử dụng list-style cho các phần tử khác • Ở đầu bài mình có nói là các thuộc tính list-style này chỉ có thể áp dụng cho các phần tử <li> vì mặc định các phần tử này sẽ hiển thị theo kiểu list item (tức là mục danh sách). Nếu bạn muốn sử dụng cho các phần tử khác thì bắt buộc phải cần chuyển nó về kiểu hiển thị list item này. Bạn có thể chuyển kiểu hiển thị của nó với thuộc tính display: list-item. Dưới đây là một ví dụ về hiển thị danh sách với thẻ <p>.