CSS 布局与边框的问题
我目前正在为客户 http://minta.jvsoftware.com/ 在以下网站工作,但我我正在尝试使主容器 div
的顶部和底部边框看起来像这样 http://awesomescreenshot.com/0f8jdwn71 基本上使边框向左延伸到屏幕末端(不要介意红色,这应该是相同的颜色作为我现在的边界)。
我一直在尝试提出一个解决方案,但到目前为止我失败了,如果仅用 css 实现它变得太困难,我愿意尝试 JS/jQuery 解决方案。
谁能帮助我吗?提前致谢!
I'm currently working in the following site for a client http://minta.jvsoftware.com/ but I'm trying to make the top and bottom borders of the main container div
to look like this http://awesomescreenshot.com/0f8jdwn71 basically make the borders span to the left up to the end of the screen (don't mind the red color this is supposed to be the same color as the border I have now).
I've been trying to come up with a solution but so far I have failed, I'm willing to try a JS/jQuery solution if implementing it with just css becomes too hard.
Can anyone help me? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过带有负边距的纯 CSS 来实现此目的。
首先,您必须更新 .container 的 CSS,如下所示:
现在将主 div 的内容包装到另一个 div 中并应用一些 css,如下所示:
这里有一个屏幕截图可以帮助您弄清楚:
You can achieve this by pure CSS with negative margins.
First you have to update the CSS for .container as follows:
Now wrap the content of the main div into another div and apply some css like this:
Here a screenshot to help you figure it out:
为了实现你想要的布局,我认为你必须在容器div旁边放置一个,让它们向左浮动,并给这个div的顶部和底部边框加上红色
To achieve the layout you want, i think you have to put a at the left beside the container div and make them float left and give this div the border at the top and the bottom with the red color
为什么不使用“位置:绝对”?在这种情况下,我想这是完美的解决方案。
Why you don't use "position:absolute"? In this case it's perfect solution I guess.