css技巧总结

来源:互联网 发布:sequoiadb巨杉数据库 编辑:程序博客网 时间:2024/06/08 08:38
1.禁用用户改变textarea窗口大小
textarea { 
resize: none 
}

2.cursor:pointer光标指向链接时,变为手型 

3.解决DIV+CSS左右两列高度自适应的方法:
(1)一是在最外层加上overflow:hidden,然后在左边列加上margin-bottom:-9999px;padding-bottom:9999px;即可。
(2)使用table  td高度相同
(3)js:
window.onload=function(){
 yxj_cl.style.height=yxj_cr.clientHeight + "px"
 }
(4)左边宽度固定时,可以切左边的背景图片,设置为整体背景向下平铺,靠左
    background:url(../images/zxgl-p.png) repeat-y  left top #fff;

4.让table中的<td>内容向上对齐
<td valign="top"></td>

5.table边框合并:border-collapse: collapse;
 
6.table 布局 height=100%垂直居中无效
 将html,body都设为100%,
html,body{

width:100%; 

height:100%;

}  

<table width="100%" height="100%">

<tr>

<td valign="middle">


8.checkbox与文字无法对齐

  1. <input type=checkbox id="theId" name=checkbox style="vertical-align:middle;" />  
  2. <a href="the_link" title="the_title" style="vertical-align:middle;" ></a> 

加入vertical-align:middle;  使元素的中心对齐周围元素的中心


9.input设置默认提示语

  <input value="请输入密码" onfocus="javascript:if(this.value=='请输入密码')this.value='';"/>


10.背景透明

background:#fff; filter:alpha(opacity=50);

background:rgba(0,0,0,0.6);filter:progid:DXImageTransform.Microsoft.gradient( GradientType = 0,startColorstr = "#60000000",endColorstr = "#60000000");

0 0