質問

フォームを使用してWebサイトを開発していますが、残念ながらIE 6および7が対象のブラウザーの1つです。スタイル設定されたフォーム要素のCSSおよびIEのレンダリングに問題があります。

テストケースを作成しましたが、そのままです( http:/からもオンラインで入手できます) /xistence.osnn.net/testcases/ie67fieldset/ ):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>IE [6|7] Wha?</title>
    <style type="text/css">

    html, body, div, span, applet, object, iframe,
    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
    a, abbr, acronym, address, big, cite, code,
    del, dfn, em, font, img, ins, kbd, q, s, samp,
    small, strike, strong, sub, sup, tt, var,
    dl, dt, dd, ol, ul, li,
    fieldset, form, label, legend,
    table, caption, tbody, tfoot, thead, tr, th, td {
        margin: 0;
        padding: 0;
        border: 0;
        outline: 0;
        font-weight: inherit;
        font-style: inherit;
        font-size: 100%;
        font-family: inherit;
        vertical-align: baseline;
    }

    /* remember to define focus styles! */
    :focus {
        outline: 0;
    }

    body {
        line-height: 1;
        color: black;
        background: white;
    }

    #req fieldset {
        border: 0;
        border-top: 1px solid #000;
        padding: 0em 1em 0em 1em;
    }

    #req legend + label {
        margin-top: 0.5em;
    }

    #req legend {
        font-size: 1.2em;
    }

    #req label {
        display: block;
        background: none;
    }

    #req input, #req textarea {
        position: relative;
        display: block;
        left: 200px;
        top: -1em;
        margin-bottom: -0.3em;
    }

    #req input[type="text"], #req textarea {
        width: 300px;
    }

    #req textarea {
        height: 3.6em;
    }

    #req input[type="text"], #req textarea {
        border: 1px solid #0a0;
    }

    #req label.required + input[type="text"], #req label.required + textarea {
        border: 1px solid #a00;
    }

    #req input[type="submit"] {
        position: relative;
        top: 0;
        margin: 0;
        left: 200px;
        margin-top: 0.5em;
    }

    #req input[type="hidden"] {
        display: none;
    }
    </style>
</head>
<body>
<form id="req">
    <fieldset>
        <legend>Contact Information</legend>
        <label for="name" class="required">Name: </label> <input type="text" id="name" name="name"></input>
        <label for="phone" class="required">Phone Number: </label> <input type="text" id="phone" name="phone"></input>
        <label for="email">Email: </label> <input type="text" id="email" name="email"></input>
    </fieldset>
    <fieldset>
        <legend>Personal Info</legend>
        <label for="sports">Sports:</label> <input type="text" id="sports" name="sports"></input>
        <label for="spentonline">Hours spent online: </label> <input type="text" id="spentonline" name="spentonline"></input>
        <label for="moreinfo">Tell us about yourself: </label> <textarea id="moreinfo" name="moreinfo"></textarea>
    </fieldset>
    <fieldset>
        <input type="submit" value="Submit" />
    </fieldset>
</form>
</body>
</html>

IE 7のスクリーンショットとIE 8、IE 7、IE 6のスクリーンショットの2つを撮りましたが、このスタイルに同意しているので、IE 6のスクリーンショットを撮ろうとは思いませんでした。

IE [6 | 7]: ここに画像の説明を入力

IE 8:

ここに画像の説明を入力

このバグを以前に見たことがありますか?どこで私は間違えましたか? IE 6/7で入力ボックスに余分な行を追加せずに機能させるには、何を削除する必要がありますか。余分な線は、ボーダートップがフィールドセット上にあるときに削除されますが、そうすると視覚的な分離全体が削除されるため、解決策ではありません。


修正されました。 textareaとinput [type =&quot; text&quot;]のマージン下部により、IE 6/7でレンダリングのバグが発生していました。それらを削除し、すべてが順調です。ページ上の要素間の余分なスペースに対処できると思います!

役に立ちましたか?

解決

使用していることがわかります

input[type="submit"]

これはIE6でサポートされているとは思わない...異なるタイプの入力を区別するために、すべてのフィールドにクラスを配置することをお勧めします。

編集

margin-bottom: -0.3em;

現在、ネガティブマージンを使用しているため、IEで問題が発生することが多いため、削除する必要があります

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top