分享

10个css常用技巧

 太极混元天尊 2018-06-16

10个css常用技巧

1、H1-H5默认样式

h1,h2,h3,h4,h5{ color: #005a9c;}h1{ font-size: 2.6em; line-height: 2.45em;}h2{ font-size: 2.1em; line-height: 1.9em;}h3{ font-size: 1.8em; line-height: 1.65em;}h4{ font-size: 1.65em; line-height: 1.4em;}h5{ font-size: 1.4em; line-height: 1.25em;}

2、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;}

3、在可点击的项目上强制手型

a[href], input[type='submit'], input[type='image'], label[for], select, button, .pointer { cursor: pointer;}

4、强制换行

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+ */}

5、基于文件类型的链接样式

/* 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;}

6、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);}

7、跨浏览器设置最小高度

#container { min-height: 550px; height: auto !important; height: 550px;}

8、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');}

9、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;}

10、固定宽度的居中布局

#page-wrap { width: 800px; margin: 0 auto;}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多