Wrap Text Around Both Sides Of Div
Here is what I try to achieve: With the following HTML:
some text
Awesome content
Solution 1:
Looks like you want something like float:center ? Well, the problem is that this property doesn't exist.
Here are 2 alternatives:
1) Fake it with pseudo elements - FIDDLE - See this css-tricks article
Set up markup like so:
<div><divid="wrap">Awesome content</div><divid="l"><p>left text here</p></div><divid="r"><p>right text here</p></div></div>
With CSS
#wrap {
width:250px;
height: 250px;
background: yellow;
position: absolute;
top: 0;
left: 50%;
margin-left: -125px;
}
#l {
float: left;
}
#r {
float: right;
}
#l, #r {
width: 49%;
}
#l:before, #r:before {
content:"";
width: 125px;
height: 250px;
}
#l:before {
float: right;
}
#r:before {
float: left;
}
Alternative #2 (IE 10+ only): CSS Exclusions - FIDDLE
Markup
<divclass="container"><divclass="exclusion">Awesome content which floats in the center</div><divclass="dummy_text">all the text here</div></div>
CSS
.container {
font-size: small;
background: aqua;
position: relative;
}
.exclusion {
background-color: lime;
-ms-wrap-flow: both;
-ms-wrap-margin: 10px;
z-index: 1;
position:absolute;
left:0;right:0;
top:0;bottom:0;
width: 150px;
height: 100px;
background: yellow;
margin: auto;
}
For more info about CSS exclusion browser support and further resources see my answer here.
Solution 2:
<divid="my1"><p>some text some text
<spanid="wrap">wrapped text</span>
some text some text</p></div>
Should work if I am reading the question correctly? A <div
> is a block level element which is breaking, a <span>
is inline like what you want.
Fiddle here: http://jsfiddle.net/YbuuH/2/
Solution 3:
Use css as below:
wrap { word-wrap:break-word; }
This css should work to wrap the text in a line and to continue on next.
Post a Comment for "Wrap Text Around Both Sides Of Div"