10 CSS rules that every web designer should know

Source: Internet
Author: User

With the extensive CSS experience of web designers, we will remember allCodeSyntax, compatibility, and fragment. There are someSpecific CSS can truly help change your website design by changing older technical rules and statements. Here are 10 useful CSS rules I have collected.

 

@ Media
 
@ Media screen and (max-Width: 960px ){}

 

To support earlier browsers, you must stick to the css1 media descriptor screen and print. They are mutually exclusive. Therefore, when a page is generated for the screen display, the browser will ignore the print style sheet, and vice versa. Therefore, each style sheet must contain the same style selector, but there are different rule declarations to generate page styles for different output devices.

Background-size
1 Body {2Background: url(image.jpg) No-Repeat;3Background-size:100%;4}

 

Css3 supports the background-size attribute. You only need a simple line of code to achieve the increasingly popular full-background image effect.

 

@ Font-face
 
@ Font-face {font-family: blackout; SRC: URL ("assests/blackout. TTF") format ("TrueType ");}

@ Font-FACE: loads the font files on the server to display fonts not installed on the client. [Microsoft's ie 5 has started to support this attribute, but only supports Microsoft's own. EOT (Embedded Open Type) format. other browsers have not yet supported this field format. However, since safari 3.1, web page reconstruction engineers have been able to set. TTF (TrueType) and. otf (OpenType) fonts as custom fonts .] For example, Google'sWebfonts or typekit

Margin: 0 auto;
# Container {margin:0Auto ;}

 

Margin: 0 auto;This is the first CSS code snippet that you use most frequently during layout.Margin: 0 auto;You can center the parent element and convert it into a block element. If no center is found, you may forget to define the DIV width.

Overflow: hidden
 
. Container {overflow: hidden ;}

 

Usually you want to solve the floating problem.Clear: both,Overflow: hidden noIt is limited to hiding overflow, and it can also clear floating

. Clearfix
. Clearfix: After {content:"."; Display: block; clear: Both; visibility: hidden; line-Height:0; Height:0;}

 

For those floatingOverflow: hidden;The best way to do this is Clearfix.Remember, you do not have to define the name of the Clearfix class. You can refer this code to any HTML Element

Color: rgba ();
. BTN {color: rgba (0,0,0,0.5);}

 

PNG images are used to create any transparent effect, but now you can use rgba color mode to create them in another method to achieve CSS transparency.Use rgba in the hexadecimal value to select a color, use its red, green, and blue channels, as well as Alpha level, such as 0.5, to set the transparency to 50%.

Input [type = "text"]
 
Input [type ="Text"] {Width: 200px ;}

 

 
Input [type = "text"] is a very common CSS technique. It does not need to define additional class names. It is a very useful styling element to select a specific attribute, you can apply any input element.
Transform: Rotate (30deg );
. Title {transform: Rotate (30deg );}

 

In css3, the transform function can be used to rotate, scale, tilt, and move text or images, the four types of deformation are implemented using the rotate, scale, skew, and translate methods.Browser support: safari 3.1 +, chrome 8 +, Firefox 4 +, opera 10 +, and ie9 +

A {outline: none ;}
 
A {outline: none ;}

When you focus on the tag, there is a dotted box around the area of the tag. Unlike border, this box does not occupy any width. When you cancel the focus, the dotted box will naturally disappear. You can see it through several versions of travel, Firefox, or IE. Safari, opera, and Goole browsers do not support this effect, so they cannot be seen. The following is an example of outline, which is captured on a page that I am working on. DefinitionOutline: none; this line can be canceled.

ArticleCollected

Related Article

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.