如何使用 Bootstrap 表单控件 class 自动调整内容大小来使内容可编辑 div?
How to make contenteditable div with Bootstrap form-control class auto resize for content?
当我将 "form-control" class 添加到 contenteditable div 时,div 的自动调整大小功能似乎中断了。尝试向 div 添加新行,您将在代码段中看到。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<div class="container">
<p>
1st with form-control class
</p>
<div autofocus class="col-md-12 sol-sm-12 form-control" contenteditable="true">Lorem Ipsum Dolor
</div>
<p>
2nd without it
</p>
<div autofocus class="col-md-12 sol-sm-12" contenteditable="true">Lorem Ipsum Dolor
</div>
</div>
.form-control
元素的 height
被 'bootstrap.min.css' 设置为 34px
。您需要使用
覆盖它
.container .form-control {
height: auto;
}
希望对您有所帮助。
当我将 "form-control" class 添加到 contenteditable div 时,div 的自动调整大小功能似乎中断了。尝试向 div 添加新行,您将在代码段中看到。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<div class="container">
<p>
1st with form-control class
</p>
<div autofocus class="col-md-12 sol-sm-12 form-control" contenteditable="true">Lorem Ipsum Dolor
</div>
<p>
2nd without it
</p>
<div autofocus class="col-md-12 sol-sm-12" contenteditable="true">Lorem Ipsum Dolor
</div>
</div>
.form-control
元素的 height
被 'bootstrap.min.css' 设置为 34px
。您需要使用
.container .form-control {
height: auto;
}
希望对您有所帮助。