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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    310
    Thanks
    86
    Thanked 3 Times in 3 Posts

    align text alongside two div elements?

    Hi Guys,

    Wondering oif someone could help with my layout please

    In my layout I have some text that I call out of a database. I then want the text to align alongside two div elements, but I can't get it to work. I want it like this:



    Code:
    <style>
      .pic_float_right {
      float:right;
      border:solid 1px silver;
      padding:5px;
      margin-left: 5px;
      margin-right:10px;
      margin-top: 10px;
      margin-bottom: 10px;
      }  
    
      .video_float_right {
      background-color: #F5F5F5; 
      width:200px;
      display:inline;
      float:right;
      border:solid 1px silver;
      padding:5px;
      margin-left: 5px;
      margin-right:10px;
      margin-top: 10px;
      margin-bottom: 10px;
      }  
    </style>
    
    [/html]
    
    <div class="video_float_right"><img src="images/camera.png" />View Video</div>
    <div class="pic_float_right"><img src="images/person.jpg" /></div>
    <p><?php  echo nl2br($body_text); ?></p>
    Thanks

    Chris

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,744
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    Hello stfc_boy,
    You just need to add clear:right; so the floats won't float next to each other. Like this:
    Code:
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <meta name="" content="authored by http://nopeople.com/Design" />
    <style type="text/css">
    html, body {
    	background: #CCCCCC;
    }
    * {
    	margin: 0;
    	padding: 0;
    	border: none;
    }
    #container {
    	width: 760px;
    	margin: 0 auto;
    	overflow: auto;
    	background: #66CCCC;
    }
    .pic_float_right {
    	float:right;
    	clear: right;
    	width:200px;
    	height: 200px;
    	border:solid 1px silver;
    	background: #00FF00;
    	padding:5px;
    	margin: 10px 10px 10px 5px;
    }  
    .video_float_right {
    	background-color: #F5F5F5; 
    	width:200px;
    	height: 200px;
    	float:right;
    	border:solid 1px silver;
    	padding:5px;
    	margin: 10px 10px 10px 5px;
    }  
    </style>
    </head>
    <body>
        <div id="container">
        <div class="video_float_right">
        	<a href=""><img src="images/camera.png" />View Video</a>
        </div>
    		<div class="pic_float_right">
            	<img src="images/person.jpg" />
            </div>
        <p>
            Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna 
            aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no 
            sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam 
            nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo 
            duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
        </p>
        <p>
            Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna 
            aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no 
            sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam 
            nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo 
            duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
        </p>
        <!--end container--></div>
    </body>
    </html>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • Users who have thanked Excavator for this post:

    stfc_boy (01-11-2008)


  •  

    Posting Permissions

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