Эта текстовая область является текстовой областью с автоматическим расширением, которая перестает расширяться, если она имеет высоту 4 строки.
проблема mac http://dl.dropbox.com/u/8196173/mac_problem.PNG версия windows http://dl.dropbox.com/u/8196173/windows_version.PNG
Итак, слева показано, как текстовое поле отображается на Mac с помощью Google Chrome, а справа - как оно отображается в Windows. Версия для Windows является правильной. По какой-то причине Chrome на Mac не добавляет одинаковую величину высоты к текстовой области каждый раз, когда расширяется, что означает, что он становится меньше и, следовательно, дополнительное пространство внизу. Но я не знаю, почему он так себя ведет, просто потому что на другой ОС.
Я могу включить код, если люди действительно хотят его, но его почти сто строк (есть другие вещи, которые перемещаются на странице, когда он расширяется), и я, честно говоря, не понимаю, как это может быть код, так как он работает на Windows и проявляет странное поведение только на osX.
Редактировать: это происходит внутри расширения Chrome, если это имеет значение.
var temp = 0;
//function that actually handles the resizing
function resize() {
temp = text.style.height;
text.style.height = 18;
text.style.height = text.scrollHeight + 'px';
var styledef = window.getComputedStyle(text);
pixelMargin = parseInt(styledef.marginTop, 10);
num = parseInt(container.style.height, 10);
re_num = parseInt(reply_container.style.marginTop, 10);
var temp_num = parseInt(temp, 10);
text_height = parseInt(text.style.height, 10);
if(temp_num == 0) { //if nothing has been done in the text area do this
temp = text.style.height;
} else if(text_height == 18) { //else if the text area is only one line do this
text.style.marginTop = '3';
reply_container.style.marginTop = '0px';
container.style.height = '364px';
container.scrollTop = container.scrollHeight;
} else if(temp_num < text_height) { //else the box is getting bigger
if(text_height <= 66 ) {
pixelMargin -= 15;
num -= 16;
re_num += 16;
conversation_scroll_pos += 16;
text.style.marginTop = pixelMargin.toString() + 'px';
container.style.height = num.toString() + 'px';
reply_container.style.marginTop = re_num.toString() + 'px';
container.scrollTop = container.scrollHeight;
temp = text.style.height;
} else if(text_height >= 66 && temp_num > 20) { //case where the box has reached its max height and the user is still typing
temp = text.style.height;
} else if(text_height > 66 && pixelMargin == 3) { //edge case to handle cuting and pasting into the box
text.style.marginTop = '-42px';
reply_container.style.marginTop = '48px';
container.style.height = '316px';
container.scrollTop = container.scrollHeight;
temp = text.style.height;
}
} else if(temp_num > text_height) { //else the box is getting smaller
if(pixelMargin < 3 && pixelMargin >= -45 && text_height < 66) {
pixelMargin += 15;
num += 16;
re_num -= 16;
text.style.marginTop = pixelMargin.toString() + 'px';
container.style.height = num.toString() + 'px';
reply_container.style.marginTop = re_num.toString() + 'px';
temp = text.style.height;
}
}
}