html - 在整个网页周围放置一个父 div

标签 html css border

我正试图在我的整个网页周围放置一个黑框。

我希望父 div 围绕整个页面,而不仅仅是底部。我的 HTML 看起来像这样:

<body>
<!-- Header --> 
        <section id = "top" class = "top">
            <div class="container">
                <h1 class = text-center>Sarah Hynds</h1>
            </div>
        </section>
        <!------ tabs ------>
        <nav class="mynav">
            <ul>
                <li>
                    <a href="">About</a>
                </li>
                <li>
                    <a href="">Resume</a>
                </li>
                <li>
                    <a href="">Projects</a>
                </li>
                <li>
                    <a href="">Interests</a>
                </li>
                <li>
                    <a href="">Contact</a>
                </li>
            </ul>
        </nav>
        <hr id="separator" width="35%" color="black">
        <div class="floating-box" id="about"></div>
        <div class=floating-box" id="profile">
        </div>
        <div class="parentDiv"></div>
</body>

我的 CSS 是这样的:

.parentDiv { 
width: 90%; 
border: 1px solid #000000; 
margin-top: 5%; 
margin-left: 5%; 
margin-right: 5%; 
height: 100%; 
display: inline-block; 
padding-bottom: 50px;
display: inline-block;
white-space: nowrap; }

如何在整个页面周围放置边框? 非常感谢!

最佳答案

<body>
<div class="parentDiv">
<!-- Header --> 
        <section id = "top" class = "top">
            <div class="container">
                <h1 class = text-center>Sarah Hynds</h1>
            </div>
        </section>
        <!------ tabs ------>
        <nav class="mynav">
            <ul>
                <li>
                    <a href="">About</a>
                </li>
                <li>
                    <a href="">Resume</a>
                </li>
                <li>
                    <a href="">Projects</a>
                </li>
                <li>
                    <a href="">Interests</a>
                </li>
                <li>
                    <a href="">Contact</a>
                </li>
            </ul>
        </nav>
        <hr id="separator" width="35%" color="black">
        <div class="floating-box" id="about"></div>
        <div class=floating-box" id="profile">
        </div>

</div>
</body>
</html>

只需将它包裹在您希望它影响的内容周围即可。 :-)

关于html - 在整个网页周围放置一个父 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45661725/

相关文章:

css - HTML div 边框和文本不对齐

HTML 类不起作用?

jquery - 如果 div 还包含一些通过选择和输入框输入的用户条目,我如何才能仅获取 div 中的文本?

javascript - 将代码后面的进度百分比传递给 Jquery 进度条?

html - 我可以防止选择到 div 的末尾吗?

html - 我想降低动画速度

css - webkit 呈现边框的最后一个像素 :1px dotted; oddly

html - 仅将阴影应用于表格行的顶部边框

css - 编写代码将 Google Font API 导入 MailChimp?