Jquery markitup是否更改textarea的显式设置大小?
我设置了几个不同大小的textarea,如下所示:Jquery markitup是否更改textarea的显式设置大小?,jquery,markitup,Jquery,Markitup,我设置了几个不同大小的textarea,如下所示: <textarea class="markItUp" rows="5" cols="80" name="upstring"> 或 但在应用标记后,它们的大小始终调整为18行。为什么? 我已经用firebug检查了行,但它没有改变(仍然是5行或100行),所以更改它不会有帮助 因为我有很多文本,我想做一些小的编辑,我不知道从什么地方开始,因为我已经知道了合适的大小 请提供帮助CSS规则通常会覆盖行和列属性,因此,与其依赖这些
<textarea class="markItUp" rows="5" cols="80" name="upstring">
或
但在应用标记后,它们的大小始终调整为18行。为什么?
我已经用firebug检查了行,但它没有改变(仍然是5行或100行),所以更改它不会有帮助
因为我有很多文本,我想做一些小的编辑,我不知道从什么地方开始,因为我已经知道了合适的大小
请提供帮助CSS规则通常会覆盖行和列属性,因此,与其依赖这些属性,不如尝试使用CSS的“高度”和“宽度”调整文本区域的大小。CSS规则通常会覆盖行和列属性,而不是依赖这些属性,尝试使用css“height”和“width”来调整文本区域的大小。在了解一些事情之后,我生成了以下代码来解决我的问题:
jQuery(".markItUp").markItUp(mySettings).css('height', function() {
/* Since line-height is set in the markItUp-css, fetch that value and
split it into value and unit. */
var h = jQuery(this).css('line-height').match(/(\d+)(.*)/)
/* Multiply line-height-value with nr-of-rows and add the unit. */
return (h[1]*jQuery(this).attr('rows'))+h[2]
});
为了理解一些事情,我编写了以下代码来解决我的问题:
jQuery(".markItUp").markItUp(mySettings).css('height', function() {
/* Since line-height is set in the markItUp-css, fetch that value and
split it into value and unit. */
var h = jQuery(this).css('line-height').match(/(\d+)(.*)/)
/* Multiply line-height-value with nr-of-rows and add the unit. */
return (h[1]*jQuery(this).attr('rows'))+h[2]
});