无论用户的屏幕尺寸如何,如何使用固定菜单覆盖整个页面宽度?
我对固定且位于页面中央的菜单有疑问。我希望整个菜单(3 个背景图像)覆盖整个页面宽度,无论用户的屏幕尺寸是什么。
原图:(
图1:宽1px,高76px;)
(图2:宽1135px,高76px;)
(图3:宽度1px,高度76px;)
CSS更改后我希望这些变成:(
图1:宽度392,5px,高度76px;)
(图2:宽1135px,高76px;)
(图3:宽度392,5px,高度76px;)
<div style="position:fixed; width:100%; height:76px;">
<div> Picture 1 </div> <!-- repeat-x on the left side -->
<div> Picture 2 , center of the page , no-repeat</div>
<div> Picture 3</div> <!-- repeat-x on the right side -->
</div>
我想在图1和图3上设置repeat-x,但不知道宽度。我可以用 jQuery 修复它,但 CSS 中没有办法吗?
I have a problem with a menu that is fixed and centered on the page. I want the entire menu (3 background images) to cover the entire page width, regardless what the screen size user have.
Orginal pictures:
(Picture 1: width 1px, height 76px;)
(Picture 2: width 1135px, height 76px;)
(Picture 3: width 1px, height 76px;)
After CSS changes I want those to become:
(Picture 1: width 392,5px, height 76px;)
(Picture 2: width 1135px, height 76px;)
(Picture 3: width 392,5px, height 76px;)
<div style="position:fixed; width:100%; height:76px;">
<div> Picture 1 </div> <!-- repeat-x on the left side -->
<div> Picture 2 , center of the page , no-repeat</div>
<div> Picture 3</div> <!-- repeat-x on the right side -->
</div>
I want to set the repeat-x on picture 1 and 3, but don't know the width. I can fix it with jQuery but aren't there a way in CSS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新了透明中心图像请参阅,http://jsfiddle.net/QEPX4/ 5/show/
HTML
CSS(代表)
如果你不关心IE7,那么你可以去掉左右两侧嵌套的
div
元素,将css替换为伪元素选择器如:Updated for transparent center image See, http://jsfiddle.net/QEPX4/5/show/
HTML
CSS (representative)
If you don't care about IE7, then you can eliminate the nested
div
elements in the left and right sides and replace the css with pseudo element selectors like: