我的页脚不占满整个页面长度 – Bootstrap

huangapple go评论90阅读模式
英文:

My footer does not take the whole length of the page - Bootstrap

问题

我知道这个问题已经被问过多次,但我没有找到适合我的解决方案,我尝试按照这个解决方案上指定的方法使用container-fluid,但似乎不起作用。

一切都进行得很顺利,但当我添加我的页脚时,它并未占据整个页面或整个行的长度,这是由container-fluid的填充引起的。

这里是代表问题的图片:

我的页脚不占满整个页面长度 – Bootstrap

正如您所看到的,边框没有完全占据整个长度

这是当我从包含我的主内容的container-fluid中删除填充时的照片:

我的页脚不占满整个页面长度 – Bootstrap

正如您所看到的,出现了水平溢出

因此,我的问题是,我是否需要担心修复溢出问题,还是将页脚放在整个长度上?我不知道应该采取哪种方法!

我的HTML页脚:

<footer id="footer">
    <div class="row">
        <div class="col-md-12">
            <div class="row">
                <div class="col-md-6">
                    <form action="" method="post">
                        <div class="form-group">
                            <label for="email_newsletter">S'inscrire gratuitement à la Newsletter :</label>
                            <input type="email" id="email_newsletter" class="form-control w-50 email" aria-describedby="email_newsletter_note">
                            <small id="email_newsletter_note" class="form-text text-muted">Nous ne partageons en aucun cas vos informations.</small>
                        </div>
                        <button type="submit" class="btn btn-primary">Valider</button>
                    </form>
                </div>
                <div class="col-md-6">
                    <a href="">Mentions Légales</a>
                </div>
            </div>
        </div>
    </div>
</footer>
英文:

I know that the question has already been asked several times, but I did not find any solution suited to my case, I tried to put a container-fluid as specified on this solution, but it does not seem to work.

Everything is going well, but when I add my footer, it does not take the whole length of the page, or of the row, there are padding caused by that of the container-fluid.

Here is a picture representing the problem :

我的页脚不占满整个页面长度 – Bootstrap

As you can see, the borders do not complete the entire length

Here is a photo of when I remove the padding from my container-fluid which includes all of my main :

我的页脚不占满整个页面长度 – Bootstrap

As you can see, a overflow-x appears

So my question is, do I have to worry about fixing the overflow problem, or putting my footer on the whole length ? I don't know which track should I take !

My HTML footer :

&lt;footer id=&quot;footer&quot;&gt;
    &lt;div class=&quot;row&quot;&gt;
        &lt;div class=&quot;col-md-12&quot;&gt;
            &lt;div class=&quot;row&quot;&gt;
                &lt;div class=&quot;col-md-6&quot;&gt;
                    &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;
                        &lt;div class=&quot;form-group&quot;&gt;
                            &lt;label for=&quot;email_newsletter&quot;&gt;S&#39;inscrire gratuitement &#224; la Newsletter :&lt;/label&gt;
                            &lt;input type=&quot;email&quot; id=&quot;email_newsletter&quot; class=&quot;form-control w-50 email&quot; aria-describedby=&quot;email_newsletter_note&quot;&gt;
                            &lt;small id=&quot;email_newsletter_note&quot; class=&quot;form-text text-muted&quot;&gt;Nous ne partageons en aucun cas vos informations.&lt;/small&gt;
                        &lt;/div&gt;
                        &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Valider&lt;/button&gt;
                    &lt;/form&gt;
                &lt;/div&gt;
                &lt;div class=&quot;col-md-6&quot;&gt;
                    &lt;a href=&quot;&quot;&gt;Mentions L&#233;gales&lt;/a&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/footer&gt;

答案1

得分: 2

**解决方案:**

我的页脚位于一个container-fluid中,只需将它移到外面,并将container-fluid添加到我的页脚本身:

```html
<footer id="footer" class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <div class="row">
                <div class="col-md-6">
                    <form action="" method="post">
                        <div class="form-group">
                            <label for="email_newsletter">免费订阅电子报:</label>
                            <input type="email" id="email_newsletter" class="form-control w-50 email" aria-describedby="email_newsletter_note">
                            <small id="email_newsletter_note" class="form-text text-muted">我们绝不分享您的信息。</small>
                        </div>
                        <button type="submit" class="btn btn-primary">确认</button>
                    </form>
                </div>
                <div class="col-md-6">
                    <a href="">法律声明</a>
                </div>
            </div>
        </div>
    </div>
</footer>

<details>
<summary>英文:</summary>

**Solution :**

My footer was in a container-fluid, it was enough to bring it out of there and to add a container-fluid to my footer itself :

```html
&lt;footer id=&quot;footer&quot; class=&quot;container-fluid&quot;&gt;
    &lt;div class=&quot;row&quot;&gt;
        &lt;div class=&quot;col-md-12&quot;&gt;
            &lt;div class=&quot;row&quot;&gt;
                &lt;div class=&quot;col-md-6&quot;&gt;
                    &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;
                        &lt;div class=&quot;form-group&quot;&gt;
                            &lt;label for=&quot;email_newsletter&quot;&gt;S&#39;inscrire gratuitement &#224; la Newsletter :&lt;/label&gt;
                            &lt;input type=&quot;email&quot; id=&quot;email_newsletter&quot; class=&quot;form-control w-50 email&quot; aria-describedby=&quot;email_newsletter_note&quot;&gt;
                            &lt;small id=&quot;email_newsletter_note&quot; class=&quot;form-text text-muted&quot;&gt;Nous ne partageons en aucun cas vos informations.&lt;/small&gt;
                        &lt;/div&gt;
                        &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Valider&lt;/button&gt;
                    &lt;/form&gt;
                &lt;/div&gt;
                &lt;div class=&quot;col-md-6&quot;&gt;
                    &lt;a href=&quot;&quot;&gt;Mentions L&#233;gales&lt;/a&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/footer&gt;

答案2

得分: 0

以下是代码的翻译部分:

&lt;footer class=&quot;page-footer&quot;&gt;

    &lt;!-- Footer Links --&gt;
    &lt;div class=&quot;container-fluid&quot;&gt;

        &lt;!-- Grid row --&gt;
        &lt;div class=&quot;row&quot;&gt;

            &lt;!-- Grid column --&gt;
            &lt;div class=&quot;col-md-6 mt-md-0 mt-3&quot;&gt;

                &lt;!-- Content --&gt;
                &lt;h5 class=&quot;text-uppercase&quot;&gt;Footer Content&lt;/h5&gt;
                &lt;p&gt;Here you can use rows and columns to organize your footer content.&lt;/p&gt;

            &lt;/div&gt;
            &lt;!-- Grid column --&gt;

            &lt;hr class=&quot;clearfix w-100 d-md-none pb-3&quot;&gt;

            &lt;!-- Grid column --&gt;
            &lt;div class=&quot;col-md-3 mb-md-0 mb-3&quot;&gt;

                &lt;!-- Links --&gt;
                &lt;h5 class=&quot;text-uppercase&quot;&gt;Links&lt;/h5&gt;

                &lt;ul class=&quot;list-unstyled&quot;&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;#!&quot;&gt;Link 1&lt;/a&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;#!&quot;&gt;Link 2&lt;/a&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;#!&quot;&gt;Link 3&lt;/a&gt;
                    &lt;/li&gt;
                    &lt;li&gt;
                        &lt;a href=&quot;#!&quot;&gt;Link 4&lt;/a&gt;
                    &lt;/li&gt;
                &lt;/ul&gt;

            &lt;/div&gt;
            &lt;!-- Grid column --&gt;


        &lt;/div&gt;
        &lt;!-- Grid row --&gt;

    &lt;/div&gt;
    &lt;!-- Footer Links --&gt;

    &lt;!-- Copyright --&gt;
    &lt;div class=&quot;footer-copyright text-center py-3&quot;&gt;&#169; 2020 Copyright:
        &lt;a href=&quot;https://mdbootstrap.com/education/bootstrap/&quot;&gt; MDBootstrap.com&lt;/a&gt;
    &lt;/div&gt;
    &lt;!-- Copyright --&gt;

&lt;/footer&gt;
&lt;!-- Footer --&gt;
英文:

The code gives the whole length footer of the page

&lt;footer class=&quot;page-footer&quot;&gt;
    
      &lt;!-- Footer Links --&gt;
      &lt;div class=&quot;container-fluid&quot;&gt;
    
        &lt;!-- Grid row --&gt;
        &lt;div class=&quot;row&quot;&gt;
    
          &lt;!-- Grid column --&gt;
          &lt;div class=&quot;col-md-6 mt-md-0 mt-3&quot;&gt;
    
            &lt;!-- Content --&gt;
            &lt;h5 class=&quot;text-uppercase&quot;&gt;Footer Content&lt;/h5&gt;
            &lt;p&gt;Here you can use rows and columns to organize your footer content.&lt;/p&gt;
    
          &lt;/div&gt;
          &lt;!-- Grid column --&gt;
    
          &lt;hr class=&quot;clearfix w-100 d-md-none pb-3&quot;&gt;
    
          &lt;!-- Grid column --&gt;
          &lt;div class=&quot;col-md-3 mb-md-0 mb-3&quot;&gt;
    
            &lt;!-- Links --&gt;
            &lt;h5 class=&quot;text-uppercase&quot;&gt;Links&lt;/h5&gt;
    
            &lt;ul class=&quot;list-unstyled&quot;&gt;
              &lt;li&gt;
                &lt;a href=&quot;#!&quot;&gt;Link 1&lt;/a&gt;
              &lt;/li&gt;
              &lt;li&gt;
                &lt;a href=&quot;#!&quot;&gt;Link 2&lt;/a&gt;
              &lt;/li&gt;
              &lt;li&gt;
                &lt;a href=&quot;#!&quot;&gt;Link 3&lt;/a&gt;
              &lt;/li&gt;
              &lt;li&gt;
                &lt;a href=&quot;#!&quot;&gt;Link 4&lt;/a&gt;
              &lt;/li&gt;
            &lt;/ul&gt;
    
          &lt;/div&gt;
          &lt;!-- Grid column --&gt;
    
         
        &lt;/div&gt;
        &lt;!-- Grid row --&gt;
    
      &lt;/div&gt;
      &lt;!-- Footer Links --&gt;
    
      &lt;!-- Copyright --&gt;
      &lt;div class=&quot;footer-copyright text-center py-3&quot;&gt;&#169; 2020 Copyright:
        &lt;a href=&quot;https://mdbootstrap.com/education/bootstrap/&quot;&gt; MDBootstrap.com&lt;/a&gt;
      &lt;/div&gt;
      &lt;!-- Copyright --&gt;
    
    &lt;/footer&gt;
    &lt;!-- Footer --&gt;

huangapple
  • 本文由 发表于 2020年1月6日 02:43:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/59603071.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定