单选按钮不会在 IE7 中显示内联

发布于 2024-12-11 21:59:15 字数 2746 浏览 1 评论 0原文

我已经设置了单选按钮以在联系表单上内联显示。它们在除 IE7 之外的所有测试浏览器中正常显示,它们不会内联显示。它们是使用 ul 和 li 设置的。

单选按钮的 CSS

fieldset div ul {
    margin: 5px 0 0 0;
    list-style:none;
    display:block;
    float:left;
}

fieldset div ul li {
    margin: 0 15px 0 0;
    padding: 0;
    list-style:none;
    display:inline;
    float:none;
}

fieldset div ul li label {
    display: inline;
    float: none;
    font-size: 1em;
    font-weight: normal;
    margin: 0;
    padding: 0;
}

fieldset div ul li input {
    background: none;
    border: none;
    display: inline;
    margin: 0 5px 0 0;
    padding: 0;
    width: auto;
    float:none;
}

表单的 HTML

<fieldset>
  <!-- Your Name -->
  <div>
    <label for="name">Name</label>
    <input type="text" name="name" id="name" class="required"/>
    </div>

  <!-- Email -->
  <div>
    <label for="emailAddress">Email</label>
    <input type="text" name="emailAddress" id="emailAddress" class="required email"/>
    </div>

  <!-- Phone -->
  <div>
    <label for="phone">Phone</label>
    <input type="text" name="phone" id="phone" />
    </div>

  <!-- Contact Time -->
  <div>
  <label for="contactTime">Best Time to Contact</label>
  <ul>
  <li><input type="radio" name="contactTime" value="morning" /><label for="morning">Morning</label></li>
  <li><input type="radio" name="contactTime" value="day" /><label for="day">Day</label></li>
  <li><input type="radio" name="contactTime" value="evening" /><label for="evening">Evening</label></li>
  </ul>
  </div>



  <!-- Contact Method -->
  <div>
  <label for="contactMethod" style="margin:15px 0 0 0;">Best Method of Contact</label>
  <ul>
  <li><input type="radio" name="contactMethod" value="phone" /><label for="phone">Phone</label></li>
  <li><input type="radio" name="contactMethod" value="email" /><label for="email">Email</label></li>
  </ul>
  </div>


  <!-- Coments -->
  <div class="floatLeft" style="margin:10px 0 0 0;">
    <label for="mess">Message</label>
    <textarea name="mess" id="mess" rows="15" cols="5"></textarea>
    </div>

  <!-- Controls -->
  <div class="controls">
    <input id="submit" name="submit" type="submit" value="Contact Us" class="button"/>
    </div>
  </fieldset>
<input name="url" type="hidden" value="" class="noDisplay"/>

I have set up radio buttons to display inline on a contact form. They display properly in all tested browsers except IE7, they will not display inline. They are set up using ul and li.

CSS for radio buttons

fieldset div ul {
    margin: 5px 0 0 0;
    list-style:none;
    display:block;
    float:left;
}

fieldset div ul li {
    margin: 0 15px 0 0;
    padding: 0;
    list-style:none;
    display:inline;
    float:none;
}

fieldset div ul li label {
    display: inline;
    float: none;
    font-size: 1em;
    font-weight: normal;
    margin: 0;
    padding: 0;
}

fieldset div ul li input {
    background: none;
    border: none;
    display: inline;
    margin: 0 5px 0 0;
    padding: 0;
    width: auto;
    float:none;
}

HTML for form

<fieldset>
  <!-- Your Name -->
  <div>
    <label for="name">Name</label>
    <input type="text" name="name" id="name" class="required"/>
    </div>

  <!-- Email -->
  <div>
    <label for="emailAddress">Email</label>
    <input type="text" name="emailAddress" id="emailAddress" class="required email"/>
    </div>

  <!-- Phone -->
  <div>
    <label for="phone">Phone</label>
    <input type="text" name="phone" id="phone" />
    </div>

  <!-- Contact Time -->
  <div>
  <label for="contactTime">Best Time to Contact</label>
  <ul>
  <li><input type="radio" name="contactTime" value="morning" /><label for="morning">Morning</label></li>
  <li><input type="radio" name="contactTime" value="day" /><label for="day">Day</label></li>
  <li><input type="radio" name="contactTime" value="evening" /><label for="evening">Evening</label></li>
  </ul>
  </div>



  <!-- Contact Method -->
  <div>
  <label for="contactMethod" style="margin:15px 0 0 0;">Best Method of Contact</label>
  <ul>
  <li><input type="radio" name="contactMethod" value="phone" /><label for="phone">Phone</label></li>
  <li><input type="radio" name="contactMethod" value="email" /><label for="email">Email</label></li>
  </ul>
  </div>


  <!-- Coments -->
  <div class="floatLeft" style="margin:10px 0 0 0;">
    <label for="mess">Message</label>
    <textarea name="mess" id="mess" rows="15" cols="5"></textarea>
    </div>

  <!-- Controls -->
  <div class="controls">
    <input id="submit" name="submit" type="submit" value="Contact Us" class="button"/>
    </div>
  </fieldset>
<input name="url" type="hidden" value="" class="noDisplay"/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放肆 2024-12-18 21:59:15

尝试将它们设置为向左浮动 -

fieldset div ul li {
    margin: 0 15px 0 0;
    padding: 0;
    list-style:none;
    display:inline;
    float:left;
}

不应该影响任何其他浏览器,并且应该对 IE7 进行排序。不过,不要忘记在它们之后clear: left;

Try setting them to float left -

fieldset div ul li {
    margin: 0 15px 0 0;
    padding: 0;
    list-style:none;
    display:inline;
    float:left;
}

Shouldn't affect any other browsers, and should sort out IE7. Don't forget to clear: left; after them though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文