4

私のページにdivは、中央に配置され、特定の幅がありますが、コンテンツで必要な場合はその幅を超えて拡張したいと考えています。私は次のようにこれをやっています:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <style type="text/css">
            .container-center {
                text-align: center;
            }
            .container-minwidth {
                min-width: 5em;
                display: inline-block;
                border: 1px solid blue;
            }
        </style>
    </head>
    <body>
        <div class="container-center">
            <div class="container-minwidth">
                a
            </div>
        </div>
    </body>
</html>

これは Firefox/Safari ではうまく機能しますが、IE6 では機能しませんdisplay: inline-block。これをIE6でも機能させる方法について何かアドバイスはありますか?

4

3 に答える 3

4

これは完璧な解決策ではありませんが、IE6 で min-width がサポートされていないといういくつかの問題を回避しました。

<style type="text/css">            
            .container-minwidth {
                min-width: 5em;

                width: auto !important;
                width: 500px; /* IE6 ignores the !important tag */

                /* would help for expanding content if it blows past 500px; */
                overflow:auto; 

                display: inline-block;
                border: 1px solid blue;
            }        
</style>

この状況で役立つ可能性があるもう 1 つのタグは、overflow タグです。

于 2009-02-02T04:49:06.440 に答える
1

実際、Alessandro IE6 は を理解display: inline-blockしていますが、あなたのコードについて理解していないのはmin-width. これを機能させるためのハックはたくさんありますが、どれもお勧めしません。それらのいずれかを使用する場合は、IE6 固有のスタイル シートに配置して、他のより標準的な準拠ブラウザーに干渉しないようにしてください。

于 2009-02-02T04:49:51.663 に答える
0
<style type="text/css">            
        .container-minwidth {
            min-width: 5em;
            _width: 500px;
            white-space:nowrap;

            display: inline-block;
            *display:inline;
            *zoom:1;

            border: 1px solid blue;
        }        
</style>
于 2012-05-07T02:45:37.287 に答える