কম্পিউটার টিউটোরিয়াল

HTML DOM Style backgroundColor প্রপার্টি


backgroundColor প্রপার্টি ব্যবহার করে একটি এলিমেন্টের জন্য ব্যাকগ্রাউন্ড রঙ সেট বা রিটার্ন করা হয়। আমরা মান নির্দিষ্ট করতে পারি স্ট্যান্ডার্ড নাম, rgb(), rgba(), hsl() বা hsla() ব্যবহার করে।

সিনট্যাক্স

backgroundColor প্রপার্টি সেট করার সিনট্যাক্স:

object.style.backgroundColor = "color|transparent"

মানসমূহ

ক্রমমান ও বিবরণ
১Color
ব্যাকগ্রাউন্ড রঙ নির্দিষ্ট করতে ব্যবহৃত হয়।
২Transparent
ব্যাকগ্রাউন্ড রঙ ট্রান্সপারেন্ট করে অর্থাৎ নিচের কন্টেন্ট দেখা যায়। এটি ডিফল্ট মান।

উদাহরণ

backgroundColor প্রপার্টির উদাহরণ:

<!DOCTYPE html> <html> <head> <style> 
  #DIV1{ 
    background-color: rgba(10,122,102,0.1); 
  } 
</style> 
<script> 
  function changeBackColor(){ 
    document.getElementById("DIV1").style.backgroundColor="rgba(1,200,55,0.5)"; 
    document.getElementById("Sample").innerHTML="The background color is now changed"; 
  } 
</script> 
</head> 
<body> 
<div id="DIV1">Duis tincidunt urna a interdum consectetur. Pellentesque nec pretium ante. In nisl magna, vestibulum non vulputate vel, feugiat ac tellus. Sed tincidunt id leo at mollis. Praesent pellentesque purus vitae scelerisque gravida. Pellentesque pulvinar scelerisque sem, at euismod sapien tristique et.</div> 
<p>Change the above div background color by clicking the below button</p> 
<button onclick="changeBackColor()">CHANGE COLOR</button> 
<p id="Sample"></p> 
</body> </html>

আউটপুট

নিচের আউটপুট তৈরি হবে:

HTML DOM Style backgroundColor প্রপার্টি

CHANGE CLIP বাটনে ক্লিক করলে:

HTML DOM Style backgroundColor প্রপার্টি

  1. HTML DOM Style borderLeftColor প্রপার্টি

  2. HTML DOM Style borderTopColor প্রপার্টি

  3. HTML DOM Style borderRightColor প্রপার্টি

  4. HTML DOM Style color প্রপার্টি