Vor
Vor

Reputation: 35149

Put two child divs next to each other inside parrent div

that's what I got so far: http://jsfiddle.net/cHKF4/3/

But I want to put small boxes (box1 and box2 inside late)

#late {
    position: relative;
    border-style: solid;
    border-width: 3px;
    border-color: #00fff3;
    height: 200px;
       width: 960px;
    margin: 0 auto;
    margin-top: 30px;
}

#box1 {
    position: relative;
    border-style: solid;
    border-width: 1px;
    border-color: #55fff3;
    height: 100%;
    width: 200px;
    margin: 0 auto;
}

#box2 {
    position: relative;
    border-style: solid;
    border-width: 3px;
    border-color: #55fff3;
    height: 100%;
    width: 200px;
}

Thank you.

Upvotes: 1

Views: 3436

Answers (4)

Paul Fleming
Paul Fleming

Reputation: 24526

Is this what you're trying to achieve (box1 and box2 side by side and centred inside late with late centred on the page) :

<div id="late">
    <div id="inner">
       <div id="box1"></div>
       <div id="box2"></div>
    </div>
</div>​

#late {
    border: solid 3px #00fff3;
    height: 200px;
    width: 960px;
    margin: 30px auto 0 auto;
}

#inner {
    width: 408px;
    height: 100%;
    margin: 0 auto 0 auto;
}

#box1 {
    border: solid 1px #55fff3;
    height: 100%;
    width: 200px;
    float: left;
}

#box2 {
    border: solid 3px #55fff3;
    height: 100%;
    width: 200px;
    float: left;
}
​

Upvotes: 2

henrywright
henrywright

Reputation: 10240

Try

#box1 {
position: absolute;
top: 10px;
left: 10px;
}

Keep the parent container's position set to relative.

Upvotes: 1

codingbiz
codingbiz

Reputation: 26396

Add float:left to both #box1 and #box2

#box1 {
    float:left;
    position: relative;
    border-style: solid;
    border-width: 3px;
    border-color: #55fff3;
    height: 100%;
    width: 200px;
}

#box2 {
    float:left;
    position: relative;
    border-style: solid;
    border-width: 3px;
    border-color: #55fff3;
    height: 100%;
    width: 200px;
}

Upvotes: 1

AntonNiklasson
AntonNiklasson

Reputation: 1749

I don't quite understand what you are trying to achieve. Are you trying to center #box1 and #box2 inside #late?

If you are just trying to put them side by side inside #late this is how I would do it: http://codepen.io/AntonNiklasson/pen/rIdcj

Upvotes: 1

Related Questions