在学习用div+css 制作网站版面的时候,越来约关注的问题就是,兼容问题,这是个很头疼的问题,那么怎么解决这些问题呢?
在学习用div+css 制作网站版面的时候,越来约关注的问题就是,兼容问题,这是个很头疼的问题,那么怎么解决这些问题呢?
要解决浏览器兼容等问题,必须要了解当中的技巧和原理,我们也在网上收集了相关信息,并对其进行整理,对于web2.0的过渡,请尽量使用xhtml的格式去写代码,而且受doctype影响的css去处理,如果是作为w3c 标准的网页,切记一定要加doctype去声明一下。
下面介绍一些css 兼容技巧
1、div的垂直居中问题 vertical-align:middle; 将行距增加到和整个DIV一样高 line-height:200px; 然后插入文字,就垂直居中了。缺点是要控制内容不要换行
2、 margin加倍的问题 设置为float的div在ie下设置的margin会加倍。这是一个ie6都存在的bug。解决方案是在这个div里面加上display:inline; 例如: <#div id=”imfloat”> 相应的css为 #IamFloat{ float:left; margin:5px;/*IE下理解为10px*/ display:inline;/*IE下再理解为5px*
div+css 兼容技巧,你学会了吗?
CSS tricks
1.div vertical centering problem vertical-align: middle; increase the line spacing and the entire DIV as high line-height: 200px; Then insert text, it vertically centered. Disadvantage is not wrap to control content
2. Margin doubling problem in a div set to float under ie set margin will be doubled. This is an ie6 are present bug. The solution is in this div inside with display: inline; example: <# div id = "imfloat"> corresponding css as # IamFloat {float: left; margin: 5px ;/ * IE next understood as 10px * / display: inline ;/ * IE down again understood as 5px *