Javascript 如何在TejTaReA的中间设置默认光标插入/在焦点上垂直输入

Javascript 如何在TejTaReA的中间设置默认光标插入/在焦点上垂直输入,javascript,php,jquery,html,css,Javascript,Php,Jquery,Html,Css,我想知道如何使用javascript/css在两行占位符文本之间设置默认光标位置,以便用户输入可以在输入字段中垂直居中(我认为这样看起来更好) 下面是演示 <textarea id="topic_title_input" placeholder="Hi there, I want the cursor caret starts in the middle of these two lines (veritcally) when onfocus"></textarea>

我想知道如何使用javascript/css在两行占位符文本之间设置默认光标位置,以便用户输入可以在输入字段中垂直居中(我认为这样看起来更好)

下面是演示

<textarea id="topic_title_input" placeholder="Hi there, I want the cursor caret starts in the middle of these two lines (veritcally) when onfocus"></textarea>



<style>
#topic_title_input{
    font-size: 20;
    border-color: orange;
    color:black;
    background-color: white;
    /*text-indent:10px;*/
    border:1px solid orange;
    width:521px;
    height:60px;
    outline:none;
    border-radius:3px;
    resize:none;
    padding:7px;
}
</style>

#主题\标题\输入{
字号:20 ;;
边框颜色:橙色;
颜色:黑色;
背景色:白色;
/*文本缩进:10px*/
边框:1px实心橙色;
宽度:521px;
高度:60px;
大纲:无;
边界半径:3px;
调整大小:无;
填充:7px;
}

我不太确定我是否明白你的要求,但无论如何这很有趣。这假定你想实际使用占位符文本,并将插入符号插入中间。第二个是试图辨别你所说的“垂直”是什么意思

var input=document.getElementById('topic\u title\u input');
var inputSpace=document.getElementById('topic_title_alt');
//概念证明。将吹出每个焦点上的现有文本!
addEventListener('focus',updateExtArea);
inputSpace.addEventListener('focus',带break);
函数updateTextArea(e){
var值,pos;
value=input.getAttribute(“占位符”);
//放在你想放的任何地方
pos=值indexOf('middle');
input.value=值;
//普通浏览器和IE9+:
输入。设置选择范围(位置,位置);
}
带中断的函数(e){
var值、pos、splitVal、newVal;
value=inputSpace.getAttribute(“占位符”);
//放在你想放的任何地方
pos=值indexOf('middle');
newVal=value.substring(0,pos)+“\r\n\r\n”;
newVal+=值。子字符串(位置)
inputSpace.value=newVal;
//普通浏览器和IE9+:
输入空间设置选择范围(位置+1,位置+1);
}
textarea{
字号:20 ;;
边框颜色:橙色;
颜色:黑色;
背景色:白色;
/*文本缩进:10px*/
边框:1px实心橙色;
宽度:521px;
高度:60px;
大纲:无;
边界半径:3px;
调整大小:无;
填充:7px;
}
在“中间”插入
这种空间?

现在说什么?可能包括你的意思的图像(以及你尝试过的任何代码)?