gpt4 book ai didi

html - 将文本区域输入包裹在一个 div 周围

转载 作者:搜寻专家 更新时间:2023-10-31 08:41:15 27 4
gpt4 key购买 nike

我有一个文本区域字段,其右上角有一个 div 框。我进行了广泛的搜索,但找不到一种方法可以让输入文本区域的文本环绕 div

#wrapper {
position: relative;
width: 500px;
height: 500px;
}

#logo {
width: 100px;
height: 100px;
position: absolute;
right: 10px;
background-color: cyan;
}

textarea {
width: 100%;
height: 100%;
}
<html>

<head>
<title></title>
<meta charset="utf-8" />
</head>

<body>
<div id="wrapper">
<div id="logo">LOGO</div>
<textarea>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam acumsan fringila lacus, in rhoncus ligula pretium eu. Nulam blandit vel quam ut posuere. Sed tincidunt comodo lacinia. Vivamus eget ulamcorper sapien. Phaselus gravida pretium sem, non fringila orci luctus vel. Donec augue sapien, pharetra portitor fringila hendrerit, ultrices in telus. In aliquet laoret turpis vitae ultrices. Praesent eget nula et telus pelentesque suscipit ac eu est. Nula sed imperdiet dui. Donec eficitur est dolor, nec placerat ex posuere pretium.</textarea>
</div>
</body>

</html>

最佳答案

我发现了这个相当古老的讨论: Unusual shape of a textarea?

给出的答案是使用 contenteditable div 上的属性(property).

我设法得到这段代码,这似乎正是您要找的。

<html>

<head>
<title></title>
<meta charset="utf-8" />

<style>
#wrapper {
width: 500px;
height: 500px;
}

#logo {
width: 100px;
height: 100px;
float: right;
background-color: cyan;
}

.textarea {
width: 100%;
height: 100%;
}

<html><head><title></title><meta charset="utf-8" /><style>#wrapper {
width: 500px;
height: 500px;
}

#logo {
width: 100px;
height: 100px;
float: right;
background-color: cyan;
}

.textarea {
width: 100%;
height: 100%;
}
</style>
</head>

<body>
<div id="wrapper">
<div id="logo">LOGO</div>
<div class='textarea' contenteditable='true'>HTML</div>
</div>
</body>

</html>

</style>
</head>

<body>
<div id="wrapper">
<div id="logo">LOGO</div>
<div class='textarea' contenteditable='true'>HTML</div>
</div>
</body>

</html>

我只是替换了 <textarea><div class='textarea' contenteditable='true'>position: absolute;float:right; .

关于html - 将文本区域输入包裹在一个 div 周围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42957363/

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