gpt4 book ai didi

jquery - 文本框展开时文本框背景不跟随

转载 作者:行者123 更新时间:2023-11-28 07:25:55 26 4
gpt4 key购买 nike

我已经为我的文本框应用了背景,当我添加 .resizeable() jQuery 时效果很好。但是,当文本框因用户输入更多单词/字符而扩展时,背景不会随文本框一起扩展。忽略 main-note 类,这不是问题所在。

JS

$(function() {
$(".note").resizable();
$(".main-note" || ".note").draggable();
$(".main-note-editable" || ".note").on("mousedown", function(e) {
e.stopPropagation();
return;
});
});

HTML

<div class="note" contenteditable="true">
<span id='close' onclick='this.parentNode.parentNode.removeChild(this.parentNode)'>
<img height="30" src="images/close.png" width="30">
</span>

<div class="note" contenteditable="true">
<span id='close' onclick='this.parentNode.parentNode.removeChild(this.parentNode)'>
<img height="30" src="images/close.png" width="30">
</span>
</div>
</div>

CSS

.note {    
width: 280px;
height: 130px;
padding-top: 20px;
margin-top: 60px;
margin-left: 25px;
padding: 2;
word-break: break-word;
font-family: Note;
font-size: 20px;
background-image: url("images/stickynote.png");
background-repeat: no-repeat;
background-size: 100% 100%;
z-index: 1;
}

最佳答案

这对我有用:

$(".note").keyup(function(){
$(this).css('height' , '100%');
});

HTML:

 <div class="note" contenteditable="true"> <span contenteditable='false' id='close' onclick='this.parentNode.parentNode.removeChild(this.parentNode)'>
<img src="http://iconizer.net/files/Brightmix/orig/monotone_close_exit_delete.png" height="30" width="30"/></span>
</div>

Here is the JSFiddle demo

关于jquery - 文本框展开时文本框背景不跟随,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31819358/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com