CSS3教程

当前位置: HTML5技术网 > CSS3教程 > 每位设计师都应该拥有的50个CSS代码片段

每位设计师都应该拥有的50个CSS代码片段

英文原文:50 Useful CSS Snippets Every Designer Should Have
         面对每年如此多的 新趋势 ,保持行业的领先是个很困难问题. 网站设计者和前端工程师都已经全面的使用 CSS3 properties, 决定这些的是 浏览器支持 和新的特性. 但是还是有些优秀的CSS2代码片段和CSS3一起运行中.
      这篇文字里我会介绍 50 个便于使用的 CSS2/CSS3 代码片段 给所有的WEB专业人员. 选择IDE开发环境来存储这些是个不错选择, 或者仅仅是把它们保存为一个小小的CSS文件. 不管那种方式我肯定设计者和开发者都会发现他们之中一些有用的.
1. CSS 重置
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 {  margin: 0;  padding: 0;  border: 0;  font-size: 100%;  font: inherit;  vertical-align: baseline;  outline: none;  -webkit-box-sizing: border-box;  -moz-box-sizing: border-box;  box-sizing: border-box;}html { height: 101%; }body { font-size: 62.5%; line-height: 1; font-family: Arial, Tahoma, sans-serif; }
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; }ol, ul { list-style: none; }
blockquote, q { quotes: none; }blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; }strong { font-weight: bold; } 
table { border-collapse: collapse; border-spacing: 0; }img { border: 0; max-width: 100%; }
p { font-size: 1.2em; line-height: 1.0em; color: #333; }
       基本的CSS重置是网络上最常见的代码片段. 这是我自己定制的重置代码,它基于 Eric Meyer’s reset codes。里面有一些图片的设定以及为所有的核心元素定义边框, 保持适当的marings 和 padding.
2. 经典的 CSS Clearfix
.clearfix:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; }.clearfix { display: inline-block; } html[xmlns] .clearfix { display: block; }* html .clearfix { height: 1%; }
         这个clearfix代码被很多聪明的开发者用于网站. 它应用于一个用于保存浮动元素的盒子模型上. 这将确保里面的任何内容都以拉伸方式出现而不是浮动出现.
3. 2011 更新的 Clearfix.clearfix:before, .container:after { content: ""; display: table; }.clearfix:after { clear: both; }
/* IE 6/7 */.clearfix { zoom: 1; }
     这里就不说这个新版本和经典版本之间的主要差差异了. 它们两个都可以有效的清除你的浮动元素, 而且都支持流行的浏览器甚至是Internet Explorer 6-8.
4. 跨浏览器的透明度
.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 */}
Code Source
       一些新的CSS3属性我们可能认为它适用于任何地方. 实际上不行,我们还得稍微调整下,透明度就是个例子. 加上这个filter属性来保证它能在IE游览器里正常运行.
5. CSS 块引用模版
blockquote {    background: #f9f9f9;    border-left: 10px solid #ccc;    margin: 1.5em 10px;    padding: .5em 10px;    quotes: "\201C""\201D""\2018""\2019";}blockquote:before {    color: #ccc;    content: open-quote;    font-size: 4em;    line-height: .1em;    margin-right: .25em;    vertical-align: -.4em;}blockquote p {    display: inline;}
Code Source
        不是所有的人都必须在他们的网站上使用blockquotes. 但是我认为这是一个很好的元素用于分离引用或是优化博客和网页上的重复内容. 上面的代码为你的blockquotes提供一个默认样式,这样你的内容就不会看起来单调乏味.
6. 个性的圆角
#container {    -webkit-border-radius: 4px 3px 6px 10px;    -moz-border-radius: 4px 3px 6px 10px;    -o-border-radius: 4px 3px 6px 10px;    border-radius: 4px 3px 6px 10px;}
/* alternative syntax broken into each line */#container {    -webkit-border-top-left-radius: 4px;    -webkit-border-top-right-radius: 3px;    -webkit-border-bottom-right-radius: 6px;    -webkit-border-bottom-left-radius: 10px;        -moz-border-radius-topleft: 4px;    -moz-border-radius-topright: 3px;    -moz-border-radius-bottomright: 6px;    -moz-border-radius-bottomleft: 10px;}
       大多数开发者都熟悉CSS3的圆角属性. 但是你知道如何为每个角设定不同的值吗? 上面的代码帮你搞定这个问题! 上面的两个版本都为你实现了这个效果,仔细研究下吧.
7.一般媒体查询
/* 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 */}
Code Source
        这是一个很棒的模版,你能在CSS-Tricks找到其它零碎的媒体查询。不管怎样我已经把他们的例子全拷下来了,那里面包括了成吨的实际的移动设备。这些代码甚至能针对视网膜屏设备,使用最小设备像素比例。
8. 现代字体栈
/* Times New Roman-based serif */font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;
/* A modern Georgia-based serif */font-family: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif," "Bitstream Vera Serif", "Liberation Serif", Georgia, serif;
/*A more traditional Garamond-based serif */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;
/*The Helvetica/Arial-based sans serif */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;
/*The Verdana-based sans serif */font-family: Corbel, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", "Bitstream Vera Sans", "Liberation Sans", Verdana, "Verdana Ref", sans-serif;
/*The Trebuchet-based sans serif */font-family: "Segoe UI", Candara, "Bitstream Vera Sans", "DejaVu Sans", "Bitstream Vera Sans", "Trebuchet MS", Verdana, "Verdana Ref", sans-serif;
/*The heavier "Impact" sans serif */font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", Charcoal, "Helvetica Inserat", "Bitstream Vera Sans Bold", "Arial Black", sans-serif;
/*The monospace */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;
Code Source
       你很难为设计一个新的页面头脑风暴式的想出自己的CSS字体栈。我希望这一小片代码能减轻一些折磨,并给你一些可以着手开始的模版。如果你想找更多的例子,查看一下CSS 字体栈 ,这是我最喜欢的资源之一。
9. 自定义文本选择
::selection { background: #e2eae2; }::-moz-selection { background: #e2eae2; }::-webkit-selection { background: #e2eae2; }
       一些新式的浏览器会允许你定义页面中的高亮颜色。默认这是设为淡蓝色的,但你可以设置任何投你所好的颜色值,这小片代码包括了典型的::selection目标以及专为Webkit和Mozilla的特定前缀。
10.隐藏H1文本为Logo标志
h1 {    text-indent: -9999px;    margin: 0 auto;    width: 320px;    height: 85px;    background: transparent url("images/logo.png") no-repeat scroll;}
       我第一次注意到这个技术实现是在古老的Digg 布局 。为了SEO的目的,你也可以设置一个包含有你的站点名称的H1标签。但使用CSS我们能移走这个文本使它不可见,并用一个客制化的logo图片替换它。
11. polaroid图像边界
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*/}
Code Source
       应用这个基础的片段将使你能在你的图像上实现.polaroid 类。这将会创建老照片风格效果,带一个很宽的白边和一些淡淡的阴影。你要更新宽/高数值,以便和你的图片尺寸和网站布局相匹配。
12. 锚链接伪类
a:link { color: blue; }a:visited { color: purple; }a:hover { color: red; }a:active { color: yellow; }
Code Source
      大多数CSS开发者知道锚链接类和:hover效果。但是我想引入这小段代码给新手做个参考。这些是一个锚链接和一些其他HTML元素的四个默认状态。把它们留在手边,直到你可以记住一些更复杂的情况。
13. 花式CSS3 Pull-引文
.has-pullquote:before { /* Reset metrics. */ padding: 0; border: none; /* Content */ content: attr(data-pullquote); /* Pull out to the right, modular scale based margins. */ float: right; width: 320px; margin: 12px -140px 24px 36px; /* Baseline correction */ position: relative; top: 5px; /* Typography (30px line-height equals 25% incremental leading) */ font-size: 23px; line-height: 30px;}
.pullquote-adelle:before { font-family: "adelle-1", "adelle-2"; font-weight: 100; top: 10px !important;}
.pullquote-helvetica:before { font-family: "Helvetica Neue", Arial, sans-serif; font-weight: bold; top: 7px !important;}
.pullquote-facit:before { font-family: "facitweb-1", "facitweb-2", Helvetica, Arial, sans-serif; font-weight: bold; top: 7px !important;}
Code Source
       Pull-引文(Pull-quotes)与块引用(blockquotes)不同,它们出现在你的博客或者新闻文章的一边。这些引文经常从文章中引用文本,所以它们和块引用显示的稍许不一样。这些默认类具有一些基础的属性,带有3个可供选择的独特的字体类型。
14.全屏背景和CSS3
html {     background: url('images/bg.jpg') no-repeat center center fixed;     -webkit-background-size: cover;    -moz-background-size: cover;    -o-background-size: cover;    background-size: cover;}
Code Source
       我应该标注一下这个代码在不支持CSS3语法的老式浏览器中不会正确的工作。然而如果你是在寻找一个不需要关心遗留系统支持的快速的解决方案,这是你能找到的最好的代码段!给你网站背景增加很大的照片同时又能使它们能在你滚动的时候保持可变尺寸和固定不动。
15. 垂直居中内容
.container {    min-height: 6.5em;    display: table-cell;    vertical-align: middle;}
Code Source
      使用 margin: 0 auto 技术,很容易就能使内嵌的内容位于你页面的水平正中。然而对垂直的文本要困难的多,尤其是考虑到滚动条和其它的方式。但这个是无需JavaScript就能完美无瑕工作的纯CSS解决方案。
16.强制垂直滚动条
html { height: 101% }
      如果你的页面内容不能填满你的浏览器窗口整个高度,那么你不会焦灼于获取滚动条。但是改变大小将会强制它们出现,并给你的窗口宽度增加额外的10-15像素,推走你的页面内容。这个代码段将保证你的HTML元素总是比浏览器高一点点,强制滚动条一直停留在适当位置。
17. CSS3梯度模板
#colorbox {    background: #629721;    background-image: -webkit-gradient(linear, left top, left bottom, from(#83b842), to(#629721));    background-image: -webkit-linear-gradient(top, #83b842, #629721);    background-image: -moz-linear-gradient(top, #83b842, #629721);    background-image: -ms-linear-gradient(top, #83b842, #629721);    background-image: -o-linear-gradient(top, #83b842, #629721);    background-image: linear-gradient(top, #83b842, #629721);}
       CSS3梯度是新技术参数的另一个奇妙的部分。许多特定前缀难以记忆,所以这个代码片段将能为你每个项目节省一点时间。
18. @font-face模版
@font-face {    font-family: 'MyWebFont';    src: url('webfont.eot'); /* IE9 Compat Modes */    src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */    url('webfont.woff') format('woff'), /* Modern Browsers */    url('webfont.ttf')  format('truetype'), /* Safari, Android, iOS */    url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */} body {    font-family: 'MyWebFont', Arial, sans-serif;}
Code Source
       这是另一些不是很容易记的CSS3代码。使用@font-face你可以给你的网站嵌入自己的TTF/OTF/SVG/WOFF文件,生成自定义的字体类型。为你未来的项目,将这个模版作为一个基本的例子。
19. 完整定义CSS3元素
p {    position:relative;    z-index:1;    padding: 10px;    margin: 10px;    font-size: 21px;    line-height: 1.3em;    color: #fff;    background: #ff0030;    -webkit-box-shadow: 0 0 0 4px #ff0030, 2px 1px 4px 4px rgba(10,10,0,.5);    -moz-box-shadow: 0 0 0 4px #ff0030, 2px 1px 4px 4px rgba(10,10,0,.5);    box-shadow: 0 0 0 4px #ff0030, 2px 1px 6px 4px rgba(10,10,0,.5);    -webkit-border-radius: 3px;    -moz-border-radius: 3px;    border-radius: 3px;}
p:before {    content: "";    position: absolute;    z-index: -1;    top: 3px;    bottom: 3px;    left :3px;    right: 3px;    border: 2px dashed #fff;}
p a {    color: #fff;    text-decoration:none;}
p a:hover, p a:focus, p a:active {    text-decoration:underline;}

Code Source20. CSS3 斑马条纹

tbody tr:nth-child(odd) {    background-color: #ccc;}
Code Source
       这个项目最好的应用是在数据列表上. 为40或50行的表来定义是很费劲的事情. 通过添加上面的CSS3条纹属性可以方便的为奇数行添上背景色.
21. 字符美化
.amp {    font-family: Baskerville, 'Goudy Old Style', Palatino, 'Book Antiqua', serif;    font-style: italic;    font-weight: normal;}
Code Source
       这个css类用在页面内容中围绕文字的span元素. 它会将一些典型的serif 字体用斜体形式显示.测试下看看是不是你喜欢的风格吧.
22. 段落首字母
p:first-letter{    display: block;    margin: 5px 0 0 5px;    float: left;    color: #ff3366;    font-size: 5.4em;    font-family: Georgia, Times New Roman, serif;}
       在报纸和图片上你一定看到过它们的首字母的特殊效果. 对于有足够版面的网页或博客来说肯定会受其影响. 上面的CSS规则定义了所有的P标签,你也可以把它们定义为一个class或是ID.
23. CSS3盒子模型内部阴影
#mydiv {     -moz-box-shadow: inset 2px 0 4px #000;    -webkit-box-shadow: inset 2px 0 4px #000;    box-shadow: inset 2px 0 4px #000;}
       阴影为我们的网站提供了巨大的变化. 你几乎可以所有的元素定义这个属性, 看起来都非常不错. 上面的代码定义了内阴影,对设计来说很丑,但在一定的环境下还是很好的.
24. CSS3盒子模型外部阴影
#mydiv {     -webkit-box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52);    -moz-box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52);    box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52);}
与CSS3内阴影一样,我也提供一段外阴影的代码. 注意第三个数字表示模糊距离,第四个表示范围. 了解更多从W3Schools.
25. 三角形列表前缀
ul {    margin: 0.75em 0;    padding: 0 1em;    list-style: none;}li:before {     content: "";    border-color: transparent #111;    border-style: solid;    border-width: 0.35em 0 0.35em 0.45em;    display: block;    height: 0;    width: 0;    left: -1em;    top: 0.9em;    position: relative;}
Code Source
      不管你信不信,反正我是信了.在CSS3中三角形的列表前缀是可能的. 这个看起来太酷了,可惜的是不是所有的浏览器都支持.
26. 固定宽度的居中布局
#page-wrap {    width: 800px;    margin: 0 auto;}
Code Source
我知道之前已经提到过怎样设置水平居中.在这里的代码是完美实现固定宽度的水平居中 .
27. CSS3 文本分列
#columns-3 {    text-align: justify;    -moz-column-count: 3;    -moz-column-gap: 12px;    -moz-column-rule: 1px solid #c4c8cc;    -webkit-column-count: 3;    -webkit-column-gap: 12px;    -webkit-column-rule: 1px solid #c4c8cc;}
Code Source
      CSS3分列在网站上看起来会非常不错, 现实的问题是我们如何把基于文本的内容分列显示. 通过上面的代码,为你的文本段落设置其中的列的数值,文本内容将会按你设定的值分成宽度相同的列.
28. CSS 固定的页脚
#footer {    position: fixed;    left: 0px;    bottom: 0px;    height: 30px;    width: 100%;    background: #444;} /* IE 6 */* html #footer {    position: absolute;    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');}
Code Source
      这个实际用起来比听起来要有用的多, 为你的网站添加一个固定页脚是很简单的. 这些页脚不管页面如何滚动都是固定的,你可以包含一些帮助信息或是联系方式等等. 完美的为用户界面增加价值.
29. PNG 图片在 IE6下的透明度
.bg {    width:200px;    height:100px;    background: url(/folder/yourimage.png) no-repeat;    _background:none;    _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/folder/yourimage.png',sizingMethod='crop');}

/* 1px gif method */img, .png {    position: relative;    behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none",       this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')",       this.src = "images/transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''),       this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')",       this.runtimeStyle.backgroundImage = "none")),this.pngSet=true));}
Code Source
       使用透明图片已经变成网站的最基本的实践. 开始的时候是gif图,现在都使用PNG透明图. 不幸的是一些IE老版的浏览器不支持这个透明度属性. 添加上上面的代码就能搞定这个问题.
30. 跨浏览器的最小高度
#container {    min-height: 550px;    height: auto !important;    height: 550px;}

      不得不使用min-height的开发者知道都是那些浏览器支持这个属性. 很多新的游览器都支持这个属性, 然而Internet Explorer 和 老版本的 Firefox对这个支持有问题. 上面的代码能解决这个Bug.
31. CSS3发光输入框
input[type=text], textarea {    -webkit-transition: all 0.30s ease-in-out;    -moz-transition: all 0.30s ease-in-out;    -ms-transition: all 0.30s ease-in-out;    -o-transition: all 0.30s ease-in-out;    outline: none;    padding: 3px 0px 3px 3px;    margin: 5px 1px 3px 0px;    border: 1px solid #ddd;} input[type=text]:focus, textarea:focus {    box-shadow: 0 0 5px rgba(81, 203, 238, 1);    padding: 3px 0px 3px 3px;    margin: 5px 1px 3px 0px;    border: 1px solid rgba(81, 203, 238, 1);}
Code Source
       我真的喜欢这个基础的自定义CSS3类,这是因为它覆盖默认浏览器行为的方式。我所知道的Chrome & Safar用户对表单里的输入框轮廓很反感。将这些属性加到你的样式表,会给基本的输入框元素设置一个全新的设计。
32. 基于文件类型的链接样式
/* external links */a[href^="http://"] {    padding-right: 13px;    background: url('external.gif') no-repeat center right;} /* emails */a[href^="mailto:"] {    padding-right: 20px;    background: url('email.png') no-repeat center right;} /* pdfs */a[href$=".pdf"] {    padding-right: 18px;    background: url('acrobat.png') no-repeat center right;}
Code Source
       相当晦涩的一段CSS代码,但我喜欢它的创造力!你可以决定使用CSS选择器的链接的文件类型,并以图标作为背景图片。这些可以包含不同的协议(HTTP, FTP, IRC, mailto)或简单的只是它们自己的文件类型(mp3, avi, pdf)。
33. 强制代码包装
pre {    white-space: pre-wrap;       /* css-3 */    white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */    white-space: -pre-wrap;      /* Opera 4-6 */    white-space: -o-pre-wrap;    /* Opera 7 */    word-wrap: break-word;       /* Internet Explorer 5.5+ */}
Code Source
       典型的pre标签是在布局中用来显示大块代码的。这是预编排的文本,就像你在Notepad或Textedit发现的那样,除非你经常看的是引起水平滚动条的一长段文字。这段CSS代码将强制所有pre标签为封装代码格式,不会跑到容器外面去。
34.强制可点击条目上显示手型光标
a[href], input[type='submit'], input[type='image'], label[for], select, button, .pointer {    cursor: pointer;}
Code Source
      有许多默认的可点击HTML元素并不总是显示手型的指针图标。使用这个CSS选择器设置,你可以对许多关键的元素以及任何使用 .pointer类的其它对象,强制指定指针的形状。
35. 网页顶端阴影
body:before {    content: "";    position: fixed;    top: -10px;    left: 0;    width: 100%;    height: 10px;
    -webkit-box-shadow: 0px 0px 10px rgba(0,0,0,.8);    -moz-box-shadow: 0px 0px 10px rgba(0,0,0,.8);    box-shadow: 0px 0px 10px rgba(0,0,0,.8);    z-index: 100;}
Code Source
      除了一些令人愉悦的美感,开发者可能找不到它会有多大用处。但我确实享受这个效果,而且显然它是独一无二的!只需将这个CSS 代码附加到你的body元素,就能从你的页面顶部往下显示一个渐渐消退的阴影。
36. CSS3 对话气泡
.chat-bubble {    background-color: #ededed;    border: 2px solid #666;    font-size: 35px;    line-height: 1.3em;    margin: 10px auto;    padding: 10px;    position: relative;    text-align: center;    width: 300px;    -moz-border-radius: 20px;    -webkit-border-radius: 20px;    -moz-box-shadow: 0 0 5px #888;    -webkit-box-shadow: 0 0 5px #888;    font-family: 'Bangers', arial, serif; }.chat-bubble-arrow-border {    border-color: #666 transparent transparent transparent;    border-style: solid;    border-width: 20px;    height: 0;    width: 0;    position: absolute;    bottom: -42px;    left: 30px;}.chat-bubble-arrow {    border-color: #ededed transparent transparent transparent;    border-style: solid;    border-width: 20px;    height: 0;    width: 0;    position: absolute;    bottom: -39px;    left: 30px;}
Code Source       每当讨论到对话气泡时,无数的用户界面用途就会浮现出来。这些可以用于处理讨论评述,或者创建公告版,或者显示引用文本。只需将下面的类加入你的样式表,你也可以从这贴 CSS3代码片段  找到相关的HTML代码。

【每位设计师都应该拥有的50个CSS代码片段】相关文章

1. 每位设计师都应该拥有的50个CSS代码片段

2. 分享10个超实用的jQuery代码片段

3. 在网站制作中随时可用的10个 HTML5 代码片段

4. 绝对应当收藏的10个实用HTML5代码片段

5. 可以直接拿来用的15个jQuery代码片段

6. 15 个响应式的 jQuery UI 组件的代码片段和模块

7. 分享5个最棒的代码片段资源网站

8. 使用 GistBox 轻松组织和管理你的代码片段

9. 用于响应式设计的9个CSS技巧

10. Web开发者和设计师必备的20个在线实用工具

本文来源:https://www.51html5.com/a966.html

点击展开全部

﹝每位设计师都应该拥有的50个CSS代码片段﹞相关内容

「每位设计师都应该拥有的50个CSS代码片段」相关专题

其它栏目

也许您还喜欢