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
- 2. 讓div填滿中心容器旁邊的空間
- 3. 渲染DIV旁邊的href
- 4. 圖片旁邊的中心文字
- 5. 固定的div旁邊的居中格
- 6. 固定div旁邊的父div
- 7. div浮動到居中div旁邊的右邊?
- 8. 做出一個textarea標籤旁邊去,但在中心垂直對齊
- 9. 另一個div位於主div旁邊
- 10. Div旁邊div沒有使用浮動
- 11. CSS在div旁邊放置div
- 12. Div#1旁邊的Div Div#2和Div#3
- 13. 浮動複選框旁邊的div
- 14. 定位div旁邊的海誓山盟
- 15. 股利旁邊的div圖像
- 16. 如何對齊div旁邊的文本?
- 17. div旁邊的圖像 - 浮動重疊
- 18. 居中文本垂直旁邊的一行textarea?
- 19. DIV旁邊的DIV保持DIV在尺寸變化
- 20. div的邊框上的中心圖像
- 21. 如何將這個DIV浮在旁邊?
- 22. fadeToggle div,通過點擊它旁邊
- 23. Div在固定格子旁邊
- 24. 對齊DIV旁邊和另一個
- 25. 無法在div旁邊添加文字
- 26. 如何在div中使用jquery在mouseover旁邊定位div?
- 27. 行中引導按鈕旁邊的中心文本
- 28. HTML垂直中心文本旁邊的我的標誌?
- 29. 靈活的寬度div旁邊的固定寬度div
- 30. 按鈕應在中心和桌面旁邊的按鈕,在中心
你能不能給你想要達到什麼樣的圖像?謝謝:) –
@shub檢查更新的答案 –
@shub - 正在爲你工作???? –