css - 缩放后固定 div 相对位置

标签 css html

我有 3 个 div block ,第一个较大的位于网页的左侧,另一个较小的位于网页的右侧。我希望它们的相对位置在所有具有任何缩放级别的浏览器中都是固定的。如果我现在放大,右栏中的两个 div block 会下降到第一个大 div 下面。

这里是 JFFIDDLE代码链接,请放大/缩小以查看问题。

<div id="topdiv">

    <div class="bigdiv">
        <p> big div </p>
    </div>  

    <div id="staticcal">
        <p> staticcal </p>
    </div>      
    <div id="staticnews">
        <p> staticnews </p>
    </div>

</div

#topdiv{
    display: inline-block;
    background-color:#b0c4de;
}

.bigdiv{
    margin: 10px 0;
    position: relative;
    width: 335px;
    height: 250px;
    float: left;
    border: 2px solid #c7930d;
}

#staticcal {
    width: 220px;
    height: 100px;
    line-height: 175px;
    float: right;
    display: inline-block;
    border: 2px solid #c7930d;
    border-radius: 4px;
    margin: 5px;
    margin-top: 10px;
    margin-right: 0px;
    position: relative;
}
#staticnews {
    width: 220px;
    height: 100px;
    line-height: 175px;
    float: right;
    display: inline-block;
    border: 2px solid #c7930d;
    border-radius: 4px;
    margin: 5px;
    margin-right: 0px;
    position: relative;
}   

最佳答案

min-width: 800px; 添加到 CSS 文件中的 #topdiv id。

CSS:

#topdiv {
    display: inline-block;
    background-color:#b0c4de;
    min-width: 800px;
}

关于css - 缩放后固定 div 相对位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19508360/

相关文章:

css - 当将图像放在 <p> 的中间时,将文本环绕在图像周围

css - 为什么 CSS translate3d transform 表现为相对定位元素?

html - 具有交替行颜色的内部和外部边框

html - iframe 标记阻止页面的其他内容

java - 在 JEditorPane java 上正确显示网站

html - 在 Angular js 中,如何在多选中使选定的选项加粗

javascript - 仅在 ng-repeat 列表中显示唯一日期值

php - 带有自定义表单的 Google CSE

javascript - 如何在替换图像时使用 AJAX 刷新 DIV?

javascript - 动画进行时在同一元素上触发 jquery animate