首页 > 解决方案 > 缩小浏览器时文本超出页脚

问题描述

我使用 html 和 css 创建了一个静态网站,问题是当我缩小浏览器时,页脚内的文本超出了页脚,我怎样才能使文本始终留在页脚中,无论我是否缩小浏览器与否?

   * {
    margin: 0px;
    padding: 0px;
  }
  

  .nav-h1 {
    text-align: center;
    margin-top: 27px;

    font-family: 'Open Sans';
    font-size: 40px;
  }

 .nav {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 50%;
  }
  
  a {
    display: inline-block;
    margin: 10px;
    font-family: 'Open Sans';
    color: black;
    font-weight: bold;
  }

  .a-container {
      margin-left: 10%;
      margin-top: 27px;
  }

  .logo-section {
      margin-left: 15px;
      margin-top: 15px;
  }

  .main {
      min-height: calc(100vh - 70px);
      background-color:#F1F1F1;
      overflow: hidden;
  }

  .footer {
   width: 100%;
   height: 100%; 
   background-color: black;
   color: gray;
   font-family: 'Open Sans';
   font-size: 15px;
  }

  .first-box {
    width: 45%;
    margin: 0 auto;
    margin-top: 50px;
  }

  .first-box-text {
    margin-top: 20px;
    font-family: 'Open Sans';
  }

  .centered-p {
    text-align: center;
    margin-top: 20px;
    font-family: 'Open Sans';
  }

.second-word {
  color: #ffa200;
  text-decoration: underline;
}

.centered-img{
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-top: 30px;
}

.header {
  height: 8%;
}

.logo-img {
  margin-top: 10px;
  height: 50px;
}

.flex-container {
  display: flex;
  margin-top: 50px;
  margin-left: 17%;
}

section {
  flex: 2;
}

aside {
  flex: 1;
}

.bordered-div {
  margin-top: 50px;
  text-align: center;
  padding: 15px;
  font-family: 'Open Sans';
  font-size: 25px;
  border-top: solid 2px gray;
  border-bottom: solid 2px gray;
}

.flex-container-first-section-a {
  color: #ffa200;

  text-decoration: none;
  border-bottom: 2px solid #ffa200;
}

.aside-first-section {
  width: 60%;
  text-align: center;
  padding: 15px;
  margin-left: 50px;
  
  border-top: solid 2px gray;
  border-bottom: solid 2px gray;
}

.aside-img {
  margin-left: 50px;
  margin-top: 20px;
}

.third-section {
  margin-top: 25px;
  font-family: 'Open Sans';
}

.forth-section-h1{
 margin-left: 28%;
 margin-top: 50px;

 font-family: 'Open Sans';
}

.forth-section-p {
  margin-left: 90px;
  margin-top: 40px;

  font-family: 'Open Sans';
}

.bordered-div-h1-upper-case {
  text-transform: uppercase;
}

.image-container {
  display: flex;
  margin-top: 30px;
}

.image-container-img {
  padding: 5px;  
}

.img-with-text {
  margin: 10px;
  font-family: 'Open Sans';
}

.img-with-text-span {
 border-top: solid 3px #ffa200
}

.second-section {
  margin-top: 10px;
  font-family: 'Open Sans';
}

.bottom-message {
  height: 300px;
  width: 100%;

  margin-top: 50px;
  margin-bottom: 50px;

  text-align: center;
  border: solid 2px black;
}

.bottom-message-button {
  width: 50%;
  height: 15%;
  margin-top: 50px;
  background-color: #ffa200;
  border-radius: 4px;
  border: none;
  color: white;
  font-family: 'Open Sans';
  font-size: 20px;
  font-weight: bold;
}

.bottom-message-content {
  margin-top: 60px;
  margin: 70px;
}

.centered-heading {
  font-family: 'Open Sans';
}

.flex-container-first-p {
  font-family: 'Open Sans';
}

.bottom-message-h1, .bottom-message-content-p {
  font-family: 'Open Sans';
  margin-top: 20px;
}

.footer-section {
  width: 50%;
  margin: 0 auto;
}

.footer-content {
  margin: 0px;
  padding: 0px;
}

.footer-links-a {
  color: gray;
  text-decoration: none;
  border-right: 1px solid;
  padding-right: 23px;
}

.capital-words {
  text-transform: uppercase;
  padding-top: 10px;
}

.footer-links {
  width: 800px;
  margin: 0 auto;
  margin-top: 50px;
}

.copyright-p {
  padding-top: 10px;
}

.aside-h2 {
  font-size: 15px;
  text-align: center;

  margin-top: 10px;
}

.aside-third-section > img {
  height: 250px;
}

.line {
  border-bottom: solid 2px black;
  width: 70%;
  margin: 0 auto;
  padding-top: 50px;
}

.box-message {
  height: 200px;
  width: 280px;
  margin-top: 50px;
  margin-left: 80px;
  border: solid 2px black;
}

.box-message-p {
  font-family: 'Open Sans';
  margin-top: 50px;
  width: 60%;
  margin: 0 auto;
  margin-top: 35px;
  font-size: 15px;
}

.box-message-button, .box-message-a {
  margin-top: 30px;
  margin-left: 70px;
}

.box-message-a {
  color: #ffa200;
  text-decoration: none;
  border-bottom: solid 2px #ffa200;
  font-size: 25px;
}

.trending-news-div {
  width: 60%;
  text-align: center;
  padding: 15px;
  margin-left: 70px;
  margin-top: 50px;
  
  border-top: solid 2px gray;
  border-bottom: solid 2px gray;
}
<div class="container">
            <div class="header">
                <div class="nav">
                    <h1 class="nav-h1">Nip &amp; Tuck</h1>
                    <div class="a-container">
                        <a>Lifestyle</a>
                        <a>Culture</a>
                        <a>Sports</a>
                        <a>Politics</a>
                    </div>
                    <div class="logo-section">
                        <img class="logo-img" src="/assets/images/twitter-logo.PNG" alt="twitter logo">
                        <img class="logo-img"src="/assets/images/youtube-logo.png" alt="youtube logo">
                        <img class="logo-img"src="/assets/images/facebook-logo.png" alt="facebook logo">
                    </div>
                </div>
            </div>
            <div class="main">
                <div class="first-box">
                    <h1 class="centered-heading">How one woman gave her boss, her ex-boyfriend and all her doubters, the big middle finger</h1>
                    <p class="first-box-text">Janice Allbright decided enough was enough. It was time to change her life. After six months of stock trading, the final result was renewed confidence, increased happiness and £128,405!
                    </p>
                    <p class="centered-p">By
                        <a class="second-word">Kelly Chang</a>
                        | 30.06.2020</p>
                    <img src="/assets/images/center-image.png" alt="woman carrying a bag" class="centered-img">
                    <p class="centered-p">"It's not arrogance, it's confidence"</p>
                </div>
                <div class="flex-container">
                    <section>
                        <p class="flex-container-first-p">
                            
“My life was basically sh!t, says Janice Allbright, a single woman whose life was literally in the toilet six months ago. “I was working at a shop on the high street, earning next to nothing. Then I would go home to my abusive boyfriend. Not exactly a fairytale life.” Everything changed for Janice when she discovered online trading while killing time on her lunch break. “My colleagues, friends and boyfriend at the time all doubted me. Now I’m the queen bitch, laughing at their tears.” 



                        </p>
                        <div class="bordered-div">
                            <p>Change your life with the Online Investing System</p>
                            <a class="flex-container-first-section-a" href="">Get started for free</a>
                        </div>
                        <img src="/assets/images/second-center-image.PNG" alt="woman talking on the phone" class="centered-img">
                        <p class="centered-p">A new and better life</p>
                        <section class="second-section">
                            <p>Janice credits her amazing financial success to trading stocks online. The highschool dropout had concerns at the beginning, due to her lack of financial knowledge and experience. “It turned out there was nothing to worry about,” she says. “My broker provided me with all of the training and tools I needed to become a successful stock trader. Their patience was amazing.” </p>
                        </section>
                        <section class="third-section">
                            <p>Brokers and platforms, like the Online Investing System, have turned novice investors into financial superheroes. People like Janice have taken advantage of some tough competition amongst brokers to get the best services for lower prices. Sometimes even for free. “I didn’t have any money for fancy financial tools or software. But lucky me, my broker gave me everything for free.”&lt;/p>
                        </section>
                        <section class="forth-section">
                            <img src="/assets/images/third-center-image.PNG" alt="" class="centered-img">
                        <h1 class="forth-section-h1">"Now I do whatever the f@ack I want when I f@cking want"</h1>
                        <p class="forth-section-p">Janice believes that her success has given her the confidence to deal with anything life throws her way. And she openly admits that displaying her wealth has become a guilty pleasure. “I was driving in my G Wagon a few weeks ago and noticed my ex-boyfriend waiting at the bus stop. I could resist. I stopped my car, rolled down the window and happily presented my middle finger. I drove away with a smile. Life is good.”&lt;/p>
                        </section>
                        <div class="bordered-div">
                            <p>Learn more about online stock trading and how you can profit </p>
                            <a class="flex-container-first-section-a" href="">Start Now</a>
                        </div>
                        <div class="bordered-div">
                            <h1 class="bordered-div-h1-upper-case">Celebrity News </h1>
                        </div>
                        <div class="image-container">
                            <div class="img-with-text">
                                <img src="/assets/images/hollywood-image.PNG" alt="hollywod sign" class="image-container-img">
                                <div class="img-with-text-bottom">
                                <h4 class="img-with-text-h4">Ass-tastic! We rank the best bums in Hollywood.</h4>
                                <span class="img-with-text-span">By Lili Johnson 30.06.2020</span>
                                </div>
                            </div>
                            <div class="img-with-text">
                                <div class="img-with-text-bottom">
                                    <img src="/assets/images/laptop-image.PNG" alt="a picture of a laptop" class="image-container-img">
                                    <h4 class="img-with-text-h4">Coming soon to Netflix. See which movies have us hot and bothered.</h4>
                                    <span class="img-with-text-span">By Gavin Lewis 30.06.2020</span>
                                </div>
                            </div>
                            <div class="img-with-text">
                                <img src="/assets/images/couple-fighting-image.PNG" alt="a picture of a couple fighting" class="image-container-img">
                                <h4 class="img-with-text-h4">Another celebrity couple calls it quits. Why can't the rich and famous stay together?</h4>
                                <span class="img-with-text-span">By Adriana Huber 30.06.2020</span>
                            </div>
                        </div>

                        <div class="bottom-message">
                            <div class="bottom-message-content">
                                <h1 class="bottom-message-h1">The rich are getting richer</h1>
                                <p class="bottom-message-content-p">And so can you. By becoming an online trader of currencies, stocks  and commodities,  you too can increase your monthly income and upgrade your standard of living </p>
                                <button class="bottom-message-button">Start with free 1-on-1 coaching</button>
                            </div>
                        </div>
                      </section>
                      <aside>
                        <div class="aside-first-section">
                            <h3>Hot Topics</h3>
                        </div>
                        <div class="aside-second-section">
                        <img src="/assets/images/second-column-first-img.PNG" alt="" class="aside-img">
                        <h2 class="aside-h2">Man steals  &pound;  2,500,000 from the <br> bank with a legal loophole!</h2>
                        </div>

                        <div class="aside-third-section">
                            <img src="/assets/images/second-column-second-img.PNG" alt="" class="aside-img">
                            <h2 class="aside-h2">Does praying to God for money <br> actually work?</h2>
                            </div>

                            <div class="line"></div>

                            <div class="aside-third-section">
                                <img src="/assets/images/second-column-sixth-image.png" alt="" class="aside-img">
                                <h2 class="aside-h2">Japanese scientists have <br> discovored the secret of making money. Find out if it's real.</h2>
                                </div>
    
                            <div class="box-message">
                                <div class="box-message-content">
                                    <p class="box-message-p">Learn more about online stock trading and how you can profit.</p>
                                    <a class="box-message-a" href="">Start Now</a>
                                </div>
                            </div>
                            <div class="trending-news-div">
                                <h3>Trending Financial News</h3>
                            </div>
                            <div class="aside-third-section">
                                <img src="/assets/images/second-column-third-image.png" alt="" class="aside-img">
                                <h2 class="aside-h2">Royal family goes bancrupt. <br> Could be out on the streets very soon.</h2>
                                </div>

                                <div class="line"></div>

                                <div class="aside-third-section">
                                    <img src="/assets/images/second-column-forth-image.png" alt="" class="aside-img">
                                    <h2 class="aside-h2">Man wins the lottery and blows it <br> all in a Spanish casino.</h2>
                                </div>

                                <div class="aside-third-section">
                                    <img src="/assets/images/second-column-fifth-image.png" alt="" class="aside-img">
                                    <h2 class="aside-h2">Silver vs Gold. Our experts give <br> you the breakdown.</h2>
                                </div>

                      </aside>
                </div>
            </div>
            <div class="footer">
            <section class="footer-section">
                <div class="footer-content">
                    <p class="capital-words">TERMS AND CONDITIONS CAREFULLY READ AND AGREE TO TERMS BELOW:</p>
                    <br>
                        <p>We are not affiliated in any way with any news publication. All trademarks on this web site whether registered or not, are the property of their respective owners. The authors of this web site are not sponsored by or affiliated with any of the third-party trade mark or third-party registered trade mark owners, and make no representations about them, their owners, their products or services. It is important to note that this site and the comments/answers depicted above is to be used as an illustrative example of what some individuals have achieved with this/these products. The website, and any page on the website, is based loosely off a true story, but has been modified in multiple ways including, but not limited to: the story, the photos, and the comments. Thus, this page, and any page on this website, are not to be taken literally or as a non-fiction story. Ther page, and the results mentioned on this page, although achievable for some, are not to be construed as the results that you may achieve on the same routine. I UNDERSTAND THIS WEBSITE IS ONLY ILLUSTRATIVE OF WHAT MIGHT BE ACHIEVABLE FROM USING THIS/THESE PRODUCTS, AND THAT THE STORY/COMMENTS DEPICTED ABOVE IS NOT TO BE TAKEN LITERALLY. Ther page receives compensation for clicks on or purchase of products featured on this site.</p><br>
                        <p class="capital-words">IMPORTANT CONSUMER DISCLOSURE</p><br>
                        <p>The term "advertorial" is a combination of "advertisement" and "editorial" written in an editorial format as an independent news story, when in fact the advertisement may promote a particular product or interest. Advertorials take factual information and report it in an editorial format to allow the author, often a company marketing its products, to enhance or explain certain elements to maintain the reader's interest. A familiar example is an airline's in-flight magazines that provide an editorial reports about travel destinations to which the airline flies.</p><br>
                        <p>As an advertorial, I UNDERSTAND THIS WEBSITE IS ONLY ILLUSTRATIVE OF WHAT MIGHT BE ACHIEVABLE FROM USING THIS PROGRAM, AND THAT THE STORY DEPICTED ABOVE IS NOT TO BE TAKEN LITERALLY. Ther page receives compensation for clicks on or purchase of products featured on this site. Ther program is not a job but an educational opportunity that can help individuals learn how to earn money through their entrepreneurial efforts. Anyone who decides to buy any program about making money will not necessarily make money simply by purchasing the program. People who think "I bought these materials so I'm going to automatically make money" are wrong. As any type of education has so many variables, it is impossible to accurately state what you may expect to achieve, however, people who bought the program not only bought the program, but also undertook additional training and education, applied the principles to an area of the market that was growing, kept their commitments and continued to learn. If you do what the individuals depicted did, you may generally expect to achieve a great education in the area of your choice, but you should not expect to earn any specific amount of money. Typical users of the starter materials that don't enroll in coaching, don't keep their commitments and don't implement what they learn, generally make no money. Though the success of the depicted individual is true, her picture and name have been changed to protect her identity. Consistent with the advertorial concept, the comments posted in the comment section are also representative of typical comments and experiences which have been compiled into a comment format to illustrate a dialogue, however, the comments are not actual posts to this webpage and have been compiled or generated for illustrative purposes only.</p><br>
                        <p>We are not affiliated in any way with CNN, WebTV, News Channel 1, ABC, NBC, CBS, U.S. News or FOX, and all such trademarks on this web site, whether registered or not, are the property of their respective owners. The authors of this web site are not sponsored by or affiliated with any of the third-party trade mark or third-party registered trade mark owners, and make no representations about them, their owners, their products or services.</p>
                </div>
                <div class="footer-links">
                    <a class="footer-links-a" href="">Cookie Policy</a>
                    <a class="footer-links-a" href="">Privacy Policy</a>
                    <a class="footer-links-a" href="">Data Processing Agreement</a>
                    <a class="footer-links-a" href="">Terms and Conditions</a>
                </div>
                <p class="testimonials-p">*Testimonials:
                    All characters, information and events depicted on This Website are entirely fictitious. Any similarity to actual events or persons, living or dead, is purely coincidental.</p>
                    <p class="copyright-p">&copy;    fortunetonight.com 2020</p>
            </section>
            </div>
        </div>

我尝试以像素和 em 为单位设置宽度,但这仍然不能解决问题

标签: htmlcss

解决方案


你有一个800px设置的宽度.footer-links 这意味着,无论你的窗口有多宽,它都会保持在 800 像素,这会让你左右滚动。

将宽度更改.footer-links100%或将其全部删除,这应该可以解决它。


推荐阅读