常用的CSS总结

来源:互联网 发布:mac怎么压缩文件夹 编辑:程序博客网 时间:2024/05/14 16:31

工作中总结积累的东东,以后工作中在慢慢积累吧。。 

1、强制换行:(用于一般输入纯字母或数字,如:ssssssssssssssssssss/1111111111111111不换行,给css加入此样式即可)

div,span,p,table,tr,td{ word-wrap: break-word; word-break: normal;} 

2、浏览器下textarea宽度可根据鼠标拉申改变,加入此代码可固定(取消textarea的拖动改变大小的功能:

textarea{resize:none;} 

3、文本两端对齐,多用于内容页

text-align:justify;text-justify:inter-ideograph; 

4、取消表单项聚焦时产生的黄色边框:

input,button,select,textarea{outline:none} 

5、增强focus定义

a:focus{ 

 outline:1px solid red;

    background:yellow;

}  

6、定义必填表单项

<input type="text" name="username" aria-required="true">

7、给你的页面添加一个h1

原因很简单,不只是有利于SEO,对网站整体的可用性和可读性都很有帮助。另外,你没有代码洁癖么?

8、定义表格的表头

<th scope="col">Date</th>  

9、定义表格描述(http://www.qianduan.net/rediscovering-html-tables.html)

不要简单的在表格前面/后面加个p了事了,表格有专用的caption标签可用,就像图片一样。

<table>

    <caption>Class Schedule</caption>

<tr> 

10、css hack 

*html .search_box .text_box {margin-top:1px;}/*仅IE6*/

  *+html .search_box .text_box {margin-top:0px;}/*仅IE7*/

#test  

    {  

        width:300px;  

        height:300px;            

        background-color:blue;      /*firefox*/

        background-color:red\9;      /*all ie*/

        background-color:yellow\0;    /*ie8*/

        +background-color:pink;        /*ie7*/

        _background-color:orange;       /*ie6*/

    }   

11、http://wave.webaim.org/

自测网站

原创粉丝点击