【发布时间】:2012-05-04 00:19:25
【问题描述】:
所以我试图将一个页面(实际上只是一个页脚)分成 8 个相等的流体列(我的目标是 6 个),而我认为我能做到的唯一方法是使用百分比。
我为每个列设置了width: 12.5%; 的百分比(实际上是一些设置为display: block; float: left; 的链接),它应该可以工作,但它没有。我的意思是列或链接应该在页面中被平均划分,但仍然有一些空间,大约100px(我的屏幕宽度为1366px)。
那我该怎么办呢?如何划分链接/列是 8 个(最好是 6 个)相等的流体列?
<footer>
<div class="footer-jigsaw"></div>
<div class="footer-wrapper">
<nav class="navigation">
<a href=""></a>
<a href=""></a>
<a href=""></a>
<a href=""></a>
<a href=""></a>
<a href=""></a>
</nav>
</div>
</footer>
footer {
position:absolute;
bottom:0;
left:0;
width:100%;
height:50px;
background-image:url(../gfx/background-light.png);
background-position:center center;
background-repeat:repeat;
-webkit-opacity:0;
-moz-opacity:0;
opacity:0;
filter:alpha(opacity=0);
}
footer .footer-jigsaw {
position:absolute;
top:0;
width:100%;
height:10px;
background-image:url(../gfx/footer.png);
background-position:0 center;
background-repeat:repeat-x;
z-index:5;
}
footer .footer-wrapper {
position:relative;
margin:0 auto;
width:100%;
height:50px;
}
footer .footer-wrapper .navigation {
position:relative;
margin:0 auto;
width:100%;
height:50px;
}
footer .footer-wrapper .navigation a {
position:relative;
float:left;
display:block;
cursor:pointer;
width:12.5%;
height:50px;
padding-top:0;
padding-left:10px;
padding-right:10px;
padding-bottom:0;
font-family:good-times-bad-times;
font-size:inherit;
font-style:normal;
font-weight:400;
font-variant:normal;
text-align:center;
text-decoration:none;
text-shadow:none;
text-indent:inherit;
text-transform:none;
word-spacing:normal;
line-height:58px;
letter-spacing:normal;
color:#fff;
-webkit-transition:all .35s ease-in-out;
-moz-transition:all .35s ease-in-out;
-ms-transition:all .35s ease-in-out;
-o-transition:all .35s ease-in-out;
transition:all .35s ease-in-out;
}
footer .footer-wrapper .navigation a:first-child {
border:none;
}
footer .footer-wrapper .navigation a:last-child {
border:none;
}
footer .footer-wrapper .navigation a.jp-current {
background-color:rgba(0,0,0,0.2);
font-family:good-times-bad-times;
font-size:inherit;
font-style:normal;
font-weight:400;
font-variant:normal;
text-align:center;
text-decoration:none;
text-shadow:none;
text-indent:inherit;
text-transform:none;
word-spacing:normal;
line-height:58px;
letter-spacing:normal;
color:#00b8f0;
}
footer .footer-wrapper .navigation a.jp-current:hover {
background-color:rgba(0,0,0,0.2);
font-family:good-times-bad-times;
font-size:inherit;
font-style:normal;
font-weight:400;
font-variant:normal;
text-align:center;
text-decoration:none;
text-shadow:none;
text-indent:inherit;
text-transform:none;
word-spacing:normal;
line-height:58px;
letter-spacing:normal;
color:#00b8f0;
}
footer .footer-wrapper .navigation a:hover {
background-color:rgba(0,0,0,0.2);
font-family:good-times-bad-times;
font-size:inherit;
font-style:normal;
font-weight:400;
font-variant:normal;
text-align:center;
text-decoration:none;
text-shadow:none;
text-indent:inherit;
text-transform:none;
word-spacing:normal;
line-height:58px;
letter-spacing:normal;
color:#00b8f0;
}
以上是所有 CSS 的一部分,但我正在尝试做我刚才提到的事情。
问题已解决:向块中添加了额外的填充;
【问题讨论】:
-
向我们展示代码,否则我们将无能为力。 jsfiddle.net 是一个很好的起点
-
查看 Twitter Bootstrap 或 960 Grid System。不要重新发明轮子。
-
@binarious - 我不想对我的所有页面都这样做,我只希望我的页脚,块之间没有空格,没有填充没有边距,只有 6 或 8 个简单的块沿页面宽度均匀分布。我知道引导程序,但我不习惯使用任何框架(虽然听起来很愚蠢)。
-
你也可以发布页脚的基本 HTML 吗?这可能是相关的。一个 jsfiddle 或指向实时页面的链接甚至更好。另外,这个计划是 CSS 还是你使用 LESS 或 Sass/SCSS?如果它是通用 CSS,那么你就有一些 CSS 问题。
-
我用的是LESS,但是它的HTML是由插件生成的,反正我会把它输出的内容粘贴到浏览器中。
标签: css less fluid-layout