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

<div class="div"></div>
.div{
background: #fff;
border: 2px solid #000;
height: 100px;
width: 100px;
position: relative;
}
.div:after,.div:before{
border:0 solid transparent;
position: absolute;
top: 100%;
content: '';
}
.div:before{
border-width: 12px;
border-top-color: #000;
left: 38px;
}
.div:after{
border-width: 10px;
border-top-color: #fff;
left: 40px;
}

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

<div class="box-shadow">一侧阴影</div>
.box-shadow {
position: absolute;
top: 50%;
left: 50px;
width: 100px;
height: 100px;
background-color: #188eee;
}
.box-shadow:after {
position: absolute;
left: 10px;
bottom:;
width: 80px;
height: 1px;
display: block;
z-index: -1;
content: "";
-webkit-box-shadow: 0px 0px 10px 5px #000;
-moz-box-shadow: 0px 0px 10px 5px #000;
box-shadow: 0px 0px 10px 5px #000;
}

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

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

    用法:缩进,隐藏logo文字

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

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

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

单行:{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、表格溢出省略号显示

table{
width:400px;
border-collapse: collapse;
table-layout: fixed;/*保持单元格的等宽*/
}
td{
border: 1px solid #ccc;
  white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}

6、强制长英文单词换行

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

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

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

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

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

9、强制显示页面滚动条

html {
height: 101%
}

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

.container {
min-height: 400px;
height: auto !important;
height: 400px;
}

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

body:before {
content: "";
position: fixed;
top: -10px;
left:;
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:;
}

12、活用:not来排除元素

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

13、居中所有元素

html, body {
height: 100%;
margin:;
}
body {
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
display: -webkit-flex;
display: flex;
}
其他居中方法:http://www.cnblogs.com/dothin/p/4971703.html

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

li {
/*……*/
}
/* 选择从1到n的元素 */
li:nth-child(-n+3) {
/*……*/
}

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翻转效果

.product li img {
height:270px;
width:200px;
-webkit-transform: rotateY(360deg);
-ms-transform: rotateY(360deg);
transform: rotateY(360deg);
-webkit-transition:-webkit-transform 1s;
-ms-transition:-ms-transform 1s;
transition:transform 1s;
}
.product li:hover img {
-webkit-transform: rotateY(0);
-ms-transform: rotateY(0);
transform: rotateY(0);
}
/*要使鼠标移出也翻转,所以transition写在前面*/

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

18、网页变灰

html {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
 filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
-webkit-filter: grayscale(1);
}

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

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

  

一些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. 通过GetManifestResourceStream加载文件出现错误提示“null值”对于“stream”无效[转]

    本文解决了我的问题,收藏一下. 原文地址:http://blog.sina.com.cn/s/blog_a67799f601010atz.html 在做Mobile开发时,需要引入图片,用到了这个方法 ...

  2. 如何从BBC网站学习英语

  3. myeclipse spket spket-1.6.23.jar 破解安装教程

    一年前安装文档就写过了,今天写破解文档,本来开发js/ext是想用aptana的,但是安装包100多M,我还是用spket吧(才11M),这个需要破解一下license,否则用不了. 一 安装教程如下 ...

  4. 使用 InstallShield limited edition 打包部署Outlook 2013 Office add-in插件

    原文: Outlook: Deploying an Outlook 2013 add-in (using InstallShield LE) Today I had to create an inst ...

  5. Nodejs爬虫进阶教程之异步并发控制

    Nodejs爬虫进阶教程之异步并发控制 之前写了个现在看来很不完美的小爬虫,很多地方没有处理好,比如说在知乎点开一个问题的时候,它的所有回答并不是全部加载好了的,当你拉到回答的尾部时,点击加载更多,回 ...

  6. 基于Node.js的强大爬虫 能直接发布抓取的文章哦

    基于Node.js的强大爬虫 能直接发布抓取的文章哦 基于Node.js的强大爬虫能直接发布抓取的文章哦!本爬虫源码基于WTFPL协议,感兴趣的小伙伴们可以参考一下 一.环境配置 1)搞一台服务器,什 ...

  7. WordPress /wp-admin/users.php畸形s参数路径泄漏漏洞

    漏洞版本: WordPress 2.7.x WordPress 2.8.x WordPress 2.9.x WordPress 3.0.x WordPress 3.1.x WordPress 3.2. ...

  8. javascript 路线整理

    前端开发很重要,编写脚本也不容易. 总结我以前的前端学习经历,基本是一团乱麻:css+javascript是在大三自学的,当时自己做课程设计,逼着自己在一个月之内,写了一个半成品的j2ee网站.当时, ...

  9. Light OJ 1025 - The Specials Menu(区间DP)

    题目大意:     给你一个字符串,问有多少种方法删除字符,使得剩下的字符是回文串. 有几个规定: 1.空串不是回文串 2.剩下的字符位置不同也被视为不同的回文串.如:AA有三种回文串 A, A, A ...

  10. HDU 1523 Decoding Morse Sequences

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1523 此题大意为 给你一串摩尔斯密码  再给你一个字典(下面单词本) 用下面的单词组合成给你的摩尔斯密 ...