最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ReactJS: How to make <div> float not affect the next <div>? - Stack Overflow

programmeradmin5浏览0评论

I currently have:

<div style={{float:'left'}}>Left</div>
<div style={{float:'right'}}>Right</div>
<div>Below</div>

I was able to get Left and Right to be on the opposite ends like intended on the same line, but the Below is also affected, and floats to the left, right next to Left, even though float has not been defined for it.

So I was wondering how to keep Below on the next line, without being affected by the previous floats?

I currently have:

<div style={{float:'left'}}>Left</div>
<div style={{float:'right'}}>Right</div>
<div>Below</div>

I was able to get Left and Right to be on the opposite ends like intended on the same line, but the Below is also affected, and floats to the left, right next to Left, even though float has not been defined for it.

So I was wondering how to keep Below on the next line, without being affected by the previous floats?

Share Improve this question asked Aug 17, 2016 at 20:27 Jo KoJo Ko 7,57516 gold badges68 silver badges128 bronze badges 1
  • Just a note: the situation is not actually react-specific, its mostly about HTML and would behave the same way in the browser regardless of how it was produced. – Ivan Kolmychek Commented Aug 17, 2016 at 20:55
Add a ment  | 

2 Answers 2

Reset to default 9

You should clear the last div. Try this:

<div style={{clear:'both'}}>Below</div>

Have you tried clearing that last div?

clear: both
发布评论

评论列表(0)

  1. 暂无评论