html - Break text on the left before breaking float on the next line -
i have code this: https://jsfiddle.net/qchtngzf/1/
and now, when browser narrow, div.right
(the text on right) jumps onto next line. to, however, if div.left
(the text on left) smaller , text inside break onto next line , div.right
stay in same place instead.
i found similar issue here: making div float left, not "fall" if text long it's little different , doesn't work me changes tried.
thank you.
you should set width both of them right , left
class:
html, body, header, nav, footer, div, p, ul, li, { margin: 0; padding: 0; text-decoration: none; font-family: sans-serif; font-size: 18px; } .left { width: 80%; float: left; position: relative; } .right { width: 10%; } .clearfix:after { content: ""; display: block; clear: both; } hr { border: 0; height: 1px; background-color: #e9e9e9; margin: 16px 0; } section.body { max-width: 960px; min-width: 272px; } div.left { color: #1e344c; float: left; } div.left span { font-size: 14px; color: #666666; } div.right { float: right; }
<section class="body"> <div class="item clearfix"> <div class="left"> text text text text text text text text text text text text text text </div> <div class="right">text </div> </div> <hr> <div class="item clearfix"> <div class="left"> text text text text text text text text text text <br> <span>text text text text text </span> </div> <div class="right">text </div> </div> <hr> <div class="item clearfix"> <div class="left"> text text text text text text text text text </div> <div class="right">text </div> </div> <hr> <div class="item clearfix"> <div class="left"> text text text text text <br> <span>text text text text text text text text text text text text text text text </span> </div> <div class="right">text </div> </div> <hr> <div class="item clearfix"> <div class="left"> text text text text text text text <br> <span>text text text text text text text </span> </div> <div class="right">text </div> </div> <hr> <div class="item clearfix"> <div class="left"> text text text text text text text text text <br> <span>text text text text text text </span> </div> <div class="right">text </div> </div> </section>
Comments
Post a Comment