Bec*_*cky 10 html javascript css jquery
我试图找出如何为a border-bottom中的每一行添加一行<textarea>,但是我只能得到最底行border-bottom来执行此操作.
有没有办法实现这个目标?
.input-borderless {
width: 80%;
border-top: 0px;
border-bottom: 1px solid green;
border-right: 0px;
border-left: 0px;
background-color: rgb(241,250,247);
text-decoration: none;
outline: none;
display: block;
padding: 10px 0;
margin: 20px 0;
font-size: 1.6em;
}Run Code Online (Sandbox Code Playgroud)
<textarea rows="3" class="input-borderless" placeholder="Describe the project"></textarea>Run Code Online (Sandbox Code Playgroud)
想法是使用图层,将textarea作为顶层,将多行作为底层.
我使用的底层伪元素,因为:before和:after上一个不工作textarea,所以我将它设置在容器上div的元素.
对于底线,我只使用下划线_,\A对于换行符,您可以根据需要使用多个行 \A.每行的高度将根据字体大小自动更新.
.container {
width: 200px;
border: 1px solid green;
position: relative;
overflow: hidden;
}
.container:before, .container textarea {
font-family: sans-serif;
font-size: 20px;
}
.container textarea {
width: 100%;
box-sizing: border-box;
background-color: transparent;
border: 0;
outline: none;
display: block;
line-height: 1.2;
}
.container:before {
position: absolute;
content: "____________________\A____________________";
z-index: -1;
left: 0;
top: 0;
width: 100%;
color: silver;
line-height: 1.4;
}Run Code Online (Sandbox Code Playgroud)
<div class="container">
<textarea rows="3" placeholder="Hello"></textarea>
</div>Run Code Online (Sandbox Code Playgroud)
您可以使用渐变作为背景图像来获得看起来像下划线的效果:
textarea
{
line-height: 4ch;
background-image: linear-gradient(transparent, transparent calc(4ch - 1px), #E7EFF8 0px);
background-size: 100% 4ch;
}
Run Code Online (Sandbox Code Playgroud)
您的问题说您希望a 中的每一行都有一行,border-bottom<textarea>所以我的答案可能无法完全满足您的需求。如果它对您或其他人有用,我会将其发布。
textarea { text-decoration: underline; }Run Code Online (Sandbox Code Playgroud)
<textarea></textarea>Run Code Online (Sandbox Code Playgroud)
示例输出: