Day 10: CSS - Background Images - 1

 p1{

background-color; blue;

opacity: 0.5;

}

p2{

background-color: rgb(40,40,40)

}

p3{

background-color: rgba(40[red],40[green],40[blue],0.5[opacity]);

}

--------------------------------------------------------------------------------------------------------

1. Height and width properties in CSS:

  • The height and width of an element are set using the height and width attributes.   
  • Height and width can be set using length (pixels, cm) or in percentage (%) format.

Example : 

Output :

Code :

2. RGB Value :

  • A color can be expressed in CSS as an RGB value (red, green, blue).   
  • Red, green, and blue parameters each control the color's intensity, which ranges from 0 to 255.     
  • For instance, the color green is displayed when the RGB values are set to 255 for green and 0 for the remaining colors.(red and blue)     
  • Set all color settings to 0 to display black, as shown here: rgb (0, 0, 0).     
  • Set all color settings to 255 to display white, as shown here: rgb (255, 255, 255).       
  • Example:
     

Code: 

Output :

3. RGBA Value

  • RGBA is an extension of the RGB color, with an additional alpha channel, which describes the opacity of a color.     
  • The syntax for RGBA color value is: rgba (red, green, blue, alpha), where alpha defines the opacity of the color.     
  • The value of the alpha parameter ranges from 0.0 (complete transparency) to 1.0. (not transparent at all).     
  • Example: 

Code:

Output :

4. HEX Value :

  • Using a hexadecimal value a color can be defined in CSS, using the following format,:#rrggbb       
  • Where the colors red, green, and blue are represented by hexadecimal numbers between 00 and ff (same as decimal 0-255).   
  • Red, for instance, is set to its greatest value (ff), while the others are set to their lowest value(00), so #ff0000 is displayed as red.     
  • Set all values to 00, as in #000000, to display black.       
  • Set all values to ff, as in #ffffff, to display white. 

Converting decimal number to hexadecimal steps :

Step 1: To begin, convert the decimal number to an integer by dividing it by 16.

Step 2: Set the rest aside.

Step 3: Repeat step 3 until the quotient value equals zero and divide the quotient by 16 once more.

Step 4: To get the hexadecimal numbers, take the values of the remaining remainders and sort them backwards.

Keep in mind that all integers from 0 to 9 will be treated equally when using the decimal system. However, from 10 to 15, they are written in alphabetical order, starting with A and going through F. (So in hexadecimal 10 = A, 11 = B, 12=C, 13=D, 14=E, 15=F).

To better comprehend the following instructions for converting decimal to hex, let's use an example.

Follow the instructions below to convert 255 to hexadecimal :

Step 1: Divide 255 by 16

255/16 = 15 , leaving 15 as the remainder.

Step 2:  Again divide 15/16

15/16= 0, leaving a remainder of 15. 

Step 3: By placing the equal hexadecimal value in place of the remaining items and sorting them in reverse order, we obtain,  15→f and 15→f

This means that 255 equals to ff in hexadecimal format.

Example:

Code :

Output:

 

Comments

Popular posts from this blog

else-if condition in if-else statements: Concatenation in JavaScript :

Day 9: CSS - Font Formate

Day 28: CSS Animation, CSS Transition Animation Box size