gpt4 book ai didi

css - 将 float div 右对齐

转载 作者:太空宇宙 更新时间:2023-11-04 04:37:25 24 4
gpt4 key购买 nike

我有以下 HTML:

<body>
<div id="postwrapper">
<div class="posterinfo">
Username<br />
<img src="http://board.ogame.nl/wcf/images/avatars/avatar-3778.gif" alt="avatar" /><br />
Postcount
</div>
<div class="postcontent">
Hi there everyone!<br /><br />
This is a sample text to test my post-layout's divs
<br />
Some text...<br />
Some text...<br />
Some text...<br />
Some text...<br />
Some text...<br />
Some text...<br />
As you can see untill here it's all going fine but:.<br /><br />
Here the text starts completely at the left..<br />
But it shouldn't..<br />
It should start at the same place as above.. Right from the div where the avatar is...<br />
blabla<br />
</div>
<div class="postersignature">
This signature should stay at the completely bottom of the postwrapper and should also be start at the right of the avatar div
</div>
</div>

</body>

使用这个 CSS:

html,body {margin:0;padding:0;height:100%;}
#postwrapper {
width:100%;
height:auto;
}
.posterinfo {
float:left;
height: auto;
margin-right:10px;
background: #222222;
}
.postcontent {
margin-top:10px;
margin-bottom: 0px;
height: 100%;
background: #333333;
word-wrap: break-word;
}
.postersignature {
height:auto;
width: 100%;
margin-bottom: 0;
bottom:0;
background: #442222;
}

但现在 de postcontent 中的文本从 div 的完全左侧开始(在向左浮动的 posterinfo div 下方)但如果文本太长而无法放在一边,我想防止它位于图像下方.

我在这里说明了这一点:http://jsfiddle.net/BsftM/

我怎样才能做到这一点?

最佳答案

添加以下样式:

.postcontent { float: left; }
.postersignature { clear: both; }

http://jsfiddle.net/BsftM/5/

关于css - 将 float div 右对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16083804/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com