How can I stop float left?

CssHtmlCss Float

Css Problem Overview


I have the following code:

<div style="float: left; width: 100%;">
  <label style="float: left;">ABC</label>  
  <input style="float: left; font-size: 0.5em;" type="button"   onclick="addTiny(0,'Question_Text'); return false;" value="&#x25BC;" title="Editor" />   
  <input style="float: left; font-size: 0.5em;" type="button" onclick="remTiny(0,'Question_Text'); return false;" value="&#x25B2;" title="Hide" />   

  <div class="adm">
    <textarea rows="2;" style="width: 100%" class="text-box multi-line mceEditor">
      abc
    </textarea>
  </div>
</div>

My problem is that the div with class adm floats to the left and so goes on the same line as the label and two input buttons. Is there a way that I can make this shift away from floating?

Css Solutions


Solution 1 - Css

A standard approach is to add a clearing div between the two floating block level elements:

<div style="clear:both;"></div>

Solution 2 - Css

Sometimes clear will not work. Use float: none as an override

Solution 3 - Css

You could modify .adm and add

.adm{
 clear:both;
}

That should make it move to a new line

Solution 4 - Css

add style="clear:both;" to the "adm" div.

Solution 5 - Css

Okay I just realized the answer is to remove the first float left from the first DIV. Don't know why I didn't see that before.

Solution 6 - Css

You should also check out the "clear" property in css in case removing a float isn't an option

Solution 7 - Css

The css clear: left in your adm class should stop the div floating with the elements above it.

Solution 8 - Css

For some reason none of the above fixes worked for me (I had the same problem), but this did:

Try putting all of the floated elements in a div element: <div class="row">...</div>.

Then add this CCS: .row::after {content: ""; clear: both; display: table;}

Solution 9 - Css

Just add overflow:hidden in the first div style. That should be enough.

Solution 10 - Css

There's a class in bootstrap for it

class="clearfix";

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTonyGView Question on Stackoverflow
Solution 1 - CssShadView Answer on Stackoverflow
Solution 2 - CssDanKodiView Answer on Stackoverflow
Solution 3 - CssBrettView Answer on Stackoverflow
Solution 4 - CsstjmView Answer on Stackoverflow
Solution 5 - CssTonyGView Answer on Stackoverflow
Solution 6 - CssTreyView Answer on Stackoverflow
Solution 7 - CssChris KentView Answer on Stackoverflow
Solution 8 - CssezgorView Answer on Stackoverflow
Solution 9 - CsssunnyView Answer on Stackoverflow
Solution 10 - CssTS71MView Answer on Stackoverflow