html - 如何摆脱div右侧的空白?

标签 html css

发生了什么

enter image description here

我想要什么

如您所见,即使我设置了 body{padding: 0; ,#Demo-Card 的右侧仍有这个讨厌的空白区域边距:0;}.

我也试过:

#Demo-Card {
    padding: 0;
    margin: 0;
}

但这没有用。

如何摆脱这个讨厌的空白区域?

如果有人可以提供帮助,我们将不胜感激!

代码

HTML

<body>
<div id="Demo-Card">
    <header>
        <h3><span class="problem-number">11</span> <span class="problem-equation">Problem</span></h3> 
    </header>
    <!--<button id="Run">Run Demo</button>-->
    <div class="iframe-container">
        <iframe id="Demo-iFrame" src="mathsynthesis/LearningByExample/GUI/web/mathsynth.html">
            <p>Your browswer does not support iFrames</p>
        </iframe>
    </div>
</div>
</body>

CSS

body{
    padding: 0;
    margin: 0;
    font-family: 'Work Sans', sans-serif;
}

/*DEMO-CARD FORMATTING*/
#Demo-Card {
    width: calc(100vw - 40px);
    height: calc(100vh - 40px - 50px); /*40px for borders, 50px for menu*/
    background-color: white;
    border: 20px solid #86E1D8;
}

JSFiddle

最佳答案

在 id 为 Demo-Card 的 div 上,你有这个 CSS 集:

宽度:计算(100vw - 40px);

相当于浏览器窗口的总宽度减去40px。

相反,将其设置为:

宽度:100%;

它应该可以工作。

关于html - 如何摆脱div右侧的空白?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38513964/

相关文章:

html - 选择多个带背景图片

html - Bootstrap 4 导航栏在小屏幕尺寸上无法正常工作

css - 使 CSS url() 相对于文档

javascript - 响应式顶部导航——使用 div 重新定位链接?

javascript - 在 Google 饼图周围添加边框

php - 使 PHP 回显 <a href= link>

html - 使三 Angular 形动画拉伸(stretch)而不是移动

html - CSS : Icon and text side by side and having space between two text

javascript - 使用 jcrop 裁剪带预览的图像

html - 如何在我的案例中设置响应式 div?