简体   繁体   English

某些div的页脚部分出现问题

[英]Troubles in the footer part with some divs

I have a headache with all this positioning stuff, so I decided to ask you about it; 我对所有这些定位材料都感到头疼,所以我决定向您询问。 I already read blogs about the positioning of this kind of things but as a beginner, it's a bit difficult to find the exact answer. 我已经读过关于这种事情定位的博客,但是作为一个初学者,要找到确切的答案有点困难。

I have the following problem: 我有以下问题:

In the image you will see what I have (I can't post it, so here is the link of the SS: http://gyazo.com/bbea3f21abf77515288719296e496fcc ), I want to move: "copyright blablabla" at the bottom of the footer using all the width of the footer, I already tried everything like: 在图像中,您将看到我所拥有的(我无法发布,所以这里是SS的链接: http : //gyazo.com/bbea3f21abf77515288719296e496fcc ),我想移动:“版权blablabla”在底部使用页脚的所有宽度的页脚,我已经尝试了所有类似方法:

footer #copyright{
    font-size: 75%;
    top: 20em; /* just trying*/
    position: relative;
    text-align: center;
    width: 100%;

But the div keeps hitting the other elements (the terms and conditions, privacy and stays exactly like you see in the image). 但是div仍然会触及其他元素(条款和条件,隐私权,并且保持与您在图片中看到的完全一样)。 The code of the "terms and conditions, etc, is this one: “条款和条件等”的代码如下:

footer li a{
    font-size: 90%;
    text-decoration:none; /* Quita toda decoracion del texto*/
    position: relative;
      /* este comando convierte en boton el reectangulo*/
    vertical-align: text-top;
        float: right;
         width: 30%;

Can anyone help me? 谁能帮我?

PD: I add my html code: PD:我添加了我的html代码:

    <footer>


        <li><a href="#contactus">Contact us</a></li>
        <li><a href="#privacy">Privacy policy</a></li>
        <li><a href="#terms">Terms and conditions</a></li>
        <li><a href="#aboutus">About us</a></li>

        <a id="copyright">Copyright 2015 Pepito S.L., All Right Reserved.</a>

    </footer>
</body>

And about my CSS, is this one: 关于我的CSS,是这样的:

* {
    margin: 0;
    padding: 0;
    font-family: verdana;
}

footer {
    width: 100%;
    height: 12em;
    background-color: #363636;
}

footer li {
    list-style: none;
    text-transform: uppercase;
}

footer li a{
    font-size: 90%;
    text-decoration:none; /* Quita toda decoracion del texto*/
    position: relative;
      /* este comando convierte en boton el reectangulo*/
    vertical-align: text-top;
        float: right;
         width: 30%;


         /* Borde para ver el div*/
    color: #696969;
      border: 1px solid #f00;

}

footer a #copyright{
    font-size: 5%;
    position: absolute;
    text-align: center;
    bottom: 0;

/* Borde para ver el div*/
    color: #696969;
      border: 1px solid #f00;

 }

Try following on the footer 尝试跟随页脚

footer {
    position: absolute; /* or fixed if you want */
    bottom: 0;
}

This will set it to the bottom of the page with a space of 0 pixel, so directly at the bottom. 这会将其设置在页面底部,间距为0像素,因此直接位于底部。

Remember this technic if you also want to place something relativly at a position like example right and the width of the element is unknown, so you don't have to calculate how much it has to be from the left, but only set the space from the right side, like right: 25px; 如果您还想相对地在示例右侧的位置放置一些东西,而元素的宽度未知,则请记住此技术,因此您不必计算必须从左侧开始的距离,而只需从右侧, right: 25px; .

Also read and understand the differences betweet every position property (relative, absolute, static, fixed) this will help you ALOT! 同时阅读并理解每个position属性(相对,绝对,静态,固定)之间的差异,这将对您有很大帮助! After I understood this, I felt like leveling up 10 levels! 了解了这一点之后,我感觉就像升级了10个级别! This helped so much, that I could optimize everything I ever did and prevented maaaaany problems I had in the past. 这极大地帮助了我,使我可以优化自己曾经做过的一切,并避免了过去遇到的严重问题。

EDIT 编辑

At this point the question has been edited and the code was given. 至此,问题已被编辑并给出了代码。 I assumed the top links are the header, but now I understand that the WHOLE thing should be the footer. 我假设顶部链接是页眉,但现在我知道应该将整个页脚作为页脚。

So positioning the footer alone won't have an affect, so the solution from Mathieu David should fit. 因此,单独放置页脚不会有任何影响,因此Mathieu David的解决方案应该适用。

Let this be an example for: Why I always should provide as much as possible information and details, also ask as best as possible and not to self-confident, because other people don't know what you are actually trying 让我们以此为例: 为什么我总是要提供尽可能多的信息和细节,也要尽可能多地询问而不是自信,因为其他人不知道您实际上在尝试什么

What you probably want is to set position: relative in the footer div and put position: absolute in the element that contains the copyright. 您可能想要的是在页脚div中设置position: relative ,在包含版权的元素中放置position: absolute

<footer>
    ...
    <div class="copyright">Copyright</div>
</footer>

and in the css 和在CSS

footer{
    position: relative;
}

.copyright{
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
}

JSFidle JSFidle

Use position: absolute; 使用position: absolute; (and relative to footer ). (和relative对于footer )。

footer {height: 130px; position: relative;}
footer #copyright {position: absolute; bottom: 0;}

https://jsfiddle.net/zkxjasf0/ https://jsfiddle.net/zkxjasf0/

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

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