1、用:before和:after实现小尖角效果

  1. <div class="div"></div>
  1. .div{
  2. background: #fff;
  3. border: 2px solid #000;
  4. height: 100px;
  5. width: 100px;
  6. position: relative;
  7. }
  8. .div:after,.div:before{
  9. border:0 solid transparent;
  10. position: absolute;
  11. top: 100%;
  12. content: '';
  13. }
  14. .div:before{
  15. border-width: 12px;
  16. border-top-color: #000;
  17. left: 38px;
  18. }
  19. .div:after{
  20. border-width: 10px;
  21. border-top-color: #fff;
  22. left: 40px;
  23. }

2、怎么只给盒子一侧加box-shadow

  1. <div class="box-shadow">一侧阴影</div>
  1. .box-shadow {
  2. position: absolute;
  3. top: 50%;
  4. left: 50px;
  5. width: 100px;
  6. height: 100px;
  7. background-color: #188eee;
  8. }
  9. .box-shadow:after {
  10. position: absolute;
  11. left: 10px;
  12. bottom:;
  13. width: 80px;
  14. height: 1px;
  15. display: block;
  16. z-index: -1;
  17. content: "";
  18. -webkit-box-shadow: 0px 0px 10px 5px #000;
  19. -moz-box-shadow: 0px 0px 10px 5px #000;
  20. box-shadow: 0px 0px 10px 5px #000;
  21. }

3、在不改变box-sizing的情况下,怎么使用text-indent和padding-left来缩进内容

  text-indent:首行缩进、不影响width(ie67下和inline-block使用有兼容性问题http://www.cnblogs.com/dothin/p/4979521.html

    用法:缩进,隐藏logo文字

  1. .logo{
  2. text-indent: -9999px;
  3. width: 300px;
  4. height: 100px;
  5. background: transparent url("imgs/logo.png") no-repeat;
  6. }

  padding-left:整体缩进,影响width

4、行溢出内容以省略号形式显示

  1. 单行:{width: px; overflow: hidden; text-overflow: ellipsis; white-space: nowarp;}
    鼠标移入显示:hover{ text-overflow: inherit; overflow: visible;}
    多行:{display:-webkit-box;display:box;overflow: hidden;text-overflow: ellipsis;-webkit-box-orient:vertical;-webkit-line-clamp:4;}

5、表格溢出省略号显示

  1. table{
  2. width:400px;
  3. border-collapse: collapse;
  4. table-layout: fixed;/*保持单元格的等宽*/
  5. }
  6. td{
  7. border: 1px solid #ccc;
  8.   white-space:nowrap;
  9. overflow:hidden;
  10. text-overflow:ellipsis;
  11. }

6、强制长英文单词换行

  1. word-wrap: break-word; /*不会切断单词*/
  2. word-break:break-all;/*要切断单词*/

7、用background-size:0 200%;给背景加渐变动画

  1. <div class="button">背景切换</div>
  1. .button {
  2. padding:10px 5px;
  3. border-radius: 4px;
  4. color: #fff;
  5. font: 16px sans-serif;
  6. width: 160px;
  7. text-align: center;
  8. background-image: linear-gradient(#155aaa, #188eee);
  9. background-size: auto 200%;
  10. background-position: 0 100%;
  11. -webkit-transition: background-position .3s;
  12. -o-transition: background-position .3s;
  13. transition: background-position .3s;
  14. }
  15. .button:hover {
  16. background-position: 0 0;
  17. }

8、我们可以用text-shadow给文本加阴影,那么你试过模糊文本吗

  1. .text {
  2. color: transparent;
  3. text-shadow: 0 0 5px rgba(0,0,0,0.5);
  4. }

9、强制显示页面滚动条

  1. html {
  2. height: 101%
  3. }

10、跨浏览器的min-height用法

  1. .container {
  2. min-height: 400px;
  3. height: auto !important;
  4. height: 400px;
  5. }

11、怎么给body顶部加固定阴影效果

  1. body:before {
  2. content: "";
  3. position: fixed;
  4. top: -10px;
  5. left:;
  6. width: 100%;
  7. height: 10px;
  8. -webkit-box-shadow: 0px 0px 10px rgba(0,0,0,.8);
  9. -moz-box-shadow: 0px 0px 10px rgba(0,0,0,.8);
  10. box-shadow: 0px 0px 10px rgba(0,0,0,.8);
  11. z-index:;
  12. }

12、活用:not来排除元素

  1. ie时代,要给一串li除了最后或者第一个以外都加border-rightborder-left),我们需要单独给最后一个或者第一个添加class才可以实现,
    现在是css3时代了,我们完全没必要这么做,仅仅只需要一个:not和一个:last-child或者:first-child
  2. li:not(:last-child){border-right:1px solid red;}瞬间心情舒畅~~

13、居中所有元素

  1. html, body {
  2. height: 100%;
  3. margin:;
  4. }
  5. body {
  6. -webkit-align-items: center;
  7. -ms-flex-align: center;
  8. align-items: center;
  9. display: -webkit-flex;
  10. display: flex;
  11. }
    其他居中方法:http://www.cnblogs.com/dothin/p/4971703.html

14、用负的 nth-child 选择元素1到元素n

  1. li {
  2. /*……*/
  3. }
  4. /* 选择从1到n的元素 */
  5. li:nth-child(-n+3) {
  6. /*……*/
  7. }

15、清除浮动的常见做法有哪些

1)加高度(但是扩张性不好)

2)父级浮动(不固定宽度的情况下,宽度会变为自适应内容)

3)display:inline-block 清浮动方法(不固定宽度的情况下,宽度会变为自适应内容)

4):after伪类 清浮动方法(主流方法)

  .clear:after{content:'';display:block;clear:both;}

  .clear{zoom:1;}

5)overflow:hidden 清浮动方法(不允许溢出内容,在需要有溢出的时候这种方法不可行

6)position:absolute、fixed 清浮动。(不固定宽度的情况下,宽度会变为自适应内容,还可以使内联元素支持宽高)

所以以下内容不需要清浮动:

绝对定位或固定定位元素、浮动元素、固定高度的元素、添加了overflow溢出隐藏的元素

16、给元素加360翻转效果

  1. .product li img {
  2. height:270px;
  3. width:200px;
  4. -webkit-transform: rotateY(360deg);
  5. -ms-transform: rotateY(360deg);
  6. transform: rotateY(360deg);
  7. -webkit-transition:-webkit-transform 1s;
  8. -ms-transition:-ms-transform 1s;
  9. transition:transform 1s;
  10. }
  11. .product li:hover img {
  12. -webkit-transform: rotateY(0);
  13. -ms-transform: rotateY(0);
  14. transform: rotateY(0);
  15. }
    /*要使鼠标移出也翻转,所以transition写在前面*/

17、css3外阴影输入框

  1. input[type=text], textarea {
  2. -webkit-transition: all 0.30s ease-in-out;
  3. -moz-transition: all 0.30s ease-in-out;
  4. -ms-transition: all 0.30s ease-in-out;
  5. -o-transition: all 0.30s ease-in-out;
  6. outline: none;
  7. padding: 3px 0px 3px 3px;
  8. margin: 5px 1px 3px 0px;
  9. border: 1px solid #ddd;
  10. }
  11.  
  12. input[type=text]:focus, textarea:focus {
  13. box-shadow: 0 0 5px rgba(81, 203, 238, 1);
  14. padding: 3px 0px 3px 3px;
  15. margin: 5px 1px 3px 0px;
  16. border: 1px solid rgba(81, 203, 238, 1);
  17. }

18、网页变灰

  1. html {
  2. -webkit-filter: grayscale(100%);
  3. -moz-filter: grayscale(100%);
  4. -ms-filter: grayscale(100%);
  5. -o-filter: grayscale(100%);
  6. filter: grayscale(100%);
  7.  filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
  8. -webkit-filter: grayscale(1);
  9. }

19、修改chrome记住密码后自动填充表单的黄色背景

  1. input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill {
  2. background-color: rgb(250, 255, 189); /* #FAFFBD; */
  3. background-image: none;
  4. color: rgb(0, 0, 0);
  5. }

  

一些css小用法总结(持续更新~)的更多相关文章

  1. C#、Java中的一些小知识点总结(持续更新......)

    前言:在项目中,有时候一些小的知识,总是容易让人忽略,但是这些功能加在项目中往往十分的有用,因此笔者在这里总结项目中遇到的一些实用的小知识点,以备用,并持续更新...... 1.禁用DataGridV ...

  2. HTML+CSS - 前端设计的小技巧(持续更新......)

    2015年7月6日20:28:20 1.设置文字的居中,非控件内的. :text-alain:center 2.图片在ASP.NET中,可以直接拖放到界面,自动形成img控件. 3.CSS直接在全局样 ...

  3. html+css常用小笔记(持续更新)

    1 去掉input点击时的蓝色边框 outline:none; 2 禁止文本选中 -webkit-touch-callout: none; /* iOS Safari */ -webkit-user- ...

  4. CSS用法总结(持续更新)

    一.html,body{height:100%} 解决了容器高度不足(容器高度由子元素高度决定,而%按照父元素的百分比),无法用%布局页面的问题 把html和body的高度设置为浏览器高度,此时会出现 ...

  5. 【小摘抄】关于C++11下 string各类用法(持续更新)

    http://blog.csdn.net/autocyz/article/details/42391155 提供了最简单的详解 下列对本人近期开发中的一些心得体会进行摘抄 1.string按照字符进行 ...

  6. css用法(持续更新ing)

    *:选择所有节点 #container:选取id为container的节点 .container:选取所有class包含container的节点 li a:选取li下的所有a节点 ul +p:选取ul ...

  7. 基于Taro与typescript开发的网易云音乐小程序(持续更新)

    基于Taro与网易云音乐api开发,技术栈主要是:typescript+taro+taro-ui+redux,目前主要是着重小程序端的展示,主要也是借此项目强化下上述几个技术栈的使用,通过这个项目也可 ...

  8. iOS 小知识点(持续更新)

    1.如何通过代码设置Button  title的字体大小 设置Button.titleLabel.font = [UIFont systemFontOfSize:<#(CGFloat)#> ...

  9. 我的CSS布局之旅--持续更新

    虽然我也接触前端一年之久了,但是无奈从切图布局下来的经验还真是很不足,因为之前比赛或者是做小项目时全部都是自己负责设计,所以都是编写边设计,哎呀,也是醉了:或者是有模板,然后从人家上面扒拉下来的,真的 ...

随机推荐

  1. DevOps - Development And Operations

    简介: 研发运维一体化 相关资料: 关于DevOps你必须知道的11件事 我眼中的DevOps DevOps 门户 docker for dotnet系列 docker4dotnet #1 前世今生 ...

  2. nutch,hbase,zookeeper兼容性问题

    nutch-2.1使用gora-0.2.1, gora-0.2.1使用hbase-0.90.4,hbase-0.90.4和hadoop-1.1.1不兼容,hbase-0.94.4和gora-0.2.1 ...

  3. BZOJ 1143 祭祀

    Description 在遥远的东方,有一个神秘的民族,自称Y族.他们世代居住在水面上,奉龙王为神.每逢重大庆典, Y族都会在水面上举办盛大的祭祀活动.我们可以把Y族居住地水系看成一个由岔口和河道组成 ...

  4. Squares<哈希>

    Description A square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-d ...

  5. Maven实战一

    转载:http://www.iteye.com/topic/1123221 1. 用Maven 命令创建一个简单的Maven项目 在cmd中运行如下命令: Cmd代码 mvn archetype:ge ...

  6. width:auto; 和 width:100%;的不同

    width:auto:会将元素撑开至整个父元素width,但是会减去子节点自己的margin,padding或者border的大小.width:100%:会强制将元素变成和父元素一样的宽,并且添加额外 ...

  7. Linux Kernel ‘kvm_set_memory_region()’函数本地提权漏洞

    漏洞名称: Linux Kernel ‘kvm_set_memory_region()’函数本地提权漏洞 CNNVD编号: CNNVD-201306-343 发布时间: 2013-06-20 更新时间 ...

  8. 【转】BLE 学习记录

    原文网址:http://m.blog.csdn.net/blog/chiooo/43985401 BLE 学习记录 ANROID BLE 开发,基于 bluetoothlegatt 分析 mBluet ...

  9. 网络流(最大密集度子图,分数规划):UvaLive 3709 Hard Life

    John is a Chief Executive Officer at a privately owned medium size company. The owner of the company ...

  10. sed替换文件中的字符串

    sed -i 's/原字符串/替换字符串/g' filename