Home  >  Article  >  Web Front-end  >  div+css是网页排版技巧_html/css_WEB-ITnose

div+css是网页排版技巧_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 13:05:051094browse

以下是工作中总结的一些技巧,留下备用,希望对看到的人有用~~

 

1,ul:默认的ul的margin和padding不是0,如果在导航中用到了左浮动的li,往往会把外部的div撑大,导致页面变形,改成: ul{margin:0px; padding:0px;}

2、img:1、这里牵涉的不同浏览器的问题,ie6里显示的图片height总是要大于准确值,这里就需要我们记住下面这一点 img{ display:block};2、页面中最好不要用大块背景,能平铺的要平铺,否则加载起来会很慢,也不利于以后的
优化和扩展,当然也有些大的网站,现在都尽量把背景统一放到一张图片上,用background-postion来取得背景。3、最好的格式就是gif格式,即确保了背景透明,在ie6中又不会有阴影,有时gif图片会有锯齿,这就需要我们保存成web格式,设置一下matter,matter的值用背景颜色的值越相近越好。


3,overflow:有时一些公司的注册协议都是很长,这就用到了overflow,可以把div的style里加上这个:overflow:auto

4,float:有时候一些div会挤到页面的上方,这里可能就是浮动引起的,可以加上clear:both。

5,div:height等于1px的div,在ie6中可能并不是1px,在这个div的style里加上font-size:1px;这样就ok了。

6,id和class:当一个样式在页面中多次使用时,不要用id,要用class,要使用js的时候,样式最好不要用id,因为id要留给js使用。

7,link:.link:link{}、.link:visited{}、.link:hover{}、.link:active{}。有一点,visited与hover的顺序一定不能倒换,否则ie6中会大大的问题。

8,css编码问题:@charset "utf-8";注意这行代码,utf-8与g把gb2312是比较常用的两种编码方式。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:网页时钟_html/css_WEB-ITnoseNext article:网页头部优化