我有这个简单的文本区域。当它没有被选中时,我希望它看起来像一个成品(即侧面逐渐变细到文本)。我也想让用户改变宽度。我怎样才能使用 autoresize 插件来做到这一点?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Pathway Builder</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<textarea class="text_field_not_selected"></textarea>
<script src="jQuery.js" type="text/javascript"></script>
<script src="selectors.js" type="text/javascript"></script>
</body>
</html>
javascript/jQuery
$('textarea').bind('focusin blur', function() {
$(this).toggleClass('text_field_not_selected');
});
$('textarea').autoResize();
CSS
body {
display: block;
}
textarea:focus {
outline: none;
text-align: center;
}
.text_field_not_selected {
text-align: center;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
-moz-box-shadow: 0px 3px 5px #444;
-webkit-box-shadow: 0px 3px 5px #444;
padding: 5px;
}
最佳答案
对于第一部分,你可以使用类似的东西
border-style: none;
对于第二部分,您只需单击并拖动文本框的右下角并调整其大小
关于javascript - 尝试使用自动调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9848301/