HTML+CSS Notes CSS Intermediate color & length values

Source: Internet
Author: User
Tags border color

Color values

The color settings in a Web page are very important, with font color (color), background color (background-color), border color (border), and so on, there are many ways to set colors:

1, English command color

Grammar:
 
   
  
  1. p{color:red;}
2. RGB color
This is consistent with the RGB colors in Photoshop and is matched by the ratio of R (red), G (green), B (blue) Three colors
 
   
  
  1. p{color:rgb(133,45,200);}
the value of each item can be an integer between 0~255, or it can be a percentage of 0%~100%.
 
   
  
  1. 每一项的值可以是 0~255 之间的整数,也可以是 0%~100% 的百分数。
3. Hex Color
This method of color setting is now more commonly used, the principle is also the RGB setting, but the value of each item is changed from 0-255 to Hex 00-ff
 
   
  
  1. p{color:#00ffff;}

Color Table Length ValuesLength Unit Summary, at present more commonly used to px (pixels), EM,% percent, you should pay attention to the fact that these three units are relative units.

1, Pixel

Why are pixels relative units? Because pixels refer to dots on the display (the CSS specification assumes "90 pixels = 1 inches"). The reality is that the browser uses the actual pixel value of the display, and most designers now tend to use pixels (px) as units.

2, EM

is the font-size value of the given font for this element, 1em = 14px If the element's font-size is 14px, and 1em = 18px If the font-size is 18px.

Grammar:
 
   
  
  1. p{font-size:12px;text-indent:2em;}
The code implements the distance from the first line of the paragraph indented 24px (12PX*2), which is two font size

A special case is noted below:

However, when Font-size is set to em , the criteria for this calculation are based on the font-size of the parent element of P.

 
   
  
  1. <p>以这个<span>例子</span>为例。</p>
 
   
  
  1. p{font-size:14px}
  2. span{font-size:0.8em;}
as a result, the font "example" font size in span is 11.2px (0.8 = 11.2px).
3. Percentage
Grammar:
 
   
  
  1. p{font-size:12px;line-height:130%}
Set line height (line spacing) to 130% of the font (* 1.3 = 15.6px)













From for notes (Wiz)

HTML+CSS Notes CSS Intermediate color & length values

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.