0

我正在尝试使用字段集图例作为一组单选按钮的标签。我的 HTML 和 CSS 在 IE8&9、firefox 和 chrome 中运行良好。在 IE7 中,标签出现在单选按钮上。在所有其他浏览器中,标签显示在按钮的左侧。我很高兴为 IE7 添加一个有条件的 stle,但我不知道是什么使这项工作。

该问题在以下标记中复制

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

  <html>
  <head>
  <title>Untitled</title>
  <style type="text/css">
  .radiolegend {
      display: inline;    float: left;    width: 300px;
  }
  .fieldsetstyle {
      border: 0 none;    clear: left;    float: left;
        }

  </style>

  </head>
  <body>
  <form>
  <fieldset class="fieldsetstyle">
  <legend class="radiolegend">legend</legend>
  <input type="radio" name="r1" style="display: inline;" id="r1">
  <label for="r1">r1</label>
  <input type="radio" name="r2" style="display: inline;" id="r2">
  <label for="r2">r2</label>
  </fieldset>
  </form>
  </body>
  </html>
4

1 回答 1

1

如果你想要 ie7 条件,那么这样做:

CSS

.radiolegend {
     float: left;    width: 150px;
}
.fieldsetstyle {
 border: 0 none;    clear: left;    float: left; width:300px;
}

.cb{
float:right;
    margin-top:-20px;
}

HTML

<form>
<fieldset class="fieldsetstyle">
<legend class="radiolegend">legend</legend>
    <div class="cb"><input type="radio" name="r1" style="display: inline;"/>r1</div>
    <div class="cb"> <input type="radio" name="r2" style="display: inline;"/>r2 </div>
    </fieldset></form>

现在,您还需要更改其余浏览器的样式。只需margin-top:-20px;.cb. 您将文本包装在<input>标签中,这是不正确的。<input>必须是自闭的

于 2011-11-16T14:48:56.033 回答