1

我设置了几个不同大小的文本区域:

<textarea class="markItUp" rows="5" cols="80" name="upstring">

或者

<textarea class="markItUp" rows="100" cols="80" name="upstring">

但是在应用标记后,它们总是被调整为 18 行。为什么?

我已经检查了带有 firebug 的行并且它没有改变(仍然是 5 或 100),所以改变它不会有帮助。

由于我有很多文本,我想对我做一些小的编辑,因为我已经知道合适的大小,所以我不知道从小到大的区域开始。

请帮忙

4

2 回答 2

6

经过一番了解后,我生成了以下代码来解决我的问题:

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]
});
于 2009-10-19T12:34:18.393 回答
3

CSS 规则通常会覆盖 rows 和 cols 属性,因此不要依赖这些属性,而是尝试使用 css 'height' 和 'width' 来调整 textareas 的大小。

于 2009-10-19T09:50:30.580 回答