温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

css常用技巧是什么

发布时间:2022-02-28 15:11:32 来源:亿速云 阅读:78 作者:小新 栏目:web开发

小编给大家分享一下css常用技巧是什么,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

1、三角形列表项目符号

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

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

3、内部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;}

4、CSS3 斑马线

tbody tr:nth-child(odd) { background-color: #ccc;}

5、强制出现垂直滚动条

html { height: 101% }

6、内容垂直居中

.container { min-height: 6.5em; display: table-cell; vertical-align: middle;}

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

8、锚链接伪类

a:link { color: blue; }a:visited { color: purple; }a:hover { color: red; }a:active { color: yellow; }

9、为logo隐藏H1

h2
 { text-indent: -9999px; margin: 0 auto; width: 320px; height: 85px; 
background: transparent url("images/logo.png") no-repeat scroll;}

10、自定义文本选择

::selection { background: #e2eae2; }::-moz-selection { background: #e2eae2; }::-webkit-selection { background: #e2eae2; }

11、跨浏览器的透明

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

12、新版清除浮动(2011)

.clearfix:before,
 .container:after { content: ""; display: table; }.clearfix:after { 
clear: both; }/* IE 6/7 */.clearfix { zoom: 1; }

13、典型的CSS清除浮动

.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%;
 }

14、制造模糊文本

想要让文本模糊?可以使用color透明和text-shadow实现

.blurry-text { color: transparent; text-shadow: 0 0 5px rgba(0,0,0,0.5);}

15、CSS:表格列宽自适用

对于表格,当谈到调整列宽时,是比较痛苦的。然后,这里有一个可以使用的技巧:给td元素添加white-space: nowrap;能让文本正确的换行

td { white-space: nowrap;}

以上是“css常用技巧是什么”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

css
AI