как автоматически изменить размер столбца и строки

0

я нашел много статей, относящихся к автоматическим изменениям строк и столбцов, таких как коды CSS ниже:

   textarea[readonly="readonly"], textarea[readonly] { background-color:white; }
    float colWidth = [[[tableView tableColumns] objectAtIndex:1]width];
    NSString *content = [[[tempArray objectAtIndex:row] objectForKey:@"tValue"] string];
    float textWidth = [content sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"Lucida Grande" size:15],NSFontAttributeName ,nil]].width;
    float newHeight = ceil(textWidth/colWidth);
    newHeight = (newHeight * 17) + 13;
            if(newHeight < 47){
                return 47;
            }   
            return newHeight;
            table {
      width: 700px;
    }

а также

table tr td {
  width: 350px;
  height: auto;
}

Но с моим кодом ничего не работает

Вот мой код таблицы, и я хочу, чтобы он автоматически изменялся на основе данных, которые будут извлекаться из базы данных:

$myRes = "<form action='' method='post'>
          <fieldset style='width: 10px'>
          <legend align='left'><strong>Results</strong></legend>
          <p>
          <table width='auto' border='1' cellspacing='1' cellpadding='1' align='center'>
          <tr>
          <th align='center' scope='row'>A</th>
          <td><textarea class=readonly name=testA id=testA cols=65 rows=3>" . $result['testA'] . "</textarea></td>
          </tr>
          <tr>
          <th scope='row'>B</th>
          <td><textarea class=readonly name=testB id=testB cols=65 rows=3>" . $result['testB'] . "</textarea></td>
          </tr>
          </table>
          </p>
          </fieldset>
          </form>";
Теги:

1 ответ

0

попробуйте следовать:

$("textarea").height( $("textarea")[0].scrollHeight );

или

window.setTimeout( function() {
    $("textarea").height( $("textarea")[0].scrollHeight );
}, 1);​
  • 0
    Любая идея, как я могу реализовать ваш код или включить его в свой код?

Ещё вопросы

Сообщество Overcoder
Наверх
Меню