CSS Useful Code Snippets

Source: Internet
Author: User

1. Stretch an element to the height of the window

In a specific scenario, you may want to extend an element to the height of the window, and the adjustment of the base element can only resize the container, so to extend an element to the height of the window, we need to stretch the top element: html and body :

html, body {    %;} 

Then apply 100% to the height of any element:

Div {    %;} 
2. Show box shadows only on one side or both sides

If you want a box shadow, try this technique to add a shadow to either side. To achieve this, first define a box with a specific width, and then locate the :after pseudo-class correctly. The code to implement the bottom shadow is as follows:

. box-Shadow {background-color: #FF8020;    width:160px;    height:90px; Margin-top:-45px; Margin-left:-80px;    Position:absolute; Top: -%; Left: -%;}. Box-shadow:after {content:"";    width:150px;    height:1px; Margin-top:88px; Margin-left:-75px;    Display:block;    Position:absolute; Left: -%; Z-index:-1; -webkit-box-shadow:0px 0px 8px 2px #000000; -moz-box-shadow:0px 0px 8px 2px #000000; Box-shadow:0px 0px 8px 2px #000000;}
3, Manufacturing fuzzy text

Want to blur text? colortransparency and implementation can be used text-shadow .

. blurry-Text {   color:transparent;   Text00 5px rgba (0,0,0,0.5);}
3, the new version of Clear floating (2011)
"" ; display:table;}. Clearfix:after {clear:both;} /*  */1; }
4. General Media Enquiry
/*Smartphones (portrait and landscape)-----------*/@media only screen and (min-device-width:320px) and (max-device-width:480px) {  /*Styles*/}/*Smartphones (Landscape)-----------*/@media only screen and (min-width:321px) {  /*Styles*/}/*Smartphones (portrait)-----------*/@media only screen and (Max-width:320px) {  /*Styles*/}/*iPads (Portrait and Landscape)-----------*/@media only screen and (min-device-width:768px) and (max-device-width:1024px) {  /*Styles*/}/*iPads (Landscape)-----------*/@media only screen and (min-device-width:768px) and (max-device-width:1024px) and (Orientation:landscape) {/*Styles*/}/*iPads (Portrait)-----------*/@media only screen and (min-device-width:768px) and (max-device-width:1024px) and (orientation:portrait) {/*Styles*/}/*desktops and laptops-----------*/@media only screen and (min-width:1224px) {  /*Styles*/}/*Large Screens-----------*/@media only screen and (min-width:1824px) {  /*Styles*/}/*IPhone 4-----------*/@media only Screen and (-webkit-min-device-pixel-ratio:1.5), only screen and (Min-device-pixel-ratio:1.5) {  /*Styles*/}
5. Force the vertical scroll bar to appear
101%}
6. CSS3 Zebra Crossing
Tbody tr:nth-child(odd) {    background-color: #ccc;}

Original link: 1190000002773955

CSS Useful Code Snippets

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.