首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何创建一个100%固定页脚与固定宽度中心透明间隙?

如何创建一个100%固定页脚与固定宽度中心透明间隙?
EN

Stack Overflow用户
提问于 2013-03-18 20:05:06
回答 4查看 791关注 0票数 2

如何创建一个100%固定页脚与固定宽度中心透明间隙?没有剧本!

以这种方式展开______ ______固定宽度隙______ >>>这样展开

我自己的解决方案

代码语言:javascript
复制
<div id="Ftr">
  <div id="FtrL"></div>
  <div id="FtrM"></div>
  <div id="FtrR"></div>
</div>

CSS

代码语言:javascript
复制
#Ftr {
    position: fixed;
    height: 115px;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 21;
}
#FtrL,
#FtrR {
    position: absolute;
    bottom: 0;
    height: 100%;
    width: calc(50% - 360px);
    width: -webkit-calc(50% - 360px);
}
#FtrL {
    background: url('../Images/Layout/footer_left.png') repeat-x;
    left: 0;
}
#FtrR {
    background: url('../Images/Layout/footer_left.png') repeat-x;
    right: 0;
}
#FtrM {
    background: url('../Images/Layout/footer_middle.png') no-repeat;
    height: 115px;
    width: 720px;
    margin: 0 auto;
}

参见此处的实时数据:http://www.dreamtek.info

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2013-03-18 21:23:07

仅使用CSS和CSS3 calc函数帮助:

可以使用以下CSS属性定义侧DIV元素宽度:

代码语言:javascript
复制
width: calc((100% - 200px) / 2); /* browsers with native support */
width: -webkit-calc((100% - 200px) / 2); /* webkit browsers support, Chrome, Safari... */
width: -moz-calc((100% - 200px) / 2); /* Firefox support */

其中200 is 为中心DIV固定宽度。这样,剩余的水平空间将被双方的DIV元素平均填充。请注意,这不是一个跨浏览器兼容的解决方案。如果您想要一个(如果需要,请参阅我的另一个答案),您可能需要使用javascript

演示

+1用于“提醒我想起webkit-calc问题”的作者

票数 2
EN

Stack Overflow用户

发布于 2013-03-18 20:15:53

代码语言:javascript
复制
<div id="footer">
  <div class="left"></div>
  <div class="right"></div>
  <div class="center"></div>
</div>


#footer {
  position: fixed; left: 0; bottom: 0; overflow: hidden; width: 100%;
}

#footer .left {
  float: left: width: 200px; height: 115px;
  background: url('../Images/Layout/footer_left.png') repeat-x;
}

#footer .right {
  float: right: width: 200px; height: 115px;
  background: url('../Images/Layout/footer_right.png') repeat-x;
}

#footer .center {
  overflow: hidden; height: 115px;
  background: url('../Images/Layout/footer_middle.png') no-repeat;
}
票数 1
EN

Stack Overflow用户

发布于 2013-03-18 20:50:02

我不认为你可以做你想要的跨浏览器与CSS ,只有。然而,尽管你说没有脚本(嘿,不要打我,好吗?!)让我向您展示使用几行javascript (使用jQuery,但您不需要)就可以实现它是多么容易。

演示

HTML

代码语言:javascript
复制
<div id="FtrM">
    <div id="FtrL"></div>
    <div id="FtrC"></div>
    <div id="FtrR"></div>
</div>

CSS

代码语言:javascript
复制
#FtrM {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 120px;
}
#FtrL, #FtrR, #FtrC {
    float: left;
    height: 100%;
}
#FtrL, #FtrR {
    width: 100px;
    background-color: black;
}

#FtrC {
    background: none;
    width: 200px;
}

JS

代码语言:javascript
复制
function calc() {
    $('#FtrL, #FtrR').width(($('#FtrM').width() - $('#FtrC').width()) / 2);
}
calc();
$(window).resize(calc);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15485878

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档