0

I have 3 divs. The first div is the rectangular border. I tried different combinations of floating to get the 2 divs to display next to the first div, but have been unsuccessful. Here is the code below and the jsfiddle.

<div class="attempt">

</div>
<div>
<ul id="menu">
  <li><a style="background:#3F4E64"  href="/html/default.asp">Button1</a></li>
  <li><a style="background:#788291">Button2</a></li>
</ul>  
</div>

<div>
<H2>TITLE</H2>
<p>
BADKADA
</p>
<p>
Fusce luctus ipsum in dui accumsan, posuere scelerisque lacus ultrices. Quisque quis ultricies nunc. Nam augue magna, eleifend id mi vel, pretium
</p>
<p>
Fusce luctus ipsum in dui accumsan, posuere scelerisque lacus ultrices. Quisque quis ultricies nunc. Nam augue magna, eleifend id mi vel, pretium
</p>

CSS

.attempt  {
  width:15px;
  height:1290px;
  background: #3F4E64
}

https://jsfiddle.net/ksaluja/f1s51sj4/

G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129
Kulwant
  • 641
  • 2
  • 11
  • 28

2 Answers2

0

Take out the display property so the first div defaults to block. Then float it to the left and give it a margin-right of 20px or so to give the content some breathing room.

.attempt {
    float:left;
 width: 15px;
    height: 1290px;
    background: #3F4E64;
 margin-right:20px;
}
<div class="attempt">

</div>
<div>
    <ul id="menu">
        <li><a style="background:#3F4E64" href="/html/default.asp">Button1</a></li>
        <li><a style="background:#788291">Button2</a></li>
    </ul>
</div>

<div>
    <H2>TITLE</H2>
    <p>
        BADKADA
    </p>
    <p>
        Fusce luctus ipsum in dui accumsan, posuere scelerisque lacus ultrices. Quisque quis ultricies nunc. Nam augue magna, eleifend id mi vel, pretium
    </p>
    <p>
        Fusce luctus ipsum in dui accumsan, posuere scelerisque lacus ultrices. Quisque quis ultricies nunc. Nam augue magna, eleifend id mi vel, pretium
    </p>

    <p>
        Fusce luctus Fusce luctus ipsum in dui accumsan, posuere scelerisque lacus ultrices. Quisque quis ultricies nunc. Nam augue magna, eleifend id mi vel, pretium fring.
    </p>
</div>
symlink
  • 11,984
  • 7
  • 29
  • 50
0

Setting the display property for the attempt div to 'inline-block' will display the div as an inline-block container, so any content or div's ahead will be displayed after it and not by side. So, to get the next divisions to the side of the first one, you can do as @symlink explained. 'block' or the default property of display, will set the div as an independent block, and other divisions will align on the side to this block.

ZeroFlex
  • 74
  • 9