有人可以告诉我为什么当我点击此Fiddle中的编辑时,星号没有与输入字段对齐但显示在底部。
CSS
.required-field::after {
display: none;
content: "*";
color: red;
font-size: 23px;
margin-left: 5px;
}
JS
$("p").on('click', function(){
var $style = $('<style>');
$style.appendTo('head');
var base = ".required-field::after{display:block;}";
$style.html(base);
});
由于
答案 0 :(得分:0)
您必须使用display:inline
而不是阻止
$("p").on('click', function(){
var $style = $('<style>');
$style.appendTo('head');
var base = ".required-field::after{display:inline;}";
$style.html(base);
});
&#13;
.required-field::after {
display: none;
content: "*";
color: red;
font-size: 23px;
margin-left: 5px;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='mvnDefinitionInput required-field'>
<input type='text' class='mvnDefinitionFieldExtraInput'/>
</div>
<p class='editDefMVN"'><span>Edit</span></p>
&#13;