Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jul 2009
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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!

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    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;
    }
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Jul 2009
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that works but then the image is disconneted from the div.
    SkyePHP | Head Developer & Project Manager.
    Release: TBA
    Like the Facebook Page for Updates!

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    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?
    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)
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Jul 2009
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Umm.. you might need to add overflow:auto; to #content .body to clear the floats.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #7
    New Coder
    Join Date
    Jul 2009
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that solved my problem thanks man!
    SkyePHP | Head Developer & Project Manager.
    Release: TBA
    Like the Facebook Page for Updates!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •