Styling List

យើង​បាន​ដឹង​រួច​មក​ហើយ​ថា នៅ​ក្នុង​ភាសា HTML មាន list ពីរ​ប្រភេទ​គឺ unordered lists (<ul>) និង ordered lists (<ol>) ។ ចំពោះ​list ទាំង​ពីរ​នេះ យើង​អាច​ប្រើប្រាស់​ភាសា CSS ក្នុង​ការកំណត់​សញ្ញា​ឬ​លេខ​នៅ​ពិ​មុខ​វា​ អោយ​ទៅ​ជា​សញ្ញា​ឬ​លេខ​ទាំងឡាយ​ណា​ដែល​ចង់​បាន​។ ពិនិត្យ​កម្មវិធី​ខាង​ក្រោម​នេះ​៖

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>CSS Styling List</title>
    <style>
      ul.a {
  		list-style-type: circle;
	  }

	  ul.b {
  		list-style-type: square;
	  }

	  ol.c {
  		list-style-type: upper-roman;
	  }

	  ol.d {
  		list-style-type: lower-alpha;
	  }
    </style>
  </head>
  
  <body>
	

Example of unordered lists:

  • Coffee
  • Tea
  • Coca Cola
  • Coffee
  • Tea
  • Coca Cola

Example of ordered lists:

  1. Coffee
  2. Tea
  3. Coca Cola
  1. Coffee
  2. Tea
  3. Coca Cola
</body> </html>

Example of unordered lists:

  • Coffee
  • Tea
  • Coca Cola
  • Coffee
  • Tea
  • Coca Cola

Example of ordered lists:

  1. Coffee
  2. Tea
  3. Coca Cola
  1. Coffee
  2. Tea
  3. Coca Cola

លើស​ពី​នេះ​ទៀត យើង​អាច​ប្រើប្រាស់​រូបភាព​ផ្សេង​ៗ​ជំនួស​អោយ​រូប​សញ្ញា​ឬ​លេខ​នៅ​ពី​មុខ​ list បាន ដោយ​ធ្វើ​ដូច​ខាង​ក្រោម​នេះ៖

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>CSS Styling List</title>
    <style>
      ul {
  		list-style-image: url('image.gif');
	  }
    </style>
  </head>
  
  <body>
	
  • Coffee
  • Tea
  • Coca Cola
</body> </html>
  • Coffee
  • Tea
  • Coca Cola

list-style-position ត្រូវ​ប្រើប្រាស់​សំរាប់​កំណត់​ទីតាំង​របស់​សញ្ញា​នៅ​ខាង​មុខ <ul> ។

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>CSS Styling List</title>
    <style>
      ul.a {
  		list-style-position: outside;
	  }

	  ul.b {
  		list-style-position: inside;
	  }
    </style>
  </head>
  
  <body>
	

The list-style-position Property

list-style-position: outside (default):

  • Coffee - A brewed drink prepared from roasted coffee beans, which are the seeds of berries from the Coffea plant
  • Tea - An aromatic beverage commonly prepared by pouring hot or boiling water over cured leaves of the Camellia sinensis, an evergreen shrub (bush) native to Asia
  • Coca Cola - A carbonated soft drink produced by The Coca-Cola Company. The drink's name refers to two of its original ingredients, which were kola nuts (a source of caffeine) and coca leaves

list-style-position: inside:

  • Coffee - A brewed drink prepared from roasted coffee beans, which are the seeds of berries from the Coffea plant
  • Tea - An aromatic beverage commonly prepared by pouring hot or boiling water over cured leaves of the Camellia sinensis, an evergreen shrub (bush) native to Asia
  • Coca Cola - A carbonated soft drink produced by The Coca-Cola Company. The drink's name refers to two of its original ingredients, which were kola nuts (a source of caffeine) and coca leaves
</body> </html>

The list-style-position Property

list-style-position: outside (default):

  • Coffee - A brewed drink prepared from roasted coffee beans, which are the seeds of berries from the Coffea plant
  • Tea - An aromatic beverage commonly prepared by pouring hot or boiling water over cured leaves of the Camellia sinensis, an evergreen shrub (bush) native to Asia
  • Coca Cola - A carbonated soft drink produced by The Coca-Cola Company. The drink's name refers to two of its original ingredients, which were kola nuts (a source of caffeine) and coca leaves

list-style-position: inside:

  • Coffee - A brewed drink prepared from roasted coffee beans, which are the seeds of berries from the Coffea plant
  • Tea - An aromatic beverage commonly prepared by pouring hot or boiling water over cured leaves of the Camellia sinensis, an evergreen shrub (bush) native to Asia
  • Coca Cola - A carbonated soft drink produced by The Coca-Cola Company. The drink's name refers to two of its original ingredients, which were kola nuts (a source of caffeine) and coca leaves

មួយវិញទៀត បើ​សិន​ជា​យើង​ចង់​យក​ចេញ​នូវ​សញ្ញា លេខ ឬ តួអក្សរ នៅ​ខាង​មុខ <ul> ឬ <ol> យើង​ត្រូវ​ធ្វើ​ដូច​ខាង​ក្រោម​នេះ៖

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>CSS Styling List</title>
    <style>
      ul.demo {
  		list-style-type: none;
  		margin: 0;
  		padding: 0;
	  }
    </style>
  </head>
  
  <body>
	

Default list:

  • Coffee
  • Tea
  • Coca Cola

Remove bullets, margin and padding:

  • Coffee
  • Tea
  • Coca Cola
</body> </html>

Default list:

  • Coffee
  • Tea
  • Coca Cola

Remove bullets, margin and padding:

  • Coffee
  • Tea
  • Coca Cola

list ក៏​ដូច​ជា element ដ៏ទៃ​ទៀត​ដែរ យើង​អាច​ប្រើប្រាស់​ពាក្យ​ថា list-style ដើម្បី​កំណត់​តំលៃ​ទាំងអស់​របស់​ list ដោយ​ធ្វើ​ដូច​ខាង​ក្រោ​នេះ៖

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>CSS Styling List</title>
    <style>
      ul {
  		list-style: square inside url("image.gif");
	  }
    </style>
  </head>
  
  <body>
	
  • Coffee
  • Tea
  • Coca Cola
</body> </html>
  • Coffee
  • Tea
  • Coca Cola