在CSS中将两个框连接在一起

时间:2013-04-27 02:17:51

标签: css position positioning webpage

我有一个网站设计,我正在尝试立即构建,我有一个菜单在右边。这是代码,之后我会解释。

#rightmenu {
    border-top: 1px solid #000000;
    border-right: 1px solid #000000;
    border-bottom: 1px solid #000000;
    width:30px;height:578px;
    border-bottom-right-radius:10px;
    border-top-right-radius:10px;
    float:right;
    margin-top:-580px;
}

这就是右边的菜单,我希望它附在这个盒子上,并且总是去哪里

#content {
    border-right: 1px solid #000000;
    border-bottom: 1px solid #000000;
    border-left: 1px solid #000000;
    width:800px;height:auto;
    min-height:400px;
    margin:0 auto;
}

宽度为800,它只是在屏幕中心,所以我需要'rightmenu'来连接到居中的内容框。这是800px的样子(正确的样子): Proper

如果网络浏览器小于800px(这是网页的最小尺寸),它的外观如下:

It's hard to see the rightmenu, but if you look closely you can see a line through everything which is it's right border

最后,如果网络大于800px,这就是它的方式: enter image description here

1 个答案:

答案 0 :(得分:1)

尝试将它们包装在宽度为830px的div中,然后在该包装上放置“margin-right:auto;和margin-left:auto”属性。