[英]How can I lay out two <div>s on one line, and have one centre-aligned (relative to the entire line) and the other right-aligned?
[英]How can I have two DIV s on the same line , one aligned to the left and one aligned to the right without an HTML table?
我想要的是表決分隔符,而與類別名稱為“ note”的文章的文本大小無關。 如果我分配會發生什么
<div class="votediv" style="right:0; position:relative">
在CSS上?
<div class="opiniondiv">
<article class="opinion"></article>
<div class="opiniondetail">
<article class="note"></article>
<div class="votediv">
<form method="POST">
<button class="agreebutton" value="1">Agree</button>
<button class="disagreebutton" value="0">Disagree</button>
</form>
</div>
</div>
</div>
另外,我想不用
display:table
為了使<div class="votediv" style="right:0">
起作用,您必須在樣式中添加position: absolute
。 然后,您可能需要添加position: relative
對於div.opiniondiv
。
而且,如果您要像其他人建議的那樣使div浮動,請不要忘記清除,否則您將一團糟。
<style>
.votediv{
float: right;
width: 50%;
}
.opiniondiv{
float: left;
width: 50%;
}
</style>
50%的寬度假定它們都在同一個父容器中。 它們需要具有一個固定的寬度才能正常工作,並且顯然,它們的組合寬度不得大於其父級。
您可以使用float: left
和float: right
分別將元素浮動到那些邊。
<style type='text/css'>
.votediv { float: right; }
.opiniondiv { float: left; }
</style>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.