13、锚链接伪类
- a:link { color: blue; }
- a:visited { color: purple; }
- a:hover { color: red; }
- a:active { color: yellow; }
14、图片边框偏光
- img.polaroid {
- background:#000; /*Change this to a background image or remove*/
- border:solid #fff;
- border-width:6px 6px 20px 6px;
- box-shadow:1px 1px 5px #333; /* Standard blur at 5px. Increase for more depth */
- -webkit-box-shadow:1px 1px 5px #333;
- -moz-box-shadow:1px 1px 5px #333;
- height:200px; /*Set to height of your image or desired div*/
- width:200px; /*Set to width of your image or desired div*/
- }
15、通用媒体查询
- /* 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 */
- }
16、跨浏览器透明
- .transparent {
- filter: alpha(opacity=50); /* internet explorer */
- -khtml-opacity: 0.5; /* khtml, old safari */
- -moz-opacity: 0.5; /* mozilla, netscape */
- opacity: 0.5; /* fx, safari, opera */
- }
17、用CSS动画实现省略号动画
- .loading:after {
- overflow: hidden;
- display: inline–block;
- vertical-align: bottombottom;
- animation: ellipsis 2s infinite;
- content: “\2026”; /* ascii code for the ellipsis character */
- }
- @keyframes ellipsis {
- from {
- width: 2px;
- }
- to {
- width: 15px;
- }
- }
18、制造模糊文本
- .blurry-text {
- color: transparent;
- text-shadow: 0 0 5px rgba(0,0,0,0.5);
- }
19、包裹长文本 文本过长自动换行不会穿破盒子
- pre {
- whitewhite-space: pre-line;
- word-wrap: break-word;
- }
20、背景渐变色
- button {
- background-image: linear-gradient(#5187c4, #1c2f45);
- background–size: auto 200%;
- background-position: 0 100%;
- transition: background-position 0.5s;
- }
- button:hover {
- background-position: 0 0;
- }
21、内容可编辑(contenteditable=”true”)
- <ul contenteditable=“true”>
- <li>悼念遇难香港同胞 </li>
- <li>深圳特区30周年</li>
- <li>伊春空难</li>
- </ul>
22、输入框改变placeholder字体颜色
- ::-webkit-input-placeholder {
- color: red;
- }
- :-moz-placeholder {
- color: red;
- }
- ::-moz-placeholder{
- color: red;
- }
- :-ms-input-placeholder {
- color: red;
- }