您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

使用display:block输入的不是块,为什么不呢?

使用display:block输入的不是块,为什么不呢?

看看我想出了什么,一种使用@R_982_2419@-sizing:border-@R_982_2419@CSS 3 相对未知的样式的解决方案。这允许任何元素上的“真”宽度为100%,无论该元素的填充和/或边框如何。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <Meta http-equiv="Content-Type" content="text/html;charset=utf-8">

        <title>Cross-browser CSS @R_982_2419@-sizing:border-@R_982_2419@</title>

        <style type="text/css">
            form {display:block; margin:0; padding:0; width:50%; border:1px solid green; overflow:visible}
            div, input {display:block; border:1px solid red; padding:5px; width:100%; font:normal 12px Arial}

            /* The voodoo starts here */
            .bb {
                @R_982_2419@-sizing: border-@R_982_2419@; /* CSS 3 rec */
                -moz-@R_982_2419@-sizing: border-@R_982_2419@; /* Firefox 2 */
                -ms-@R_982_2419@-sizing: border-@R_982_2419@; /* Internet Explorer 8 */
                -webkit-@R_982_2419@-sizing: border-@R_982_2419@; /* Safari 3 */
                -khtml-@R_982_2419@-sizing: border-@R_982_2419@; /* Konqueror */
            }
        </style>

        <!-- The voodoo gets scary. Force Internet Explorer 6 and Internet Explorer 7 to support Internet Explorer 5's @R_982_2419@ model -->
        <!--[if lt IE 8]><style>.bb {behavior:url("@R_982_2419@sizing.htc");}</style><![endif]-->
    </head>

    <body>
        <form name="foo" action="#">
            <div class="bb">div</div>
            <input class="bb" size="20" name="bar" value="field">
        </form>
    </body>
</html>

解决方案通过Erik Arvidsson编写的行为支持Internet Explorer 6和Internet Explorer 7,并通过Dean Edwards的一些调整来支持百分比和其他非像素宽度。

其他 2022/1/1 18:16:04 有365人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶