我在一个直接放在输入字段顶部的范围内复制输入字段值。 (这样做只能操作部分文本)
我遇到溢出问题。
有没有办法让跨度像输入字段一样,并在添加越来越多的字符时将文本向左滚动?
当前跨度样式:
style="display: inline-block; position: absolute; top: 0.25px; left: 2px; padding: 1px; z-index: 2; pointer-events: none;"
修改
<div style="position: relative;" class="input-box">
<input style="color: transparent; caret-color: black; z-index: 1;" type="text" name="street[]" id="street_1" class="street
input-text"/>
<span id="street1span" class="input-text" style="display: inline-block; width: 100%; position: absolute; top: 0.25px; left: 2px; padding: 1px; z-index: 2; pointer-events: none;" ></span>
</div>
答案 0 :(得分:3)
试试这个:
span {
border: 1px solid #CCC;
width: 200px;
display: inline-block;
white-space: nowrap;
overflow: hidden;
}
input[type="text"] {
width: 200px;
}
Span :<span contenteditable="true"></span>
<br><br>
Input:<input type="text" name="">
编辑帖子后
span {
position: absolute;
top: 100px;
left: 2px;
padding: 1px;
z-index: 2;
border: 1px solid #CCC;
width: 200px;
height: 20px;
display: inline-block;
white-space: nowrap;
overflow: hidden;
}
<div style="position: relative;" class="input-box">
<input style="color: #000; caret-color: black; z-index: 1;" type="text" name="street[]" id="street_1" class="streetinput-text"/>
<span id="street1span" contenteditable="true" class="input-text" >
</span>
</div>
答案 1 :(得分:1)
试试这个:
* {
font-family: Arial, sans-serif;
font-size: 12px;
}
input {
display: inline-block;
position: absolute;
top: 0.25px;
left: 2px;
padding: 1px;
overflow-x:auto
}
<div class="row">
<input type="text" placeholder="something span" />
</div>
答案 2 :(得分:0)
您可以在范围中添加overflow-x:auto;
答案 3 :(得分:0)
你可以做到
HTML
<span id="flow"></span>
CSS
.flow{
overflow : hidden/auto; // depending on your choice
}
答案 4 :(得分:-2)
试试这个:
<div style="position: relative;" class="input-box">
<input style="color: transparent; caret-color: black; z-index: 1;" type="text" name="street[]" id="street_1" class="street
input-text"/>
<br /><br /><br />
<hr />
<span id="street1span" class="input-text" style="display: inline-block; width: 100%; padding: 1px; border:1px solid #ccc; width:300px; overflow-x:scroll;" > hellhellhellhellhellhellhellhellhellhellhellhellhellhello</span>
</div>