简体   繁体   English

为什么我的花车不工作

[英]Why aren't my floats working

I am trying to create a footer for a website and need there to be two sets of links on either side. 我正在尝试为网站创建页脚,并且需要在两边都有两组链接。 I have it all in a div and the links for the left and right sides are in uls and their own divs that have ids. 我将所有内容都放在一个div中,左侧和右侧的链接都在uls和它们自己的具有id的div中。 This is my HTML: 这是我的HTML:

<div class="bb">
        <div class="fl">
            <ul>
                <li><a href="link">Advertising</a></li>                                 
                <li><a href="link">Business</a></li>
                <li><a href="link">About</a></li>
            </ul>
        </div>
        <div class="fr">
            <ul>    
                <li><a href="link">Privacy</a></li>
                <li><a href="link">Terms</a></li>
                <li><a href="link">Settings</a></li>
            </ul>
        </div>
    </div>

And here is the CSS I have going along with it: 这是我一直沿用的CSS:

.bb {position: fixed;bottom: 0;list-style: none;margin: 0;padding: 0;text-align: right;}
.fl {display: inline-block;float: left;}
.fr {display: inline-block;float: right;}
.fl li {display: inline;}
.fr li {display: inline;}

Why is the footer for the right side not floating all the way to the right side of the page? 为什么右侧的页脚没有一直浮动到页面的右侧? Thanks for any help 谢谢你的帮助

To my understanding, the problem is your whole footer bb does not have a width. 据我了解,问题在于您的整个页脚bb没有宽度。 Just adding width:100% to bb will solve this. 只需在bb添加width:100%即可解决此问题。

The fr actually floats, however, inside the footer bb . fr实际上在页脚bb内浮动。

I put a jsfiddle at https://jsfiddle.net/Lw93vtgr/ showing this. 我在https://jsfiddle.net/Lw93vtgr/上显示了一个jsfiddle。

Further, you may not want to assign float with inline-block , the result display would be block anyway. 此外,您可能不希望为inline-block分配float ,结果display仍然是block

So i think you forgot set the width of class .bb 所以我认为您忘记设置班级.bb的宽度了

In your code, <div class=".bb"> have a width equal to your content. 在您的代码中, <div class=".bb">的宽度等于您的内容。

You can try to set .bb class with width 100% or equal to your page width 您可以尝试将.bb类设置为宽度100%或等于页面宽度

You must remove the position: fixed; 您必须删除职位:固定; from the bb class, or else specify the width of it. bb类,或者指定它的宽度。

尝试将width: 100%添加到类.bb

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

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