简体   繁体   English

我的HTML内容超出了容器

[英]My HTML content flows beyond the container

I am finishing up a site for my church and I am having trouble figuring out how to keep my section content inside of the container. 我正在为教堂准备一个场地,但在弄清楚如何将我的部分内容保留在容器中时遇到了麻烦。 It overflows down beyond the footer. 它溢出超出页脚。 I am not very experienced with CSS so I'm not sure where the problem is. 我对CSS不太了解,所以我不确定问题出在哪里。 I have tried making adjustments to the display type of the section. 我试图调整该部分的显示类型。 I already have overflow: hidden included. 我已经溢出:已隐藏。 I'm not sure where the problem is, beyond my inexperience, that is. 除了我的经验不足之外,我不确定问题出在哪里。 I know my limits are surpassed with this project for sure. 我知道这个项目肯定会超越我的极限。 I just want to help my church out with this and finish it up. 我只是想帮助我的教会完成这项工作。 Any help is appreciated greatly. 任何帮助将不胜感激。

 nav { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } nav a { float: left; display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } nav a:hover:not(.active) { background-color: #000; } .active { background-color: #840D55; } header { background-color: #840D55; position: absolute; top: 47px; width: 100%; border-bottom: solid; border-bottom-color: #840D55; } header img { max-width: 100%; max-height: 100%; margin: auto; display: block; } #container { height: 100%; width: 100%; margin-right: auto; } #wrapper { position: absolute; top: 0; height: 100%; width: 100%; border-left: solid; border-right: solid; border-left-color: #333; border-right-color: #333; } section { height: auto; width: auto; color: #333; position: relative; top: 310px; padding-left: 20px; } h1 { position: relative; top: 240px; color: #333; margin-left: 20px; padding: 0; text-align: center; } h2 { color: #333; } h3 { color: #333; } p { line-height: 1.5; } .floatLeft { padding-left: 40px; width: 50%; position: relative; float: left; margin: auto; line-height: 1.8; } .floatRight { width: 38%; position: relative; float: left; margin: auto; text-align: right; padding-right: 20px; line-height: 1.8; } #schAlign { padding-right: 20px; } footer { clear: both; position: absolute; bottom: 0px; color: #777; width: 100%; background-color: #840D55; } 
 <div id="wrapper"> <div id="container"> <nav> <a class="active" href="">Home</a> <a href="">About</a> <a href="">Pastors</a> <a href="">Contact</a> </nav> <header> <img src="Images/bannerImg.jpg" alt="Flame of Fire Church"> </header> <h1>In the name of Jesus, come and be blessed.</h1> <section> <div class="floatLeft"> <h3>Acts chapter 2 verse 38 says</h3> <blockquote>Peter replied, "Repent and be baptized, every one of you, in the name of Jesus Christ for the forgiveness of your sins. <strong><em>And you will receive the gift of the <u>Holy Spirit</u>.</strong></em>"</blockquote> <br /> <h3>Verse 39 continues</h3> <blockquote>"The promise is for you and your children and for all who are far off - for all whom the Lord our God will call."</blockquote> <br /> <p></p> </div> <div class="floatRight"> <h2>Service Schedule</h2> <div id="schAlign"> <p>Wednesday Night</p> <ul> <li>7:00PM</li> </ul> <p>Sunday Morning</p> <ul> <li>10:00AM</li> </ul> </div> </div> </section> </div> <footer> <!-- This site built with love and joy by Keith Graham --> &copy; Flame of Fire Church, 2017. All rights reserved. </footer> </div> 

Updated styles (without positioning - it seems you don't need it here - and other bloat). 更新了样式(没有定位 -似乎您不需要在这里-和其他膨胀)。 Use margins to set distances among elements accordingly to your ideas, not positioning. 使用边距可根据您的想法而不是定位来设置元素之间的距离。 Also you might want to add normalize.css before your styles for better cross-browserness. 另外,您可能希望在样式之前添加normalize.css ,以实现更好的跨浏览器功能。 So, you can start again from here: 因此,您可以从这里重新开始:

 html { box-sizing: border-box; font-size: 14px; } *, *:before, *:after { box-sizing: inherit; } nav { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } nav a { float: left; display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; } nav a:hover:not(.active) { background-color: #000; } .active { background-color: #840D55; } header { background-color: #840D55; border-bottom: solid; border-bottom-color: #840D55; } header img { max-width: 100%; max-height: 100%; margin: auto; display: block; } #wrapper { width: 90%; margin: 0px auto; border-left: solid; border-right: solid; border-left-color: #333; border-right-color: #333; } section { color: #333; padding-left: 20px; } section:after { content: ""; display: table; clear: both; } h1 { color: #333; padding: 0; text-align: center; } h2 { color: #333; } h3 { color: #333; } p { line-height: 1.5; } .floatLeft, .floatRight { line-height: 1.8; width: 50%; text-align: left; } .floatLeft { float: left; } .floatRight { float: right; padding-left: 10%; } #schAlign { padding-right: 20px; } footer { clear: both; color: #fff; text-align: center; padding: 1rem; background-color: #840D55; } @media (max-width: 767px) { #wrapper { width: 100%; } .floatLeft, .floatRight { width: 100%; padding: .8rem; } } 
 <div id="wrapper"> <div id="container"> <nav> <a class="active" href="">Home</a> <a href="">About</a> <a href="">Pastors</a> <a href="">Contact</a> </nav> <header> <img src="Images/bannerImg.jpg" alt="Flame of Fire Church"> </header> <h1>In the name of Jesus, come and be blessed.</h1> <section> <div class="floatLeft"> <h3>Acts chapter 2 verse 38 says</h3> <blockquote>Peter replied, "Repent and be baptized, every one of you, in the name of Jesus Christ for the forgiveness of your sins. <strong><em>And you will receive the gift of the <u>Holy Spirit</u>.</strong></em>"</blockquote> <br /> <h3>Verse 39 continues</h3> <blockquote>"The promise is for you and your children and for all who are far off - for all whom the Lord our God will call."</blockquote> <br /> <p></p> </div> <div class="floatRight"> <h2>Service Schedule</h2> <div id="schAlign"> <p>Wednesday Night</p> <ul> <li>7:00PM</li> </ul> <p>Sunday Morning</p> <ul> <li>10:00AM</li> </ul> </div> </div> </section> </div> <footer> <!-- This site built with love and joy by Keith Graham --> &copy; Flame of Fire Church, 2017. All rights reserved. </footer> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM