很多朋友在编写html的时候往往会被一些小问题所困扰,这里介绍几个小小的技巧。

1. 防止图片撑破div层

.div-img {margin: auto; width: 600px;}
.div-img img{max-width: 100%!important; height: auto!important; width:expression(this.width > 600 ? “600px” : this.width)!important;}

2. 让div的内容图片垂直居中(可兼容多浏览器)

.div-img {*position:absolute; top:50%;}
.div-img img {*position:relative; top:-50%; left:-50%;}

3. 让文字从右往左竖排写

.text { layout-flow: vertical-ideographic; height:400px; line-height:200%; }