比如用我要把button设置成长度为50
text设置成100
如何?

解决方案 »

  1.   

    <HTML>
    <HEAD>
    <META http-equiv="Content-Type" content="text/html; charset=gb2312">
    <TITLE>test</TITLE>
    <STYLE>
    input
    {
        lxc:expression(setWidth(this));
    }
    </STYLE>
    <SCRIPT language="javascript">
    function setWidth(obj)
    {
        if(obj.type == "text")
            obj.style.width = 100;
        if(obj.type == "button")
            obj.style.width = 50;
    }
    </SCRIPT>
    </HEAD><BODY>
    <INPUT type="text">
    <INPUT type="button">
    </BODY>
    </HTML>
      

  2.   

    Input.htm
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title></title>
    <style>
    input{behavior:url('Input.htc')}
    </style>
    </head><body>
    <input type=text value="文本">
    <input type=button value="按钮">
    </body></html>Input.htc
    <script language=javascript>
    switch(type)
    {
    case 'text':
    case 'password':
    style.border="1px solid #000000";
    style.backgroundColor="#FFFFFF";
    style.height="18px";
    style.font="normal 12px 宋体";
    style.color="#000000";
    break;
    case 'submit':
    case 'reset':
    case 'button':
    style.border="1px solid #000000";
    style.backgroundColor="#CCCCCC";
    style.height="18px";
    style.font="normal 12px 宋体";
    style.color="#000000";
    break;
    default:;
    }
    </script>