开发者

Using CSS, setting div class to drop to another line?

Using CSS, can I set a div class to some text on a paragraph to drop it to the line below?

I tried float: left; and it moved the text to the beginning of the paragraph which is a good start as I would want the text on the left, but I need it on the line below.

开发者_运维技巧

Here's the HTML:

<div class="tweet">
<ul class="tweet_list">
<li class="tweet_odd">
<span class="tweet_text">This is a tweet</span>
<span class="tweet_time">1 minute ago</span>
</li>
</ul>
</div>

Thanks


Add this to the div you want to drop below, it may do the trick:

 <div style="clear: both;">
  • Inline css is not optimal way though, this would be better done in a style-sheet.


Using a <div> inside of a <p> is actually semantically incorrect. You should put an inline element such as a <span> element inside of your <p> tag, and then make the <span> a block-level element.

The structure of your code would look something like this:

HTML:

<p>This is some text in your paragraph. 
<span class="newline">This text will appear on a new line.</span> 
This is some more text in a paragraph, which will also appear on a new line.</p>

CSS:

.newline {
  display: block;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜