Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-11-2011, 01:21 PM   PM User | #1
gfadmin
New Coder

 
Join Date: Jul 2009
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
gfadmin is an unknown quantity at this point
wrap text around relative positioned DIV

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?

Code:
#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;
}
Code:
<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>
__________________
SkyePHP | Head Developer & Project Manager.
Release: TBA
Like the Facebook Page for Updates!
gfadmin is offline   Reply With Quote
Old 05-11-2011, 01:26 PM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
Code:
#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
Code:
#content .body img {
	float:left;
        margin:10px 15px 15px 0;
}

#content .body p {
	padding:10px;	
	font-size:14px;
	text-indent:20px;
}
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 05-11-2011, 01:30 PM   PM User | #3
gfadmin
New Coder

 
Join Date: Jul 2009
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
gfadmin is an unknown quantity at this point
that works but then the image is disconneted from the div.
__________________
SkyePHP | Head Developer & Project Manager.
Release: TBA
Like the Facebook Page for Updates!
gfadmin is offline   Reply With Quote
Old 05-11-2011, 01:34 PM   PM User | #4
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
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?
Quote:
Code:
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)
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 05-11-2011, 01:54 PM   PM User | #5
gfadmin
New Coder

 
Join Date: Jul 2009
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
gfadmin is an unknown quantity at this point
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
__________________
SkyePHP | Head Developer & Project Manager.
Release: TBA
Like the Facebook Page for Updates!
gfadmin is offline   Reply With Quote
Old 05-11-2011, 02:05 PM   PM User | #6
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Umm.. you might need to add overflow:auto; to #content .body to clear the floats.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 05-11-2011, 03:02 PM   PM User | #7
gfadmin
New Coder

 
Join Date: Jul 2009
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
gfadmin is an unknown quantity at this point
that solved my problem thanks man!
__________________
SkyePHP | Head Developer & Project Manager.
Release: TBA
Like the Facebook Page for Updates!
gfadmin is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:14 PM.


Advertisement
Log in to turn off these ads.