文字內容自動換行
word-wrap:break-word;FF
white-space:normal; word-break:break-all; IE
=================================
textarea的wrap屬性
textarea中有個wrap屬性,該屬性值有off, wrap, virtual, physical;
設爲off時,是默認運作;會出現滾動條;
而設置virtual,physical會自動換行,這兩者的區別是,當提交到服務器上時virtual始終只一行字符,直到人爲換回車;而physical則是看到幾行就是幾行。
wrap再看起什麼作用的。
=======================================
DIV圖像居中
圖像水平居中很容易與文本居中一樣用text-align:center屬性,只是注意顯示給出外框元素的寬度屬性.
圖像垂直居中:
* {margin:0;padding:0}
div {
width:500px;
height:500px;
border:1px solid #666;
overflow:hidden;
position:relative;
display:table-cell;
text-align:center;
vertical-align:middle
}
div p {
position:static;
+position:absolute;
top:50%
}
img {
position:static;
+position:relative;
top:-50%;left:-50%;
}
===圖片作爲背景圖居中
div {
width:500px;border:1px solid #666;
height:500px;
background:url("http://www.google.com/intl/en/images/logo.gif") center no-repeat
}
======================================
IE6下select無法被div擋住
這個bug老早就發現了,只由於發生在IE6下,所以就一直沒深入研究。最近測試老反應在IE6下,select無法被擋,所以就動手解決了下。
常用方法有兩種,第一是當觸發彈層(多數以彈層方式)時候,通過js把select隱藏,第二種是通過iframe來遮擋select。這裏我採用了第二種方法,其基本原理是div可以擋iframe,而iframe可以擋select。
<div class="popmsg" id="popmsg"> //彈層
</div>
<div id="popmsgbg"></div> //遮罩層
<iframe id="ifr" scrolling="no" frameborder="0"></iframe> //iframe
當觸發彈層時,顯示iframe並通過js設置它的width、height、top、left與彈層的相同,z-index的值比彈層小即可。