0

I have created a news banner and a button as two separate <div> elements, but I find them in 2 lines.

I want keep them in one line, how to do it?

HTML:

<div id="outer">
    <div>
        <div>
            <div id="newsbar">news bar</div>
            <div id="button"><span role="button"> <input type="button" value="submit"/></div>
        </div>
    </div>
</div>

fiddle.

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
Harim
  • 31
  • 1
  • 7

12 Answers12

1
#newsbar {
    float:left;
    width:400px;
    text-align: center;
}
#button{
    float:left;
}

See Fiddle

Roopendra
  • 7,674
  • 16
  • 65
  • 92
0

Here's the fiddle. Add

float:left

to both the divs. Fiddle

Tejas
  • 585
  • 3
  • 15
0

Use display:inline-block

Here is the fiddle.

codingrose
  • 15,563
  • 11
  • 39
  • 58
0

http://jsfiddle.net/ZKKFU/4/

Set the two div's to have style of inline (or inline block as I have opted for in the example above.)

CSS rule below for inline block

#id { display:inline-block; }
Idiot211
  • 848
  • 7
  • 17
0

Did you research your subject?

 #newsbar
 {
     float:left; 
 } 
SBD
  • 446
  • 6
  • 17
0

Try adding a width for each and then use for the first :

float:left;  

and for the second div :

float:right; 
0

try this. Demo

div
{
    display:inline-block;
    float: left;
}
SanketS
  • 963
  • 1
  • 13
  • 36
0

Use a width where there is space for 2 divs, than use

Float: left;

this will put the divs next to each other, ofcourse you could use any other direction of your choice

0

Here you go.

http://jsfiddle.net/alaminopu/ZKKFU/15/

HTML:

<div id="outer">
    <div id="news-wrap">
        <div>
            <div id="newsbar"></div>
            <div id="button"><span role="button"> <input type="button" value="submit"/></div>
        </div>
    </div>
</div>

CSS:

#news-wrap{
    overflow:hidden;
}
#newsbar{
    float:left;
    width:200px;
}
Md. Al-Amin
  • 1,423
  • 1
  • 13
  • 26
0

try this,

<table>
<tr>
<td width="200px" align="center">
<div id="outer">
<div id="newsbar"></div></td>
<td>
<div id="button"><span role="button"> <input type="button" value="submit"/></div></td>
</div>
</tr>
</table>

just make ur div's into a small table..

Shameer Ali Shaik
  • 53
  • 1
  • 4
  • 14
0
    display:inline-block

#div1{float:left}

#div2{float:right}
Sridhar R
  • 20,190
  • 6
  • 38
  • 35
0

In your css try adding

float: left; 

and

display: inline-block; 


That should fix it.