☆
下拉列表填加/刪除選項
document.getElementById("selectId").options.add(new Option("text","value"));
document.getElementById("selectId").options[i]=null;
☆
固定表格的寬度,不要被文字撐寬
如果是table:style=" table-layout:fixed;word-wrap:break-word;"
如果是div:style="word-wrap:break-word;"

☆
只顯示豎向滾動條
overflow-x:none;overflow-y:scroll;
☆
表格內文本超出指定寬度溢出的處理(顯示為……)
table{
width:600px;
table-layout:fixed;/*只有定義了表格的布局算法為fixed,下面td的定義才能起作用。 */
}
td{
word-break:keep-all;/* 不換行 */
white-space:nowrap;/* 不換行 */
overflow:hidden;/* 內容超出寬度時隱藏超出部分的內容 */
text-overflow:ellipsis;/* 當對象內文本溢出時顯示省略標記(
) ;需與overflow:hidden;一起使用。*/
}
☆
設置disabled
不可用:"disabled":disabled="disabled"
可用:false;(注意不要加引號):disabled=false;
注意:如果設置為disabled后,在Form提交后是讀不到值的。例如:<input type="text" name="user" value="myname" disabled="disabled"/>, 雖然組件"user"有值(value="myname"),但是提交過后是讀不出值的。即取得"user"的值為空。
☆
捕獲回車事件
<script type="text/javascript" >
if(document.addEventListener)
document.addEventListener("keydown",myKeyDown,true);//IE
else
document.attachEvent("onkeydown",myKeyDown);//FireFox
function myKeyDown(event){
if(event.keyCode==13)
alert("enter");
}
</script>
☆
表格邊框為虛線
style="border-collapse: collapse;border: 1px dotted #afafaf;"
【none:無樣式;
dotted:點線;
dashed:虛線;
solid:實線;
double:雙線;
groove:槽線;
ridge:脊線;
inset:內凹;
outset:外凸。】
☆
滾動字幕
<marquee
direction="up" //滾動方向
bgcolor="#99CC33" //背景顏色
loop="-1" //無限循環
scrollamount="3" //滾動速度
scrolldelay="200" //滾動停留
height="60px" //高度
hspace="2" //左右距離
vspace="5" //上下距離
onmouseover="this.stop()" //停止滾動
onmouseout="this.start()">
</marquee>
☆
使插入表格中的表格往上對齊
在外面的td中加入屬性valign="top"
☆
Line-height無效
如果在單元格里面即有圖片,同時又有文字,那么設置line-height無效;解決方法:1)設置圖片的margin距離;
2)用css:
ul {list-style-image:url(../images/arrow1.gif);}
li{line-height:180%;list-style:none;margin-left:20px;}
posted on 2007-08-29 16:54
破繭而出 閱讀(500)
評論(0) 編輯 收藏 所屬分類:
CSS_DOM