html - How can I avoid text that is exceeding DIV's width limits -
i have parent div structure uses "display: inline-block" , "position:absolute". !important , cannot changed!
but.. in child's floated left div, text exceeding width.
how can avoid behavior?
fiddle: https://jsfiddle.net/s8a818vw/
css:
#main { width:100%; height:400px; overflow: hidden; white-space: nowrap; background:pink; } .sub { width:600px; display: inline-block; height:400px; position:absolute; margin-left: auto; margin-right: auto; left: 0; right: 0; } .sub-text { width:70%; height:100%; float:left; background:lime; overflow: none; } .sub-img { width:30%; height:100%; float:right; background:red; display:flex; flex-direction: row; flex-wrap: nowrap; justify-content: center; align-content: flex-end; align-items: center; }
html:
<div id="main"> <div class="sub"> <div class="sub-text"> <h1>header</h1> <p>lorem ipsum dolor sit amet, consectetur adipiscing elit. fusce sit amet tellus vitae nisi feugiat malesuada. phasellus semper vehicula ante. pellentesque ut finibus nisl. cras tempus, eros ut aliquam mollis, metus diam efficitur neque, non pellentesque eros mi felis. in lectus ipsum, rutrum @ risus eget, faucibus sodales ipsum. nam vel interdum libero. donec ac lacus interdum, rutrum neque sit amet, vestibulum tellus.</p> <a href="#">my link</a> </div> <div class="sub-img">img 1</div> </div> </div>
this issue here you've set white-space: nowrap;
on #main
. that's being inherited p
tag , causing text not wrap.
setting white-space
normal
cause text wrap you'd expect.
.sub-text{ white-space: normal; }
Comments
Post a Comment