开发者

How can I get the post text to be beside the avatar and not below it?

So I'm trying to create a forum with avatars, but right now the text is going below the avatars and not beside them. How can I fix this?

Here is the CSS:

.postbox{
    text-align: left;
    margin: auto;
    background-color: #dbfef8;
    border: 1px solid #82FFCD;
    width: 100%;
    margin-top: 10px;
}   

.postfooter{
    width: 100%;
    border-top: 1px solid #82FFCD;
}

.postheader{
    width: 100%;
    border-bottom: 1px solid #82FFCD;
}

.posttext{
    width: 70%;
    text-align: left;
    border: 1px solid #82FFCD;
}

.postavi{   
    width: 20%;
    text-align: left;
    border: 1px solid #82FFCD;
}

and here is the html:

<div class="postbox"><div class="postheader">
                            <b><span>CyanPrime!!~::##Admin##::~</span></b>

                        </div>
                        <div class="postavi"><img src="http://prime.programming-designs.com/test_for开发者_如何学JAVAum/images/avatars/hacker.png" alt="hacker"/></div><div class="posttext">Let's test the Hacker Avatar.</div>
                        <div class="postfooter">
                            [<a href="http://prime.programming-designs.com/test_forum/viewthread.php?thread=25">Reply</a>] 0 posts omitted.
                        </div>
                    </div>


You can wrap your divs in a container div and float everything left. Remember to clear your floats.

.clear { clear: both; }

.posttext{
    float: left;
    width: 70%;
    text-align: left;
    border: 1px solid #82FFCD;
}

.postavi{
    float: left;
    width: 20%;
    text-align: left;
    border: 1px solid #82FFCD;
}


<div>
  <div class="postavi"><img src="http://prime.programming-designs.com/test_forum/images/avatars/hacker.png" alt="hacker"/></div>
  <div class="posttext">Let's test the Hacker Avatar.</div>
  <br class="clear"/>
</div>


This should do it:

.postavi{ float: left}


Add the CSS "float: left;" to the element that must allow the text to be placed side-by-side.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜