当前位置: 动力学知识库 > 问答 > 编程问答 >

html - iCSS floating divs

问题描述:

My picture explains what im trying to do, everything I have tried is breaking,

position: fixed; breaks when moving horizontal browser window size.

position: absolute; breaks when moving scrollbar down.

div1 is a image

div2-4 is css buttons.

网友答案:

Something like this:

JSBin

Add the blue border like border:5px solid blue; ( you have to modify the width and height if you will use the border).

Example with a container:

JSBin_2

I would advice you to use fixed width ( not % ).

网友答案:

Use float:left for div 1, and float:right for div2 - 4. Also, set a width for the parent container (blue box in your picture).

网友答案:

HTML:

<div id="div1">
Div1
</div>

<div id="div2">
Div2
</div>

<div id="div3">
Div3
</div> 

<div id="div4">
Div4
</div>

CSS:

#div1,#div2,#div3,#div4{
background:#c00000;
}

#div1{
width:450px;
height:150px;
float:left;
padding:10px;
}

#div2,#div3,#div4{
width:160px;
margin-left:480px;
margin-bottom:10px;
padding:10px;
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: