【译】60个有用CSS代码片段
<p><img src="https://simg.open-open.com/show/00f77bdf89132de324a7442d6a41a58a.jpg"></p> <h2>1、垂直对齐</h2> <p>如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,可以很优雅的解决这个困惑:</p> <ol> <li>.verticalcenter{</li> <li>position: relative;</li> <li>top: 50%;</li> <li>-webkit-transform: translateY(-50%);</li> <li>-o-transform: translateY(-50%);</li> <li>transform: translateY(-50%);</li> <li>}</li> </ol> <p>(ps: <a href="/misc/goto?guid=4959676932545427975" rel="nofollow,noindex">【译】如何实现CSS居中?–CSS居中常用方法</a> )</p> <p>使用这个技巧,从单行文本、段落到box,都会垂直对齐。目前浏览器对Transform的支持是需要关注的,Chrome 4, Opera 10, Safari 3, Firefox 3, and Internet Explorer 9.均支持该属性。</p> <h2>2、伸展一个元素到窗口高度</h2> <p>在具体场景中,你可能想要将一个元素伸展到窗口高度,基本元素的调整只能调整容器的大小,因此要使一个元素伸展到窗口高度,我们需要伸展顶层元素: html 和 body :</p> <ol> <li>html,</li> <li>body {</li> <li>height: 100%;</li> <li>}</li> </ol> <p>然后将100%应用到任何元素的高:</p> <ol> <li>div {</li> <li>height: 100%;</li> <li>}</li> </ol> <h2>3、基于文件格式使用不同的样式</h2> <p>为了更容易知道链接的目标,有时你想让一些链接看起来和其它的不同。下面的片段在文本链接前添加一个图标,对不同的资源使用不同的图标或图片:</p> <ol> <li>a[href^="http://"]{</li> <li>padding-right: 20px;</li> <li>background: url(external.gif) no-repeat center right;</li> <li>}</li> <li>/* emails */</li> <li>a[href^="mailto:"]{</li> <li>padding-right: 20px;</li> <li>background: url(email.png) no-repeat center right;</li> <li>}</li> <li> </li> <li>/* pdfs */</li> <li>a[href$=".pdf"]{</li> <li>padding-right: 20px;</li> <li>background: url(pdf.png) no-repeat center right;</li> <li>}</li> </ol> <p>看起来是这样的: <a href="/misc/goto?guid=4959676932641156000" rel="nofollow,noindex">http://jsfiddle.net/agusesetiyono/3sL1r0mw/light/</a></p> <h2>4、创建跨浏览器的图像灰度</h2> <p>灰度有时看起来简约和优雅,能为网站呈现更深层次的色调。在示例中,我们将对一个SVG图像添加灰度过滤:</p> <ol> <li><svg xmlns="http://www.w3.org/2000/svg"></li> <li><filter id="grayscale"></li> <li><feColorMatrix type="matrix" values="0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0"/></li> <li></filter></li> <li></svg></li> </ol> <p>为了跨浏览器,会用到 filter 属性:</p> <ol> <li>img {</li> <li>filter: url(filters.svg#grayscale); /* Firefox 3.5+ */</li> <li>filter: gray; /* IE6-9 */</li> <li>-webkit-filter: grayscale(1); /* Google Chrome, Safari 6+ & Opera 15+ */</li> <li>}</li> </ol> <h2>5、背景渐变动画</h2> <p>CSS中最具诱惑的一个功能是能添加动画效果,除了渐变,你可以给背景色、透明度、元素大小添加动画。目前,你不能为渐变添加动画,但下面的代码可能有帮助。它通过改变背景位置,让它看起来有动画效果。</p> <ol> <li>button {</li> <li>background-image: linear-gradient(#5187c4, #1c2f45);</li> <li>background-size: auto 200%;</li> <li>background-position: 0 100%;</li> <li>transition: background-position 0.5s;</li> <li>}</li> <li>button:hover {</li> <li>background-position: 0 0;</li> <li>}</li> </ol> <p>效果在这里: <a href="/misc/goto?guid=4959676932718048853" rel="nofollow,noindex">http://jsfiddle.net/agusesetiyono/gw46dk27/1/light/</a></p> <h2>6、CSS:表格列宽自适用</h2> <p>对于表格,当谈到调整列宽时,是比较痛苦的。然后,这里有一个可以使用的技巧:给 td 元素添加 white-space: nowrap; 能让文本正确的换行</p> <ol> <li>td {</li> <li>white-space: nowrap;</li> <li>}</li> </ol> <p>查看效果: <a href="/misc/goto?guid=4959676932803548711" rel="nofollow,noindex">http://jsfiddle.net/agusesetiyono/1uotj8wv/3/light/</a></p> <h2>7、只在一边或两边显示盒子阴影</h2> <p>如果你要一个盒阴影,试试这个技巧,能为任一边添加阴影。为了实现这个,首先定义一个有具体宽高的盒子,然后正确定位 :after 伪类。实现底边阴影的代码如下:</p> <ol> <li>.box-shadow {</li> <li>background-color: #FF8020;</li> <li>width: 160px;</li> <li>height: 90px;</li> <li>margin-top: -45px;</li> <li>margin-left: -80px;</li> <li>position: absolute;</li> <li>top: 50%;</li> <li>left: 50%;</li> <li>}</li> <li>.box-shadow:after {</li> <li>content: "";</li> <li>width: 150px;</li> <li>height: 1px;</li> <li>margin-top: 88px;</li> <li>margin-left: -75px;</li> <li>display: block;</li> <li>position: absolute;</li> <li>left: 50%;</li> <li>z-index: -1;</li> <li>-webkit-box-shadow: 0px 0px 8px 2px #000000;</li> <li>-moz-box-shadow: 0px 0px 8px 2px #000000;</li> <li>box-shadow: 0px 0px 8px 2px #000000;</li> <li>}</li> </ol> <p>效果: <a href="/misc/goto?guid=4959676932881107239" rel="nofollow,noindex">http://jsfiddle.net/agusesetiyono/1kwhsfvo/light/</a></p> <h2>8、包裹长文本</h2> <p>如果你碰到一个比自身容器长的文本,这个技巧对你很有用。在这个示例中,默认时,不管容器的宽度,文本都将水平填充。</p> <p><img src="https://simg.open-open.com/show/cd553893eede73014309161316f91119.jpg"></p> <p>简单的CSS代码就能在容器中调整文本:</p> <ol> <li>pre {</li> <li>white-space: pre-line;</li> <li>word-wrap: break-word;</li> <li>}</li> </ol> <p>效果看起来如下:</p> <p><img src="https://simg.open-open.com/show/dff97d58250030a3712867fbbf4ba84a.jpg"></p> <h2>9、制造模糊文本</h2> <p>想要让文本模糊?可以使用 color 透明和 text-shadow 实现。</p> <ol> <li>.blurry-text {</li> <li>color: transparent;</li> <li>text-shadow: 0 0 5px rgba(0,0,0,0.5);</li> <li>}</li> </ol> <p>demo: <a href="/misc/goto?guid=4959676932958702973" rel="nofollow,noindex">http://jsfiddle.net/agusesetiyono/n5uh4s0j/light/</a></p> <h2>10、用CSS动画实现省略号动画</h2> <p>这个片段将帮助你制造一个ellipsis的动画,对于简单的加载状态是很有用的,而不用去使用gif图像。</p> <ol> <li>.loading:after {</li> <li>overflow: hidden;</li> <li>display: inline-block;</li> <li>vertical-align: bottom;</li> <li>animation: ellipsis 2s infinite;</li> <li>content: "\2026"; /* ascii code for the ellipsis character */</li> <li>}</li> <li>@keyframes ellipsis {</li> <li>from {</li> <li>width: 2px;</li> <li>}</li> <li>to {</li> <li>width: 15px;</li> <li>}</li> <li>}</li> </ol> <p>效果: <a href="/misc/goto?guid=4959676933044328233" rel="nofollow,noindex">http://jsfiddle.net/agusesetiyono/MDzsR/69/light/</a></p> <h2>11、样式重置</h2> <ol> <li>html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {</li> <li>margin: 0;</li> <li>padding: 0;</li> <li>border: 0;</li> <li>font-size: 100%;</li> <li>font: inherit;</li> <li>vertical-align: baseline;</li> <li>outline: none;</li> <li>-webkit-box-sizing: border-box;</li> <li>-moz-box-sizing: border-box;</li> <li>box-sizing: border-box;</li> <li>}</li> <li>html { height: 101%; }</li> <li>body { font-size: 62.5%; line-height: 1; font-family: Arial, Tahoma, sans-serif; }</li> <li> </li> <li>article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; }</li> <li>ol, ul { list-style: none; }</li> <li> </li> <li>blockquote, q { quotes: none; }</li> <li>blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; }</li> <li>strong { font-weight: bold; }</li> <li> </li> <li>table { border-collapse: collapse; border-spacing: 0; }</li> <li>img { border: 0; max-width: 100%; }</li> <li> </li> <li>p { font-size: 1.2em; line-height: 1.0em; color: #333; }</li> </ol> <h2>12、典型的CSS清除浮动</h2> <ol> <li>.clearfix:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; }</li> <li>.clearfix { display: inline-block; }</li> <li> </li> <li>html[xmlns] .clearfix { display: block; }</li> <li>* html .clearfix { height: 1%; }</li> </ol> <h2>13、新版清除浮动(2011)</h2> <ol> <li>.clearfix:before, .container:after { content: ""; display: table; }</li> <li>.clearfix:after { clear: both; }</li> <li> </li> <li>/* IE 6/7 */</li> <li>.clearfix { zoom: 1; }</li> </ol> <h2>14、跨浏览器的透明</h2> <ol> <li>.transparent {</li> <li>filter: alpha(opacity=50); /* internet explorer */</li> <li>-khtml-opacity: 0.5; /* khtml, old safari */</li> <li>-moz-opacity: 0.5; /* mozilla, netscape */</li> <li>opacity: 0.5; /* fx, safari, opera */</li> <li>}</li> </ol> <h2>15、CSS引用模板</h2> <ol> <li>blockquote {</li> <li>background: #f9f9f9;</li> <li>border-left: 10px solid #ccc;</li> <li>margin: 1.5em 10px;</li> <li>padding: .5em 10px;</li> <li>quotes: "\201C""\201D""\2018""\2019";</li> <li>}</li> <li>blockquote:before {</li> <li>color: #ccc;</li> <li>content: open-quote;</li> <li>font-size: 4em;</li> <li>line-height: .1em;</li> <li>margin-right: .25em;</li> <li>vertical-align: -.4em;</li> <li>}</li> <li>blockquote p {</li> <li>display: inline;</li> <li>}</li> </ol> <h2>16、个性圆角</h2> <ol> <li>#container {</li> <li>-webkit-border-radius: 4px 3px 6px 10px;</li> <li>-moz-border-radius: 4px 3px 6px 10px;</li> <li>-o-border-radius: 4px 3px 6px 10px;</li> <li>border-radius: 4px 3px 6px 10px;</li> <li>}</li> <li> </li> <li>/* alternative syntax broken into each line */</li> <li>#container {</li> <li>-webkit-border-top-left-radius: 4px;</li> <li>-webkit-border-top-right-radius: 3px;</li> <li>-webkit-border-bottom-right-radius: 6px;</li> <li>-webkit-border-bottom-left-radius: 10px;</li> <li> </li> <li>-moz-border-radius-topleft: 4px;</li> <li>-moz-border-radius-topright: 3px;</li> <li>-moz-border-radius-bottomright: 6px;</li> <li>-moz-border-radius-bottomleft: 10px;</li> <li>}</li> </ol> <h2>17、通用媒体查询</h2> <ol> <li>/* Smartphones (portrait and landscape) ----------- */</li> <li>@media only screen</li> <li>and (min-device-width : 320px) and (max-device-width : 480px) {</li> <li>/* Styles */</li> <li>}</li> <li> </li> <li>/* Smartphones (landscape) ----------- */</li> <li>@media only screen and (min-width : 321px) {</li> <li>/* Styles */</li> <li>}</li> <li> </li> <li>/* Smartphones (portrait) ----------- */</li> <li>@media only screen and (max-width : 320px) {</li> <li>/* Styles */</li> <li>}</li> <li> </li> <li>/* iPads (portrait and landscape) ----------- */</li> <li>@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {</li> <li>/* Styles */</li> <li>}</li> <li> </li> <li>/* iPads (landscape) ----------- */</li> <li>@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {</li> <li>/* Styles */</li> <li>}</li> <li> </li> <li>/* iPads (portrait) ----------- */</li> <li>@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {</li> <li>/* Styles */</li> <li>}</li> <li> </li> <li>/* Desktops and laptops ----------- */</li> <li>@media only screen and (min-width : 1224px) {</li> <li>/* Styles */</li> <li>}</li> <li> </li> <li>/* Large screens ----------- */</li> <li>@media only screen and (min-width : 1824px) {</li> <li>/* Styles */</li> <li>}</li> <li> </li> <li>/* iPhone 4 ----------- */</li> <li>@media only screen and (-webkit-min-device-pixel-ratio:1.5), only screen and (min-device-pixel-ratio:1.5) {</li> <li>/* Styles */</li> <li>}</li> </ol> <p>(ps: <a href="/misc/goto?guid=4959676933128240011" rel="nofollow,noindex">【译】Responsive Design常用的媒体查询</a> )</p> <h2>18、现代字体栈</h2> <ol> <li>/* Times New Roman-based serif */</li> <li>font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;</li> <li> </li> <li>/* A modern Georgia-based serif */</li> <li>font-family: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif," "Bitstream Vera Serif", "Liberation Serif", Georgia, serif;</li> <li> </li> <li>/*A more traditional Garamond-based serif */</li> <li>font-family: "Palatino Linotype", Palatino, Palladio, "URW Palladio L", "Book Antiqua", Baskerville, "Bookman Old Style", "Bitstream Charter", "Nimbus Roman No9 L", Garamond, "Apple Garamond", "ITC Garamond Narrow", "New Century Schoolbook", "Century Schoolbook", "Century Schoolbook L", Georgia, serif;</li> <li> </li> <li>/*The Helvetica/Arial-based sans serif */</li> <li>font-family: Frutiger, "Frutiger Linotype", Univers, Calibri, "Gill Sans", "Gill Sans MT", "Myriad Pro", Myriad, "DejaVu Sans Condensed", "Liberation Sans", "Nimbus Sans L", Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif;</li> <li> </li> <li>/*The Verdana-based sans serif */</li> <li>font-family: Corbel, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", "Bitstream Vera Sans", "Liberation Sans", Verdana, "Verdana Ref", sans-serif;</li> <li> </li> <li>/*The Trebuchet-based sans serif */</li> <li>font-family: "Segoe UI", Candara, "Bitstream Vera Sans", "DejaVu Sans", "Bitstream Vera Sans", "Trebuchet MS", Verdana, "Verdana Ref", sans-serif;</li> <li> </li> <li>/*The heavier "Impact" sans serif */</li> <li>font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", Charcoal, "Helvetica Inserat", "Bitstream Vera Sans Bold", "Arial Black", sans-serif;</li> <li> </li> <li>/*The monospace */</li> <li>font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace;</li> </ol> <p><a href="/misc/goto?guid=4958533837481104314" rel="nofollow,noindex">Code Source</a></p> <h2>19、自定义文本选择</h2> <ol> <li>::selection { background: #e2eae2; }</li> <li>::-moz-selection { background: #e2eae2; }</li> <li>::-webkit-selection { background: #e2eae2; }</li> </ol> <h2>20、为logo隐藏H1</h2> <ol> <li>h1 {</li> <li>text-indent: -9999px;</li> <li>margin: 0 auto;</li> <li>width: 320px;</li> <li>height: 85px;</li> <li>background: transparent url("images/logo.png") no-repeat scroll;</li> <li>}</li> </ol> <h2>21、图片边框偏光</h2> <ol> <li>img.polaroid {</li> <li>background:#000; /*Change this to a background image or remove*/</li> <li>border:solid #fff;</li> <li>border-width:6px 6px 20px 6px;</li> <li>box-shadow:1px 1px 5px #333; /* Standard blur at 5px. Increase for more depth */</li> <li>-webkit-box-shadow:1px 1px 5px #333;</li> <li>-moz-box-shadow:1px 1px 5px #333;</li> <li>height:200px; /*Set to height of your image or desired div*/</li> <li>width:200px; /*Set to width of your image or desired div*/</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533837801092937" rel="nofollow,noindex">Code Source</a></p> <h2>22、锚链接伪类</h2> <ol> <li>a:link { color: blue; }</li> <li>a:visited { color: purple; }</li> <li>a:hover { color: red; }</li> <li>a:active { color: yellow; }</li> </ol> <p><a href="/misc/goto?guid=4958533837912004281" rel="nofollow,noindex">Code Source</a></p> <h2>23、奇特的CSS引用</h2> <ol> <li>.has-pullquote:before {</li> <li>/* Reset metrics. */</li> <li>padding: 0;</li> <li>border: none;</li> <li> </li> <li>/* Content */</li> <li>content: attr(data-pullquote);</li> <li> </li> <li>/* Pull out to the right, modular scale based margins. */</li> <li>float: right;</li> <li>width: 320px;</li> <li>margin: 12px -140px 24px 36px;</li> <li> </li> <li>/* Baseline correction */</li> <li>position: relative;</li> <li>top: 5px;</li> <li> </li> <li>/* Typography (30px line-height equals 25% incremental leading) */</li> <li>font-size: 23px;</li> <li>line-height: 30px;</li> <li>}</li> <li> </li> <li>.pullquote-adelle:before {</li> <li>font-family: "adelle-1", "adelle-2";</li> <li>font-weight: 100;</li> <li>top: 10px !important;</li> <li>}</li> <li> </li> <li>.pullquote-helvetica:before {</li> <li>font-family: "Helvetica Neue", Arial, sans-serif;</li> <li>font-weight: bold;</li> <li>top: 7px !important;</li> <li>}</li> <li> </li> <li>.pullquote-facit:before {</li> <li>font-family: "facitweb-1", "facitweb-2", Helvetica, Arial, sans-serif;</li> <li>font-weight: bold;</li> <li>top: 7px !important;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533838007049652" rel="nofollow,noindex">Code Source</a></p> <h2>24、CSS3:全屏背景</h2> <ol> <li>html {</li> <li>background: url('images/bg.jpg') no-repeat center center fixed;</li> <li>-webkit-background-size: cover;</li> <li>-moz-background-size: cover;</li> <li>-o-background-size: cover;</li> <li>background-size: cover;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533838121579169" rel="nofollow,noindex">Code Source</a></p> <h2>25、内容垂直居中</h2> <ol> <li>.container {</li> <li>min-height: 6.5em;</li> <li>display: table-cell;</li> <li>vertical-align: middle;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533838226277867" rel="nofollow,noindex">Code Source</a></p> <h2>26、强制出现垂直滚动条</h2> <ol> <li>html { height: 101% }</li> </ol> <h2>27、CSS3渐变模板</h2> <ol> <li>#colorbox {</li> <li>background: #629721;</li> <li>background-image: -webkit-gradient(linear, left top, left bottom, from(#83b842), to(#629721));</li> <li>background-image: -webkit-linear-gradient(top, #83b842, #629721);</li> <li>background-image: -moz-linear-gradient(top, #83b842, #629721);</li> <li>background-image: -ms-linear-gradient(top, #83b842, #629721);</li> <li>background-image: -o-linear-gradient(top, #83b842, #629721);</li> <li>background-image: linear-gradient(top, #83b842, #629721);</li> <li>}</li> </ol> <h2>28、@font-face模板</h2> <ol> <li>@font-face {</li> <li>font-family: 'MyWebFont';</li> <li>src: url('webfont.eot'); /* IE9 Compat Modes */</li> <li>src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */</li> <li>url('webfont.woff') format('woff'), /* Modern Browsers */</li> <li>url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */</li> <li>url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */</li> <li>}</li> <li> </li> <li>body {</li> <li>font-family: 'MyWebFont', Arial, sans-serif;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958335380631283516" rel="nofollow,noindex">Code Source</a></p> <h2>29、缝合CSS3元素</h2> <ol> <li>p {</li> <li>position:relative;</li> <li>z-index:1;</li> <li>padding: 10px;</li> <li>margin: 10px;</li> <li>font-size: 21px;</li> <li>line-height: 1.3em;</li> <li>color: #fff;</li> <li>background: #ff0030;</li> <li>-webkit-box-shadow: 0 0 0 4px #ff0030, 2px 1px 4px 4px rgba(10,10,0,.5);</li> <li>-moz-box-shadow: 0 0 0 4px #ff0030, 2px 1px 4px 4px rgba(10,10,0,.5);</li> <li>box-shadow: 0 0 0 4px #ff0030, 2px 1px 6px 4px rgba(10,10,0,.5);</li> <li>-webkit-border-radius: 3px;</li> <li>-moz-border-radius: 3px;</li> <li>border-radius: 3px;</li> <li>}</li> <li> </li> <li>p:before {</li> <li>content: "";</li> <li>position: absolute;</li> <li>z-index: -1;</li> <li>top: 3px;</li> <li>bottom: 3px;</li> <li>left :3px;</li> <li>right: 3px;</li> <li>border: 2px dashed #fff;</li> <li>}</li> <li> </li> <li>p a {</li> <li>color: #fff;</li> <li>text-decoration:none;</li> <li>}</li> <li> </li> <li>p a:hover, p a:focus, p a:active {</li> <li>text-decoration:underline;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533838367262351" rel="nofollow,noindex">Code Source</a></p> <h2>30、CSS3 斑马线</h2> <ol> <li>tbody tr:nth-child(odd) {</li> <li>background-color: #ccc;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958335377554408718" rel="nofollow,noindex">Code Source</a></p> <h2>31、有趣的&</h2> <ol> <li>.amp {</li> <li>font-family: Baskerville, 'Goudy Old Style', Palatino, 'Book Antiqua', serif;</li> <li>font-style: italic;</li> <li>font-weight: normal;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533838523982109" rel="nofollow,noindex">Code Source</a></p> <h2>32、大字段落</h2> <ol> <li>p:first-letter{</li> <li>display: block;</li> <li>margin: 5px 0 0 5px;</li> <li>float: left;</li> <li>color: #ff3366;</li> <li>font-size: 5.4em;</li> <li>font-family: Georgia, Times New Roman, serif;</li> <li>}</li> </ol> <h2>33、内部CSS3 盒阴影</h2> <ol> <li>#mydiv {</li> <li>-moz-box-shadow: inset 2px 0 4px #000;</li> <li>-webkit-box-shadow: inset 2px 0 4px #000;</li> <li>box-shadow: inset 2px 0 4px #000;</li> <li>}</li> </ol> <h2>34、外部CSS3 盒阴影</h2> <ol> <li>#mydiv {</li> <li>-webkit-box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52);</li> <li>-moz-box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52);</li> <li>box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52);</li> <li>}</li> </ol> <h2>35、三角形列表项目符号</h2> <ol> <li>ul {</li> <li>margin: 0.75em 0;</li> <li>padding: 0 1em;</li> <li>list-style: none;</li> <li>}</li> <li>li:before {</li> <li>content: "";</li> <li>border-color: transparent #111;</li> <li>border-style: solid;</li> <li>border-width: 0.35em 0 0.35em 0.45em;</li> <li>display: block;</li> <li>height: 0;</li> <li>width: 0;</li> <li>left: -1em;</li> <li>top: 0.9em;</li> <li>position: relative;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533838726597093" rel="nofollow,noindex">Code Source</a></p> <h2>36、固定宽度的居中布局</h2> <ol> <li>#page-wrap {</li> <li>width: 800px;</li> <li>margin: 0 auto;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533838840867625" rel="nofollow,noindex">Code Source</a></p> <h2>37、CSS3 列文本</h2> <ol> <li>#columns-3 {</li> <li>text-align: justify;</li> <li>-moz-column-count: 3;</li> <li>-moz-column-gap: 12px;</li> <li>-moz-column-rule: 1px solid #c4c8cc;</li> <li>-webkit-column-count: 3;</li> <li>-webkit-column-gap: 12px;</li> <li>-webkit-column-rule: 1px solid #c4c8cc;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533838967962621" rel="nofollow,noindex">Code Source</a></p> <h2>38、CSS固定页脚</h2> <ol> <li>#footer {</li> <li>position: fixed;</li> <li>left: 0px;</li> <li>bottom: 0px;</li> <li>height: 30px;</li> <li>width: 100%;</li> <li>background: #444;</li> <li>}</li> <li> </li> <li>/* IE 6 */</li> <li>* html #footer {</li> <li>position: absolute;</li> <li>top: expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px');</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533839054907741" rel="nofollow,noindex">Code Source</a></p> <h2>39、IE6的PNG透明修复</h2> <ol> <li>.bg {</li> <li>width:200px;</li> <li>height:100px;</li> <li>background: url(/folder/yourimage.png) no-repeat;</li> <li>_background:none;</li> <li>_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/folder/yourimage.png',sizingMethod='crop');</li> <li>}</li> <li> </li> <li> </li> <li>/* 1px gif method */</li> <li>img, .png {</li> <li>position: relative;</li> <li>behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none",</li> <li>this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')",</li> <li>this.src = "images/transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''),</li> <li>this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')",</li> <li>this.runtimeStyle.backgroundImage = "none")),this.pngSet=true));</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533839136939164" rel="nofollow,noindex">Code Source</a></p> <h2>40、跨浏览器设置最小高度</h2> <ol> <li>#container {</li> <li>min-height: 550px;</li> <li>height: auto !important;</li> <li>height: 550px;</li> <li>}</li> </ol> <h2>41、CSS3 鲜艳的输入</h2> <ol> <li>input[type=text], textarea {</li> <li>-webkit-transition: all 0.30s ease-in-out;</li> <li>-moz-transition: all 0.30s ease-in-out;</li> <li>-ms-transition: all 0.30s ease-in-out;</li> <li>-o-transition: all 0.30s ease-in-out;</li> <li>outline: none;</li> <li>padding: 3px 0px 3px 3px;</li> <li>margin: 5px 1px 3px 0px;</li> <li>border: 1px solid #ddd;</li> <li>}</li> <li> </li> <li>input[type=text]:focus, textarea:focus {</li> <li>box-shadow: 0 0 5px rgba(81, 203, 238, 1);</li> <li>padding: 3px 0px 3px 3px;</li> <li>margin: 5px 1px 3px 0px;</li> <li>border: 1px solid rgba(81, 203, 238, 1);</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533839235937034" rel="nofollow,noindex">Code Source</a></p> <h2>42、基于文件类型的链接样式</h2> <ol> <li>/* external links */</li> <li>a[href^="http://"] {</li> <li>padding-right: 13px;</li> <li>background: url('external.gif') no-repeat center right;</li> <li>}</li> <li> </li> <li>/* emails */</li> <li>a[href^="mailto:"] {</li> <li>padding-right: 20px;</li> <li>background: url('email.png') no-repeat center right;</li> <li>}</li> <li> </li> <li>/* pdfs */</li> <li>a[href$=".pdf"] {</li> <li>padding-right: 18px;</li> <li>background: url('acrobat.png') no-repeat center right;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533839338282339" rel="nofollow,noindex">Code Source</a></p> <h2>43、强制换行</h2> <ol> <li>pre {</li> <li>white-space: pre-wrap; /* css-3 */</li> <li>white-space: -moz-pre-wrap; /* Mozilla, since 1999 */</li> <li>white-space: -pre-wrap; /* Opera 4-6 */</li> <li>white-space: -o-pre-wrap; /* Opera 7 */</li> <li>word-wrap: break-word; /* Internet Explorer 5.5+ */</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533839448163240" rel="nofollow,noindex">Code Source</a></p> <h2>44、在可点击的项目上强制手型</h2> <ol> <li>a[href], input[type='submit'], input[type='image'], label[for], select, button, .pointer {</li> <li>cursor: pointer;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533839545742715" rel="nofollow,noindex">Code Source</a></p> <h2>45、网页顶部盒阴影</h2> <ol> <li>body:before {</li> <li>content: "";</li> <li>position: fixed;</li> <li>top: -10px;</li> <li>left: 0;</li> <li>width: 100%;</li> <li>height: 10px;</li> <li> </li> <li>-webkit-box-shadow: 0px 0px 10px rgba(0,0,0,.8);</li> <li>-moz-box-shadow: 0px 0px 10px rgba(0,0,0,.8);</li> <li>box-shadow: 0px 0px 10px rgba(0,0,0,.8);</li> <li>z-index: 100;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533839663356180" rel="nofollow,noindex">Code Source</a></p> <h2>46、CSS3对话气泡</h2> <ol> <li>.chat-bubble {</li> <li>background-color: #ededed;</li> <li>border: 2px solid #666;</li> <li>font-size: 35px;</li> <li>line-height: 1.3em;</li> <li>margin: 10px auto;</li> <li>padding: 10px;</li> <li>position: relative;</li> <li>text-align: center;</li> <li>width: 300px;</li> <li>-moz-border-radius: 20px;</li> <li>-webkit-border-radius: 20px;</li> <li>-moz-box-shadow: 0 0 5px #888;</li> <li>-webkit-box-shadow: 0 0 5px #888;</li> <li>font-family: 'Bangers', arial, serif;</li> <li>}</li> <li>.chat-bubble-arrow-border {</li> <li>border-color: #666 transparent transparent transparent;</li> <li>border-style: solid;</li> <li>border-width: 20px;</li> <li>height: 0;</li> <li>width: 0;</li> <li>position: absolute;</li> <li>bottom: -42px;</li> <li>left: 30px;</li> <li>}</li> <li>.chat-bubble-arrow {</li> <li>border-color: #ededed transparent transparent transparent;</li> <li>border-style: solid;</li> <li>border-width: 20px;</li> <li>height: 0;</li> <li>width: 0;</li> <li>position: absolute;</li> <li>bottom: -39px;</li> <li>left: 30px;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533839749943668" rel="nofollow,noindex">Code Source</a></p> <h2>47、H1-H5默认样式</h2> <ol> <li>h1,h2,h3,h4,h5{</li> <li>color: #005a9c;</li> <li>}</li> <li>h1{</li> <li>font-size: 2.6em;</li> <li>line-height: 2.45em;</li> <li>}</li> <li>h2{</li> <li>font-size: 2.1em;</li> <li>line-height: 1.9em;</li> <li>}</li> <li>h3{</li> <li>font-size: 1.8em;</li> <li>line-height: 1.65em;</li> <li>}</li> <li>h4{</li> <li>font-size: 1.65em;</li> <li>line-height: 1.4em;</li> <li>}</li> <li>h5{</li> <li>font-size: 1.4em;</li> <li>line-height: 1.25em;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533839850149250" rel="nofollow,noindex">Code Source</a></p> <h2>48、纯CSS背景噪音</h2> <ol> <li>body {</li> <li>background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwUNqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZaV*NAPcoU0dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+hYHnUt5ZPfnsHJyNiDtnpJyayNBkF6cWoYGAMY92U2hXHF/C1M8uP/ZtYdiuj26UdAdQQSXQErwSOMzt/XWRWAz5GuSBIkwG1H3FabJ2OsUOUhGC6tK4EMtJO0ttC6IBD3kM0ve0tJwMdSfjZo+EEISaeTr9P3wYrGjXqyC1krcKdhMpxEnt5JetoulscpyzhXN5FRpuPHvbeQaKxFAEB6EN+cYN6xD7RYGpXpNndMmZgM5Dcs3YSNFDHUo2LGfZuukSWyUYirJAdYbF3MfqEKmjM+I2EfhA94iG3L7uKrR+GdWD73ydlIB+6hgref1QTlmgmbM3/LeX5GI1Ux1RWpgxpLuZ2+I+IjzZ8wqE4nilvQdkUdfhzI5QDWy+kw5Wgg2pGpeEVeCCA7b85BO3F9DzxB3cdqvBzWcmzbyMiqhzuYqtHRVG2y4x+KOlnyqla8AoWWpuBoYRxzXrfKuILl6SfiWCbjxoZJUaCBj1CjH7GIaDbc9kqBY3W/Rgjda1iqQcOJu2WW+76pZC9QG7M00dffe9hNnseupFL53r8F7YHSwJWUKP2q+k7RdsxyOB11n0xtOvnW4irMMFNV4H0uqwS5ExsmP9AxbDTc9JwgneAT5vTiUSm1E7BSflSt3bfa1tv8Di3R8n3Af7MNWzs49hmauE2wP+ttrq+AsWpFG2awvsuOqbipWHgtuvuaAE+A1Z/7gC9hesnr+7wqCwG8c5yAg3AL1fm8T9AZtp/bbJGwl1pNrE7RuOX7PeMRUERVaPpEs+yqeoSmuOlokqw49pgomjLeh7icHNlG19yjs6XXOMedYm5xH2YxpV2tc0Ro2jJfxC50ApuxGob7lMsxfTbeUv07TyYxpeLucEH1gNd4IKH2LAg5TdVhlCafZvpskfncCfx8pOhJzd76bJWeYFnFciwcYfubRc12Ip/ppIhA1/mSZ/RxjFDrJC5xifFjJpY2Xl5zXdguFqYyTR1zSp1Y9p+tktDYYSNflcxI0iyO4TPBdlRcpeqjK/piF5bklq77VSEaA+z8qmJTFzIWiitbnzR794USKBUaT0NTEsVjZqLaFVqJoPN9ODG70IPbfBHKK+/q/AWR0tJzYHRULOa4MP+W/HfGadZUbfw177G7j/OGbIs8TahLyynl4X4RinF793Oz+BU0saXtUHrVBFT/DnA3ctNPoGbs4hRIjTok8i+algT1lTHi4SxFvONKNrgQFAq2/gFnWMXgwffgYMJpiKYkmW3tTg3ZQ9Jq+f8XN+A5eeUKHWvJWJ2sgJ1Sop+wwhqFVijqWaJhwtD8MNlSBeWNNWTa5Z5kPZw5+LbVT99wqTdx29lMUH4OIG/D86ruKEauBjvH5xy6um/Sfj7ei6UUVk4AIl3MyD4MSSTOFgSwsH/QJWaQ5as7ZcmgBZkzjjU1UrQ74ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==);</li> <li>background-color: #0094d0;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533839954589360" rel="nofollow,noindex">Code Source</a></p> <h2>39、持久的列表排序</h2> <ol> <li>ol.chapters {</li> <li>list-style: none;</li> <li>margin-left: 0;</li> <li>}</li> <li> </li> <li>ol.chapters > li:before {</li> <li>content: counter(chapter) ". ";</li> <li>counter-increment: chapter;</li> <li>font-weight: bold;</li> <li>float: left;</li> <li>width: 40px;</li> <li>}</li> <li> </li> <li>ol.chapters li {</li> <li>clear: left;</li> <li>}</li> <li> </li> <li>ol.start {</li> <li>counter-reset: chapter;</li> <li>}</li> <li> </li> <li>ol.continue {</li> <li>counter-reset: chapter 11;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533840134495295" rel="nofollow,noindex">Code Source</a></p> <p>(PS: <a href="/misc/goto?guid=4958979767456438088" rel="nofollow,noindex">可参考content属性详解</a> )</p> <h2>50、CSS悬浮提示文本</h2> <ol> <li>a {</li> <li>border-bottom:1px solid #bbb;</li> <li>color:#666;</li> <li>display:inline-block;</li> <li>position:relative;</li> <li>text-decoration:none;</li> <li>}</li> <li>a:hover,</li> <li>a:focus {</li> <li>color:#36c;</li> <li>}</li> <li>a:active {</li> <li>top:1px;</li> <li>}</li> <li> </li> <li>/* Tooltip styling */</li> <li>a[data-tooltip]:after {</li> <li>border-top: 8px solid #222;</li> <li>border-top: 8px solid hsla(0,0%,0%,.85);</li> <li>border-left: 8px solid transparent;</li> <li>border-right: 8px solid transparent;</li> <li>content: "";</li> <li>display: none;</li> <li>height: 0;</li> <li>width: 0;</li> <li>left: 25%;</li> <li>position: absolute;</li> <li>}</li> <li>a[data-tooltip]:before {</li> <li>background: #222;</li> <li>background: hsla(0,0%,0%,.85);</li> <li>color: #f6f6f6;</li> <li>content: attr(data-tooltip);</li> <li>display: none;</li> <li>font-family: sans-serif;</li> <li>font-size: 14px;</li> <li>height: 32px;</li> <li>left: 0;</li> <li>line-height: 32px;</li> <li>padding: 0 15px;</li> <li>position: absolute;</li> <li>text-shadow: 0 1px 1px hsla(0,0%,0%,1);</li> <li>white-space: nowrap;</li> <li>-webkit-border-radius: 5px;</li> <li>-moz-border-radius: 5px;</li> <li>-o-border-radius: 5px;</li> <li>border-radius: 5px;</li> <li>}</li> <li>a[data-tooltip]:hover:after {</li> <li>display: block;</li> <li>top: -9px;</li> <li>}</li> <li>a[data-tooltip]:hover:before {</li> <li>display: block;</li> <li>top: -41px;</li> <li>}</li> <li>a[data-tooltip]:active:after {</li> <li>top: -10px;</li> <li>}</li> <li>a[data-tooltip]:active:before {</li> <li>top: -42px;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533840224388113" rel="nofollow,noindex">Code Source</a></p> <h2>51、深灰色的圆形按钮</h2> <ol> <li>.graybtn {</li> <li>-moz-box-shadow:inset 0px 1px 0px 0px #ffffff;</li> <li>-webkit-box-shadow:inset 0px 1px 0px 0px #ffffff;</li> <li>box-shadow:inset 0px 1px 0px 0px #ffffff;</li> <li>background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ffffff), color-stop(1, #d1d1d1) );</li> <li>background:-moz-linear-gradient( center top, #ffffff 5%, #d1d1d1 100% );</li> <li>filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#d1d1d1');</li> <li>background-color:#ffffff;</li> <li>-moz-border-radius:6px;</li> <li>-webkit-border-radius:6px;</li> <li>border-radius:6px;</li> <li>border:1px solid #dcdcdc;</li> <li>display:inline-block;</li> <li>color:#777777;</li> <li>font-family:arial;</li> <li>font-size:15px;</li> <li>font-weight:bold;</li> <li>padding:6px 24px;</li> <li>text-decoration:none;</li> <li>text-shadow:1px 1px 0px #ffffff;</li> <li>}</li> <li>.graybtn:hover {</li> <li>background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #d1d1d1), color-stop(1, #ffffff) );</li> <li>background:-moz-linear-gradient( center top, #d1d1d1 5%, #ffffff 100% );</li> <li>filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d1d1d1', endColorstr='#ffffff');</li> <li>background-color:#d1d1d1;</li> <li>}</li> <li>.graybtn:active {</li> <li>position:relative;</li> <li>top:1px;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533840313181784" rel="nofollow,noindex">Code Source</a></p> <h2>52、在可打印的网页中显示URLs</h2> <ol> <li>@media print {</li> <li>a:after {</li> <li>content: " [" attr(href) "] ";</li> <li>}</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533840408587948" rel="nofollow,noindex">Code Source</a></p> <h2>53、禁用移动Webkit的选择高亮</h2> <ol> <li>body {</li> <li>-webkit-touch-callout: none;</li> <li>-webkit-user-select: none;</li> <li>-khtml-user-select: none;</li> <li>-moz-user-select: none;</li> <li>-ms-user-select: none;</li> <li>user-select: none;</li> <li>}</li> </ol> <h2>54、CSS3 圆点图案</h2> <ol> <li>body {</li> <li>background: radial-gradient(circle, white 10%, transparent 10%),</li> <li>radial-gradient(circle, white 10%, black 10%) 50px 50px;</li> <li>background-size: 100px 100px;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533840501249159" rel="nofollow,noindex">Code Source</a></p> <h2>55、CSS3 方格图案</h2> <ol> <li>body {</li> <li>background-color: white;</li> <li>background-image: linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black),</li> <li>linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black);</li> <li>background-size: 100px 100px;</li> <li>background-position: 0 0, 50px 50px;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533840588253394" rel="nofollow,noindex">Code Source</a></p> <h2>56、Github的fork色带</h2> <ol> <li>.ribbon {</li> <li>background-color: #a00;</li> <li>overflow: hidden;</li> <li>/* top left corner */</li> <li>position: absolute;</li> <li>left: -3em;</li> <li>top: 2.5em;</li> <li>/* 45 deg ccw rotation */</li> <li>-moz-transform: rotate(-45deg);</li> <li>-webkit-transform: rotate(-45deg);</li> <li>/* shadow */</li> <li>-moz-box-shadow: 0 0 1em #888;</li> <li>-webkit-box-shadow: 0 0 1em #888;</li> <li>}</li> <li>.ribbon a {</li> <li>border: 1px solid #faa;</li> <li>color: #fff;</li> <li>display: block;</li> <li>font: bold 81.25% 'Helvetiva Neue', Helvetica, Arial, sans-serif;</li> <li>margin: 0.05em 0 0.075em 0;</li> <li>padding: 0.5em 3.5em;</li> <li>text-align: center;</li> <li>text-decoration: none;</li> <li>/* shadow */</li> <li>text-shadow: 0 0 0.5em #444;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533840673182778" rel="nofollow,noindex">Code Source</a></p> <h2>57、CSS font属性缩写</h2> <ol> <li>p {</li> <li>font: italic small-caps bold 1.2em/1.0em Arial, Tahoma, Helvetica;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533840768544546" rel="nofollow,noindex">Code Source</a></p> <h2>58、论文页面的卷曲效果</h2> <ol> <li>ul.box {</li> <li>position: relative;</li> <li>z-index: 1; /* prevent shadows falling behind containers with backgrounds */</li> <li>overflow: hidden;</li> <li>list-style: none;</li> <li>margin: 0;</li> <li>padding: 0;</li> <li>}</li> <li> </li> <li>ul.box li {</li> <li>position: relative;</li> <li>float: left;</li> <li>width: 250px;</li> <li>height: 150px;</li> <li>padding: 0;</li> <li>border: 1px solid #efefef;</li> <li>margin: 0 30px 30px 0;</li> <li>background: #fff;</li> <li>-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;</li> <li>-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;</li> <li>box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;</li> <li>}</li> <li> </li> <li>ul.box li:before,</li> <li>ul.box li:after {</li> <li>content: '';</li> <li>z-index: -1;</li> <li>position: absolute;</li> <li>left: 10px;</li> <li>bottom: 10px;</li> <li>width: 70%;</li> <li>max-width: 300px; /* avoid rotation causing ugly appearance at large container widths */</li> <li>max-height: 100px;</li> <li>height: 55%;</li> <li>-webkit-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);</li> <li>-moz-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);</li> <li>box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);</li> <li>-webkit-transform: skew(-15deg) rotate(-6deg);</li> <li>-moz-transform: skew(-15deg) rotate(-6deg);</li> <li>-ms-transform: skew(-15deg) rotate(-6deg);</li> <li>-o-transform: skew(-15deg) rotate(-6deg);</li> <li>transform: skew(-15deg) rotate(-6deg);</li> <li>}</li> <li> </li> <li>ul.box li:after {</li> <li>left: auto;</li> <li>right: 10px;</li> <li>-webkit-transform: skew(15deg) rotate(6deg);</li> <li>-moz-transform: skew(15deg) rotate(6deg);</li> <li>-ms-transform: skew(15deg) rotate(6deg);</li> <li>-o-transform: skew(15deg) rotate(6deg);</li> <li>transform: skew(15deg) rotate(6deg);</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533840859325082" rel="nofollow,noindex">Code Source</a></p> <h2>59、鲜艳的锚链接</h2> <ol> <li>a {</li> <li>color: #00e;</li> <li>}</li> <li>a:visited {</li> <li>color: #551a8b;</li> <li>}</li> <li>a:hover {</li> <li>color: #06e;</li> <li>}</li> <li>a:focus {</li> <li>outline: thin dotted;</li> <li>}</li> <li>a:hover, a:active {</li> <li>outline: 0;</li> <li>}</li> <li>a, a:visited, a:active {</li> <li>text-decoration: none;</li> <li>color: #fff;</li> <li>-webkit-transition: all .3s ease-in-out;</li> <li>}</li> <li>a:hover, .glow {</li> <li>color: #ff0;</li> <li>text-shadow: 0 0 10px #ff0;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533840968849532" rel="nofollow,noindex">Code Source</a></p> <h2>60、带CSS3特色的横幅显示</h2> <ol> <li>.featureBanner {</li> <li>position: relative;</li> <li>margin: 20px</li> <li>}</li> <li>.featureBanner:before {</li> <li>content: "Featured";</li> <li>position: absolute;</li> <li>top: 5px;</li> <li>left: -8px;</li> <li>padding-right: 10px;</li> <li>color: #232323;</li> <li>font-weight: bold;</li> <li>height: 0px;</li> <li>border: 15px solid #ffa200;</li> <li>border-right-color: transparent;</li> <li>line-height: 0px;</li> <li>box-shadow: -0px 5px 5px -5px #000;</li> <li>z-index: 1;</li> <li>}</li> <li> </li> <li>.featureBanner:after {</li> <li>content: "";</li> <li>position: absolute;</li> <li>top: 35px;</li> <li>left: -8px;</li> <li>border: 4px solid #89540c;</li> <li>border-left-color: transparent;</li> <li>border-bottom-color: transparent;</li> <li>}</li> </ol> <p><a href="/misc/goto?guid=4958533841050377431" rel="nofollow,noindex">Code Source</a></p> <p> </p> <p>来自:http://www.ido321.com/1565.html</p> <p> </p>
本文由用户 KelThornton 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!