1、给input的placeholder设置颜色

 1 .phColor::-webkit-input-placeholder { /* WebKit, Blink, Edge */
 2     color:maroon;
 3 }
 4 .phColor:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
 5    color:maroon;opacity:  1;
 6 }
 7 .phColor::-moz-placeholder { /* Mozilla Firefox 19+ */
 8    color:maroon;opacity:  1;
 9 }
10 .phColor:-ms-input-placeholder { /* Internet Explorer 10-11 */
11    color:maroon;
12 }

 

2、透明度

.demo{
    width:100%;height:25px;background:orange;
    /*兼容IE6+,Chrome,Firefox--注意不要更改下面三条属性的次序*/
    opacity: 0.3; 
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
    filter: alpha(opacity=30);
}
<p class="demo">hello world</p>

 

3、超出长度显示省略号

width:300px;height:100px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;

其他文本类属性有:

(1)word-wrap: normal|break-word;

(2)word-break: normal|break-all|keep-all;

normal 使用浏览器默认的换行规则;break-all 允许在单词内换行。

(3)white-space: normal|pre|nowrap|pre-wrap|pre-line;

normal 默认 - 空白会被浏览器忽略;nowrap 文本不会换行,文本会在在同一行上继续,直到遇到 <br> 标签为止。(常用)

 

4、textarea禁止拖动

resize: none | both | horizontal | vertical

none:用户不能操纵机制调节元素的尺寸;both:用户可以调节元素的宽度和高度;

horizontal:用户可以调节元素的宽度;vertical:让用户可以调节元素的高度;

 

5、按钮-鼠标悬浮-背景色过渡变化(transtion)

1 a{padding:8px 16px;border-radius:5px;background-color:#396;color:#fff;text-decoration:none;
2   transition:background-color .3s ease-in-out .1s;
3   -webkit-transition:background-color .3s ease-in-out .1s;  /*Safari 需要前缀 -webkit-*/
4 }
5 a:hover{background-color:#063;}
6 <a href="#">hello</a>

 

6、列表-鼠标悬浮-缩进过渡变化(transtion)

<style>
.box .list{width:300px;border:1px solid #ccc;border-radius:5px;overflow:hidden;padding:5px 16px;list-style:none;}
.box .list li{padding:6px 0 6px 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:all 0.25s ease-in-out 0s;}
.box .list li:hover{margin-left:8px;}
.box .list li a{color:#333;text-decoration:none;}
.box .list li span{color:aqua;font-size:20px;padding-right:6px;}
/*text-overflow:ellipsis;显示省略符号来代表被修剪的文本.
  white-space:nowrap;文本不会换行,文本会在在同一行上继续,直到遇到br标签为止.*/
</style>
<div class="box">
    <ul class="list">
        <li class=""><span>•</span><a href="#">list1 list1 list1 list1 list1 list1 list1 </a></li>
        <li class=""><span>•</span><a href="#">list2 list2 list2 list2 list2 list2 list2</a></li>
        <li class=""><span>•</span><a href="#">list3 list3 list3 list3 list3 list3 list3</a></li>
    </ul>
</div>

 

7、横线-文字-横线

ul{padding:0;margin:30px auto;list-style:none;}
ul .list1{border-bottom:1px solid #666;margin-bottom:-15px;}
ul li a{width:100%;display:block;box-sizing:border-box;padding:5px;text-align:center;text-decoration:none;color:orange;}
ul li a span{background:#fff;padding:0 10px;}
<ul>
    <li class="list1"></li>
    <li class="list2"><a href="javascript:;"><span>Hello world</span></a></li> 
</ul>

 

8、table-border

 1 <!DOCTYPE html>
 2 <html>
 3 <head lang="en">
 4 <meta charset="utf-8" />
 5 <style type="text/css">
 6 /*table-1*/
 7 #table1{border-collapse:collapse;}
 8 #table1, #table1 td, #table1 th{border:1px solid black;}
 9 /*table-3*/
10 #table3{border-collapse:separate;border-spacing:10px 10px;}
11 #table3, #table3 td, #table3 th{border:1px solid black;}
12 /**
13 * border-collapse 属性设置表格的边框是否被合并为一个单一的边框,还是象在标准的 HTML 中那样分开显示。
14 * 可能的值:
15 * separate--默认值。边框会被分开。不会忽略 border-spacing 和 empty-cells 属性。
16 * collapse--如果可能,边框会合并为一个单一的边框。会忽略 border-spacing 和 empty-cells 属性。
17 * inherit--规定应该从父元素继承 border-collapse 属性的值。
18 **/
19 /**
20 * border-spacing--属性设置相邻单元格的边框间的距离,在指定的两个长度值中,第一个是水平间隔,第二个是垂直间隔。除非 border-collapse 被设置为 separate,否则将忽略这个属性。
21 **/
22 </style>
23 </head>
24 
25 <body>
26 <h2>table-1:</h2>
27 <table id="table1">
28     <tr><th>Firstname</th><th>Lastname</th></tr>
29     <tr><td>Bill</td><td>Gates</td></tr>
30     <tr><td>Steven</td><td>Jobs</td></tr>
31 </table>
32 <p><b>注释:</b>如果没有规定 !DOCTYPE,border-collapse 属性可能会引起意想不到的错误。</p>
33 <hr>
34 <h2>table-2:</h2>
35 <table border='1' cellspacing='0'>
36     <tr><th>Firstname</th><th>Lastname</th></tr>
37     <tr><td>Bill</td><td>Gates</td></tr>
38     <tr><td>Steven</td><td>Jobs</td></tr>
39 </table>
40 <hr>
41 <h2>table-3:</h2>
42 <table id="table3">
43     <tr><th>Firstname</th><th>Lastname</th></tr>
44     <tr><td>Bill</td><td>Gates</td></tr>
45     <tr><td>Steven</td><td>Jobs</td></tr>
46 </table>
47 </body>
48 </html>
View Code

相关文章:

  • 2021-04-27
  • 2021-12-15
  • 2021-08-18
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2021-08-16
猜你喜欢
  • 2021-12-25
  • 2021-12-16
  • 2021-12-29
  • 2022-12-23
  • 2021-12-25
  • 2022-01-01
  • 2022-01-31
相关资源
相似解决方案