...

View Full Version : wrap text around relative positioned DIV



gfadmin
05-11-2011, 02:21 PM
I want to have text for a certain element to wrap around an image(#content .body img) in the same element. the image is positioned relative. the reason for positioning the DIV relative is if i use float:left; the image is removed from the containing DIV(#content .body).

If i set the text(#content .body p) to display:inline then is partially wraps the text(first line wraps around the bottom of the image).

Is there anything I can do to wrap the text around the image?




#content .body {
position:relative;
top:60px;
left:15px;
background: rgba(0, 0, 0, 0.6);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";
max-width:650px;
-webkit-border-radius:15px;
-moz-border-radius:15px;
border-radius:15px;
}

#content .body img {
position:relative;
top:15px;
left:15px;
margin-right:15px;
margin-bottom:15px;
}

#content .body p {
position:inherit;
padding:10px;
font-size:14px;
text-indent:20px;
display:inline;
}





<div id="contentContainer">
<div id="navigation">
<ul>
<li><a href="#">News</a></li>
<li><a href="#">Reviews</a></li>
<li><a href="#">Videos</a></li>
<li><a href="#" id="active">Downloads</a></li>
<li><a href="#">Contact</a></li>
</ul>
<img id="divider" src="images/divider.png"/>
</div>

<div id="content">
<div class="title">
<h2>Google I/O 2011</h2>
</div>
<div class="body">
<img src="images/icecream.png" />
<p>At the live keynote, Google announced 2 new versions of it's Android OS. First the 3.1 update for Android Hunnycomb and the next big release Android Ice Cream Sandwich or Android 4. This version of Android is going to include many new features. First is Google is standardizing the Android Platform across all devices, this means that the same OS that is on Android phones with also be on Android Tablets. This new OS is going to have all the features of Android 3, but optimized to work on both Tablets and Phones. <a href="#">READ MORE</a></p>
</div>
</div>

</div>

abduraooft
05-11-2011, 02:26 PM
#content .body img {
position:relative;
top:15px;
left:15px;
margin-right:15px;
margin-bottom:15px;
}

#content .body p {
position:inherit;
padding:10px;
font-size:14px;
text-indent:20px;
display:inline;
} Change the above to

#content .body img {
float:left;
margin:10px 15px 15px 0;
}

#content .body p {
padding:10px;
font-size:14px;
text-indent:20px;
}

gfadmin
05-11-2011, 02:30 PM
that works but then the image is disconneted from the div.
http://gamingfusion.net/images/issue.jpg

abduraooft
05-11-2011, 02:34 PM
that works but then the image is disconneted from the div.
Sorry, that doesn't make any sense. Can we have a link to your page?


position:relative;
top:60px;
left:15px;

Generally, top/bottom and left/right properties do not play well with an element that doesn't have absolute/fixed position. (Also, it's not a good practice to use an absolute/fixed position without a "real" requirement)

gfadmin
05-11-2011, 02:54 PM
OK the issue is the div wrapping the image and the text isn't constraining to the image as seen in the image i provided above which i updated to show where this happens

abduraooft
05-11-2011, 03:05 PM
Umm.. you might need to add overflow:auto; to #content .body to clear the floats.

gfadmin
05-11-2011, 04:02 PM
that solved my problem thanks man!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum