0

嗨,我得到了下面的部分视图,它将在 div 内显示控件,但控件创建的时间总是比 div 长,有没有更好的方法来控制 css 而不是硬编码每个控件的宽度?

<fieldset  class="fieldsetthinner">
    <div style="float: left; width: 10%"><p>@Html.EditorFor(model => model.decBeginQty)<p></div>
    <div style="float: left; width: 10%"><p>@Html.EditorFor(model => model.decEndQty )<p></div>
    <div style="float: left; width: 10%"><p>@Html.EditorFor(model => model.decBeginAmt )<p></div>
    <div style="float: left; width: 10%"><p>@Html.EditorFor(model => model.decEndAmt )<p></div>

    <div style="float: left; width: 20%"><p>@Html.EditorFor(model => model.tintFactorType)<p></div>
    <div style="float: left; width: 10%"><p>@Html.EditorFor(model => model.decMaxBonus )<p></div>
    <div style="float: left; width: 10%"><p>@Html.EditorFor(model => model.nvarMsg )<p></div>
    <div style="float: left; width: 10%"><p>@Html.EditorFor(model => model.varVCode  )<p></div>
</fieldset>

提前致谢

4

1 回答 1

0

像这样的东西?

<fieldset  class="fieldsetthinner">
 <div class="editor"><p>THIS IS AN EDITOR<p></div>
 <div class="editor"><p>THIS IS AN EDITOR<p></div>
 <div class="editor"><p>THIS IS AN EDITOR<p></div>
 <div class="editor"><p>THIS IS AN EDITOR<p></div>
 <div class="editor2"><p>THIS IS AN EDITOR<p></div>
 <div class="editor"><p>THIS IS AN EDITOR<p></div>
 <div class="editor"><p>THIS IS AN EDITOR<p></div>
 <div class="editor"><p>THIS IS AN EDITOR<p></div>
</fieldset>

CSS

fieldset.fieldsetthinner
{
    background-color:gray;
}

.editor
{
  float:left;
  width:10%;
  background-color:red;
}
.editor2
{
 background-color:blue;
 float:left;
 width:20%;
}

只需将其添加到您的 CSS 中。我添加了背景颜色以向您展示差异。您可以使用 class 或 id ,这样您就不会像您正在做的那样重复输入类似的样式。

这是工作的FIDDLE

于 2013-07-23T11:15:44.353 回答