【发布时间】:2013-12-04 18:28:55
【问题描述】:
我目前正在做一个项目,该项目需要元素顶部和底部的边框,并将其扩展到页面边缘。我有一个 960px 宽的包装器,我已将 overflow-x 设置为在 body 和 html 上隐藏。我正在使用以下样式。
#profile-page{
position:relative;
overflow:hidden;
}
#profile-page .bottom:after, #profile-page .bottom:before {
content: "";
position: absolute;
left: 0px;
right: 0px;
height: 5px;
background-image: -webkit-linear-gradient(0deg, #7ad100 95px, #00bce8 95px, #00bce8 190px, #ffde00 190px, #ffde00 285px, #ff5942 285px, #ff5942 380px);
background-image: -ms-linear-gradient(0deg, #7ad100 95px, #00bce8 95px, #00bce8 190px, #ffde00 190px, #ffde00 285px, #ff5942 285px, #ff5942 380px);
background-image: -moz-linear-gradient(0deg, #7ad100 95px, #00bce8 95px, #00bce8 190px, #ffde00 190px, #ffde00 285px, #ff5942 285px, #ff5942 380px);
background-size: 380px;
}
#profile-page .bottom:before{
top: -2px;
}
#profile-page .bottom:after{
bottom: -2px;
}
#profile-page .bottom{
padding-left:3000px;
margin-left:-3000px;
padding-right:3000px;
margin-right:-3000px;
position:relative;
background: #ffffff;
}
样式在 Firefox 中显示良好,但在 chrome 或 ie9 中不显示(尚未测试其他人)。我已包含屏幕截图,以便您查看实际输出。
如果我删除样式以使 .bottom 拉伸到屏幕边缘,则样式会以 chrome 显示。我不知道该样式的哪一部分与我的伪元素混淆,但希望这里有人知道。提前致谢。
编辑:只是想澄清一下,如果我删除以下规则,我将 REMOVE 放在假冒出现的旁边。但是后来我的 div 不再到达屏幕边缘并包含在包装器中,这不可能发生
#profile-page .bottom{
padding-left:3000px; -REMOVE
margin-left:-3000px; -REMOVE
padding-right:3000px; -REMOVE
margin-right:-3000px; -REMOVE
position:relative;
background: #ffffff;
}
CSS 有点用 less 编写,试图去掉任何 Less 捷径,但可能会遗漏一些捷径,以防人们认为他们看到了错误。
编辑:根据要求,HTML 结构
<html>
<body id="profile-page">
<div id="wrapper">
<div class="top"></div>
<div class="item bottom">
<div id="profile-content">PROFILE LINKS</div>
</div>
</div>
</body>
</html>
顶部是firefox,底部是chrome
【问题讨论】:
-
如果这不起作用,请发布您的一些 HTML 结构,以便我们查看您正在使用的内容。
-
@Diodeus 我认为我根据该主题正确使用了它们。
-
@Nathan,我添加了 HTML 结构。这是非常基本的。
-
你能把你的 .bottom div 移到包装器之外吗?如果是这样,您可以使 .bottom 充当包装器,然后将 #profile-content 设置为您需要的宽度。
标签: html css google-chrome firefox pseudo-element