How can I stop float left?
CssHtmlCss FloatCss 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="▼" title="Editor" />
<input style="float: left; font-size: 0.5em;" type="button" onclick="remTiny(0,'Question_Text'); return false;" value="▲" 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";