Background Property

Background គឺ​ជា​ property មួយ​ត្រូវ​ប្រើប្រាស់​សំរាប់​រចនា​ផ្ទៃ element ទាំងមូល​អោយ​មាន​ពណ៌​ឬ​រូបភាព​ទៅ​តាម​អ្វី​ៗ​ដែល​យើង​ចង់​បាន​។ Background ត្រូវ​ចែក​ចេញ​ជា preperty ដោយ​ឡែក​ផ្សេង​ៗ​គ្នា​មួយ​ចំនួន​ទៀត​ មាន​ដូចជា background-color, background-image, background-repeat, background-attachment, background-position ជាដើម​។

background-color ត្រូវ​ប្រើប្រាស់​សំរាប់​រចនា​ពណ៌​នៃ​ផ្ទៃ​របស់ element ទាំងមូល​។

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>CSS Background</title>
    <style>
      body {
  		background-color: lightblue;
	  }
    </style>
  </head>
  
  <body>
	

Hello World!

This page has a light blue background color!

</body> </html>

Hello World!

This page has a light blue background color!


background-image ត្រូវ​ប្រើប្រាស់​សំរាប់​យក​រូបភាព​ផ្សេង​ៗ​មក​បិទ​នៅ​លើ​ផ្ទៃ​របស់ element ។ ហើយ​បើ​រូបភាពដែល​ត្រូវ​យក​មក​បិទ​នោះ មាន​ទំហំ​មិន​ពេញ​ផ្ទៃ​របស់​ element ទេ រូបភាព​នោះ​នឹង​ត្រូវ​ចំលង​ចេញ​ជា​ច្រើន​រូបភាព​ ដើម្បី​បិទ​នៅ​លើ​ផ្ទៃ element អោយ​បាន​ពេញ​ទាំងអស់​។

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>CSS Background</title>
    <style>
      body {
  		background-image: url("wood.jpg");
	  }
    </style>
  </head>
  
  <body>
	

Hello World!

This page has a light blue background color!

</body> </html>

Hello World!

This page has an image as the background!


background-repeat ត្រូវ​យក​ទៅ​ប្រើប្រាស់​ជាមួយ​នឹង background-image ដើម្បី​កំណត់​ពី​ការចំលង​រូបភាព​ដែល​ត្រូវ​ចំលង​យក​ទៅ​បិទ​នៅ​ផ្ទៃ element ។ តំលៃ​សំរាប់​ property នេះ​ អាច​ជា no-repeat, repeat-x, repeat-y ។

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>CSS Background</title>
    <style>
      body {
  		background-image: url("wood.jpg");
        background-repeat: repeat-x;
	  }
    </style>
  </head>
  
  <body>
	

Hello World!

Here, a background image is repeated only horizontally!

</body> </html>

Hello World!

Here, a background image is repeated only horizontally!


background-attachment ត្រូវ​ប្រើប្រាស់​ជាមួយ​នឹង​ background-image ដើម្បី​កំណត់​អោយ​រូបភាព​ដែល​ត្រូវ​យក​ទៅ​បិទ​លើ​ផ្ទៃ​របស់ element ត្រូវ​រំកិល​តាម​ផ្ទៃ element ជាប់​រហូត​ឬ​យ៉ាង​ណា​។ ហើយ​បើ​យើង​ផ្តល់​តំលៃ​អោយ property នេះ​ជា fixed បាន​ន័យ​ថា​ជា​ការកំណត់​អោយ​រូបភាព​រំកិល​តាម​ផ្ទៃ element ដល់​តែ​ត្រឹម​ផ្ទៃ​ខាង​លើ​គេបង្អស់​នៃ​ browser តែ​ប៉ុណ្ណោះ​។ តែ​បើ​យើង​ផ្តល់​តំលៃ​អោយ​ property នេះ​ជា scroll វិញ រូបភាព​នឹង​រំកិល​តាម​ផ្ទៃ​ browser រហូត​។

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>CSS Background</title>
    <style>
      body {
  		background-image: url("wood.jpg");
        background-repeat: repeat-x;
        background-attachment: fixed;
	  }
    </style>
  </head>
  
  <body>
	

The background-attachment Property

The background-attachment property specifies whether the background image should scroll or be fixed (will not scroll with the rest of the page).

Tip: If you do not see any scrollbars, try to resize the browser window.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

</body> </html>

The background-attachment Property

The background-attachment property specifies whether the background image should scroll or be fixed (will not scroll with the rest of the page).

Tip: If you do not see any scrollbars, try to resize the browser window.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.


យ៉ាងណាម៉ិញ បណ្តា property ខាង​លើ​នេះ អាច​ត្រូវ​បង្រួម​មក​អោយ​មក​នៅ​ត្រឹម​តែ background តែ​មួយ​បាន ដោយ​ធ្វើ​ដូច​ខាង​ក្រោម​នេះ៖

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  	<title>CSS Background</title>
    <style>
      body {
      	background: lightblue url("wood.jpg") repeat-x fixed;
	  }
    </style>
  </head>
  
  <body>
	

The background-attachment Property

The background-attachment property specifies whether the background image should scroll or be fixed (will not scroll with the rest of the page).

Tip: If you do not see any scrollbars, try to resize the browser window.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

</body> </html>

The background-attachment Property

The background-attachment property specifies whether the background image should scroll or be fixed (will not scroll with the rest of the page).

Tip: If you do not see any scrollbars, try to resize the browser window.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.

The background-image is fixed. Try to scroll down the page.