0
A
回答
1
嘗試用這種
<div style="display:table">
<label for="textarea">Description</label><br>
<textarea id="textarea" style="display: table-cell;"></textarea>
<div style="vertical-align: middle; display: table-cell; width:100px; text-align:center; border:#f00 1px solid;">Text</div>
</div>
也爲您在Fiddle
0
您可以使用JavaScript來獲取文本區域的高度,更新的右側的行高,設置文本對齊爲中心
2
純CSS
這可能是工作爲您提供:
<html>
<head>
<title>
</title>
<style type="text/css">
/* style here */
div#main{
position:relative;
vertical-align:middle;
}
textarea{
}
div.right{
position:absolute;
top:45%;
right:0px;
width: 100px;
}
</style>
</head>
<body>
<div id="main">
<textarea></textarea>
<div class="right">
TEXT
</div>
</div>
</body>
</html>
JavaScript解決方案:
這可能會爲你工作:
讓我知道,如果這樣做的伎倆。
<script type="text/javascript">
jQuery(document).ready(function(){
// set init (default) state
var t = jQuery('#text_area');
t.data('x', t.outerWidth());
t.data('y', t.outerHeight());
t.mouseup(function(){
var th = jQuery(this);
if (th.outerWidth()!= th.data('x') || th.outerHeight() != th.data('y'))
// set new height/width
th.data('x', th.outerWidth());
th.data('y', th.outerHeight());
$("#center_text").css("margin-top", (th.outerHeight()/2 - 20) + "px");
});
});
</script>
相關問題
- 1. Div旁邊的div
- 2. ExtJS的: '旁邊的中心'
- 3. 在頁面中心的海誓山盟旁邊的兩個div
- 4. 讓div填滿中心容器旁邊的空間
- 5. Div的旁邊彼此
- 6. 渲染DIV旁邊的href
- 7. 圖片旁邊的中心文字
- 8. 中心UIButton與它旁邊的圖像
- 9. 文本爲中心的旁邊,圖像
- 10. 固定的div旁邊的居中格
- 11. 子div旁邊的父div,在底部
- 12. 固定div旁邊的父div
- 13. div浮動到居中div旁邊的右邊?
- 14. 做出一個textarea標籤旁邊去,但在中心垂直對齊
- 15. Div中心在屏幕上,並在它旁邊另一個內聯div
- 16. Div旁邊div沒有使用浮動
- 17. 另一個div位於主div旁邊
- 18. 底部對齊div浮動div旁邊
- 19. 固定DIV旁邊5流體DIV
- 20. CSS在div旁邊放置div
- 21. Div#1旁邊的Div Div#2和Div#3
- 22. 浮動複選框旁邊的div
- 23. div旁邊的圖像 - 浮動重疊
- 24. 股利旁邊的div圖像
- 25. div的位置放在FORM旁邊
- 26. 填充旁邊的div,如表
- 27. 對齊列表項旁邊的div
- 28. 定位div旁邊的海誓山盟
- 29. 如何對齊div旁邊的文本?
- 30. 居中文本垂直旁邊的一行textarea?
你能不能給你想要達到什麼樣的圖像?謝謝:) –
@shub檢查更新的答案 –
@shub - 正在爲你工作???? –