人生就像骑单车。想保持平衡就得往前走。 ——爱因斯坦
1.更改input的placeholder中文字的样式
input::-webkit-input-placeholder { /* WebKit browsers */
color: #A1A1A1;
}
input::-moz-placeholder { /* Mozilla Firefox 4 to 18 */
color: #A1A1A1;
}
input::-moz-placeholder { /* Mozilla Firefox 19+ */
color: #A1A1A1;
}
input::-ms-input-placeholder { /* Internet Explorer 10+ */
color: #A1A1A1;
}
实践过程中发现没效果,可能是我哪里写错了吧,后来把input换成".类名"就有效果了!
2. 强制文字不换行
white-space:nowrap;
3. : before 选择器在被选元素的内容前面插入内容,使用 content 属性来指定要插入的内容
<style>
p:before
{
content:"台词:";
}
</style>
</head>
<body>
<p>我是唐老鸭。</p>
<p>我住在 Duckburg。</p>
<p><b>注释:</b>对于在 IE8 中工作的 :before,必须声明 DOCTYPE。</p>
</body>
结果就是在每个 <p> 元素的内容之前插入新内容4. 清除浮动:父容器使用 overflow:auto; 使用这种方法,必须定义width或者zoom,而且不能设置高度height,优点是代码少,缺点是不能使用position,否则超出的元素将会被隐藏
5. 图片底部加一点渐变色:
background-image: linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,0.8))
6. 单个圆角设置:7. 禁止浏览器自动填充非登陆input的账号和密码
<div class="biaodan">
<input class="name1" type="text" placeholder="请输入暱称" style="width:0;position:absolute;z-inde:-9999">
<input class="name" type="text" placeholder="请输入暱称">
<input class="pwd1" type="password" placeholder="请输入密码" style="width:0;position:absolute;z-inde:-9999">
<input class="pwd" type="password" placeholder="请输入密码">
<div class="btn" @click="checklogin">登录</div>
<div class="wangji">忘记密码</div>
</div>
在上面加input,让它自动填充,然后input 宽度设置为0,position设为绝对定位,z-index设为-9999
8. 解决直接在table上设置圆角无效果的问题:只要在table的外面套上一个圆角的DIV盒子,把overflow设为hidden就好了~简单粗暴!(亲测可用)
9. 通配符选择器 * 一般不使用(性能不好),权重0到1之间
10. 伪类选择器: 给一个元素添加某种状态(hover等)
11. 伪元素: 通过css代码向指定的元素内添加假的(html)中不存在的元素
<div>我是div元素</div>
div{
color: red;
}
div:before{ //出现在该div内容之前
display: block;
content: "我是哥哥"; // 这个属性的内容可以为空,但是引号""不能缺少
color: blue;
font-size: 16px;
}
div:after{ // 出现在该div内容之后
display: block;
content: "我是弟弟";
color: blue;
font-size: 14px;
}
在工作中,经常使用 :after ,用来清除浮动带来的影响
12. 用border制作三角形
<div class="div1"></div>
.div1{
width: 0;
border-style: solid;
border-width: 20px; //大小由border-width决定
border-color: red transparent transparent transparent;
}