質問

いfield_wrapperクラスの本部長を含む3つのサブdivs field_label,field_inputとfield_error

私のfield_label,field_input並field_error以下の。

下記をご参照くださいcssコードかどうかを達成し、問題はそがインドにおいて入手できないIE7.明確なものfield_errorがあり、びっくりしました。

後もgoogling長時間において適切な方法でこの問題を修正するには追加なしのHTMLをマークします。ご相談css端またはその他の方法を避ける追加マークアップコード

.field_wrapper
{
 clear:both;
}

.field_label
{
 float:left;
 width:40%;
}
.field_input
{
 float:left;
 width:40%;
}
.field_error
{
 clear: both;
 color:#FF0000;
 float: right;
 text-align:left;
 width: 60%;
}

<form method="post" action="http://localhost/locations/add">
 <div class="field_wrapper">
  <div class="field_label">
   <label for="location_add_name">Name</label>
  </div>
  <div class="field_input">
   <input type="text" id="location_add_name" value="" name="name">
  </div>
  <div class="field_error">
   <p>The Name field is required.</p>
  </div>
 </div>
 <div class="field_wrapper">
  <div class="field_label">
   Address
  </div>
  <div class="field_input">
   <textarea id="location_add_address" rows="12" cols="90" name="address"></textarea>
  </div>
  <div class="field_error">
  </div>
 </div>
 <div class="form_submit">
  <input type="submit" value="Add" name="submit"> 
 </div>
</form>
役に立ちましたか?

解決

ない場合は削除のfloatります。利用することができラッパーコード

.field_wrapper { display: inline-block; }
.field_wrapper:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
* html .field_wrapper { height: 1%; }
.field_wrapper{ display: block; }

でも私にとっては毎回(IE6)

更新:

私はここで再び、変更、マークアップを少しでもで有効なxhtml.を入れるだけのクラスではPタグでしょリーダーを外部です。

    .field_wrapper
    {
     clear:both;
    }

    .field_label
    {
     float:left;
     width:40%;
    }
    .field_input
    {
     float:left;
     width:40%;
    }
    .field_error
    {
     clear: both;
     color:#f00;
     width: 60%;
    }


<form method="post" action="http://localhost/locations/add">
    <div class="field_wrapper">
        <div class="field_label">
            <label for="location_add_name">Name</label>
        </div>
        <div class="field_input">
            <input type="text" id="location_add_name" value="" name="name" />
            <p class="field_error">The Name field is required.</p>
        </div>
    </div>

    <div class="field_wrapper">
        <div class="field_label">Address</div>
        <div class="field_input">
            <textarea id="location_add_address" rows="12" cols="90" name="address"></textarea>
        </div>
    </div>
    <div class="form_submit">
        <input type="submit" value="Add" name="submit" /> 
    </div>
</form>

他のヒント

floatを削除します。右の 'field_error'

から

私が最初にあなたに一つのことを教えてみましょう。あなたは、コンテナ内のコンテンツを浮動た場合、コンテナは、それはそれまでは含んでいませんし、あなたも隠さにコンテナのoverflowプロパティを設定したりしない限り、それはあなたをフロートさせます。

のような
.field_wrapper
{
 clear:both;
 overflow:hidden;
}

今ではすべての浮動要素が含まれています。あなたはあなたの左に要素を浮遊しているよう今すぐあなたのエラーのdivのために、それほど明確にする:のみ残し、それが動作します。

おかげ

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