【发布时间】:2014-09-26 13:59:13
【问题描述】:
我正在为我的 Web 应用程序使用引导程序,但我在验证消息时遇到问题,无法将消息状态置于正确的位置。现在我使用了这个link 中的这个例子,代码如下:
<div class="control-group error">
<label class="control-label" for="inputError">Input with error</label>
<div class="controls">
<input type="text" id="inputError">
<span class="help-inline">Please correct the error</span>
</div>
</div>
我现在使用的代码:
<h4 class="form-signin-heading">Please sign in</h4>
<div class="control-group">
<div class="controls">
@Html.TextBoxFor(u => u.Username, new {placeholder="Username", @class="form-control username", id="inputError"})
<span class="help-inner">@Html.ValidationMessageFor(u => u.Username)</span>
</div>
<div class="controls">
@Html.PasswordFor(u => u.Password, new {placeholder="Password", @class="form-control password"})
@Html.ValidationMessageFor(u=> u.Password)
</div>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
我的代码是这样做的(也在小提琴中:http://jsfiddle.net/4h5E5/1/):
但我的愿望是将验证消息放在这个位置(如链接中的示例):
【问题讨论】:
-
使用 CSS 来定位它。我现在能想到的简单方法是你可以做 float:right;
-
很有趣,但它只放在输入右侧的末尾(例如用户名)
-
所以你希望它在右侧,如图所示
-
是的-Richa,我在我的 style.css 中放在 float 旁边:right、margin-right 和 margin-top,它放置在正确的位置,但响应不起作用......
标签: css twitter-bootstrap validation message