【发布时间】:2015-08-30 19:09:31
【问题描述】:
我正在尝试为我的输入框创建验证错误消息,但我遇到了奇怪的行为以及 Chrome 和其他浏览器之间的差异。
我需要将错误标签设置为显示在输入旁边,并且它应该显示在其他元素上。 我的方法在 FF 中运行良好,但在 chrome 中不行。
问题在于,在 Chrome 中,错误消息位于输入框下方。
示例: http://jsfiddle.net/ewuq44xg/3/
调整 html 预览区域的大小以查看效果。
.editor-group {
display: inline-block;
vertical-align: top;
margin-left: 5px;
margin-right: 10px;
}
.editor-label {
min-width: 120px;
display: inline-block;
vertical-align: middle;
}
.editor-field {
min-width: 150px;
display: inline-block;
margin: 3px 0;
vertical-align: middle;
}
.field-validation-error {
background-repeat: repeat-x;
min-width: 20px;
position: absolute !important;
text-align: center;
z-index: 1000;
outline: 0 none;
background-position: center center;
background-color: #FFF4C9;
border: solid 1px #FFE79E;
color: #635145;
margin-right: 6px;
display: inline-block;
padding: 2px 5px 1px 6px;
border-radius: 4px 4px 4px 4px;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.3);
font-weight: normal;
font-size: .85em;
}
<div class="editor-group">
<div class="editor-label editor-required">
<label for="NameOfReceiptNo1">Name</label>
</div>
<div class="editor-field">
<input type="text" value="">
<span class="field-validation-error">
<span class="k-icon k-warning"></span>
Name is required
</span>
</div>
</div>
【问题讨论】:
标签: html css google-chrome firefox css-position