how to put two divs in one line?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sidooh
    New Member
    • Dec 2009
    • 9

    how to put two divs in one line?

    Hi,everyone!

    I want to put two divs in one line,but my code didn't work...

    here is my code:
    exp.html
    Code:
    <html>
    
    <link rel="stylesheet" type="text/css" href="exp.css">
    
    	<head>
    	</head>
    	
    	<body>
    		<div id="headerimg">
    			<div id="logo">
    				<div id="l1">l1
    					<div id="l2">l2</div>
    				</div>
    				
    			</div>
    			<div id="title">gbstack</div>
    		</div>
    	</body>
    	
    </html>
    exp.css
    Code:
    #headerimg{
    	width:100%;
    }
    
    #logo{
    	width:30%;
    	background:red;
    }
    
    #l1{
    	width:50%;
    	background:#aaaaaa;
    }
    
    #l2{
    	width:50%;
    	background:#aa00cc;
    }
    
    #title{
    	width:70%;
    	background:green;
    }
    I want to put l1 and l2 in one line.
    any suggestion is appreciated.
    Attached Files
  • sidooh
    New Member
    • Dec 2009
    • 9

    #2
    any one could help me?

    Comment

    • JKing
      Recognized Expert Top Contributor
      • Jun 2007
      • 1206

      #3
      Divs are by default block elements. Use display:inline; in your css for both divs.

      Comment

      • sidooh
        New Member
        • Dec 2009
        • 9

        #4
        Thank you very much!
        It works!

        Thank you again!

        Comment

        • cutesrivastavaabhi
          New Member
          • May 2010
          • 8

          #5
          Originally posted by sidooh
          Hi,everyone!

          I want to put two divs in one line,but my code didn't work...

          here is my code:
          exp.html
          Code:
          <html>
          
          <link rel="stylesheet" type="text/css" href="exp.css">
          
          	<head>
          	</head>
          	
          	<body>
          		<div id="headerimg">
          			<div id="logo">
          				<div id="l1">l1
          					<div id="l2">l2</div>
          				</div>
          				
          			</div>
          			<div id="title">gbstack</div>
          		</div>
          	</body>
          	
          </html>
          exp.css
          Code:
          #headerimg{
          	width:100%;
          }
          
          #logo{
          	width:30%;
          	background:red;
          }
          
          #l1{
          	width:50%;
          	background:#aaaaaa;
          }
          
          #l2{
          	width:50%;
          	background:#aa00cc;
          }
          
          #title{
          	width:70%;
          	background:green;
          }
          I want to put l1 and l2 in one line.
          any suggestion is appreciated.
          Code:
          <html>
          <body>
          <div align="left"  style="width:200px; top:0px; position:absolute">hi</div><div  style="left:220px;top:0px; position:absolute">hello</div>
          </body>
          </html>
          Last edited by Dormilich; Jul 6 '10, 10:00 AM. Reason: Please use [code] tags when posting code

          Comment

          • Bharat383
            New Member
            • Aug 2011
            • 93

            #6
            <code>
            <div style="float:le ft;height:200px ;width:400px"> jadsklfj;adkfj; </div>
            <div style="float:le ft;height:200px ;width:400px;"> ajljdfakljdf;ka jdf</div>
            </code>

            Bharat Parmar(Bharat38 3)

            Comment

            Working...