css - 在 CSS 中将两个盒子连接在一起

标签 css position positioning html

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

#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

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

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

最后,如果网页大于 800 像素,它会采用以下方式: enter image description here

最佳答案

尝试将它们都包装在一个宽度为 830 像素的 div 中,然后将“margin-right: auto; and margin-left: auto”属性放在该包装上。

关于css - 在 CSS 中将两个盒子连接在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16247630/

相关文章:

css - 为什么嵌套的 HTML 元素会使我的 CSS 跳转?

javascript - 将 css 样式应用于多个 jquery 缓存变量而不重复 css 样式

javascript - 使用可重用组件时 Angular 7 CSS 不工作

html - 将图像垂直居中对齐

position - 如何在 graphviz 中强制节点位置(x 和 y)

javascript - 将 Div 动态放置在文本框下方以显示选项

html - IE Intranet 兼容性 View 不包括某些字体

html - 缩放时 CSS "position: fixed"在移动设备上无法正常工作

html - 拉伸(stretch) block 元素以填充其父元素的 100% 垂直滚动高度

css - 将 div 粘贴到右下角,但始终位于页脚上方