CSS开始从固定位置重复背景

编程入门 行业动态 更新时间:2024-10-26 04:25:12
本文介绍了CSS开始从固定位置重复背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

#container的{    背景:网址(图像/ BG-main.png)重复-Y;    宽度:903px;    背景位置:0像素687px;    背景位置:底部;    高度:1200像素;    保证金左:自动;    保证金右:自动;    }#内容{    背景:网址(图像/ BG-wood.png)重复-Y;    宽度:903px;    高度:678px;    保证金左:自动;    保证金右:自动;    }

#内容 DIV是 #container的 DIV中。我想 #container的的背景,开始在687px从上重复。这可能吗?

编辑:?难道DIV的第一x像素(从顶部)有emtpy空间和后backgrund开始x像素

解决方案

背景:网址(映像路径)0像素287px重复-Y;

这会从垂直从287px顶部重复你的背景图片。

但另一种方式是将它设置为你的内容的div:

的margin-top:287px;

您最好的解决办法是做这样的:

#container的{    位置:相对;    }#背景{    背景:网址(图像URL');    位置:绝对的;    顶:287px;    左:0像素;    的z-index:100;    }#内容{    位置:绝对的;    顶:0像素;    左:0像素;    的z-index:99999;    }

#container{ background:url(images/bg-main.png) repeat-y; width: 903px; background-position: 0px 687px; background-position: bottom; height: 1200px; margin-left: auto; margin-right: auto; } #content{ background:url(images/bg-wood.png) repeat-y; width: 903px; height: 678px; margin-left: auto; margin-right: auto; }

#content div is inside #container div. I want #container's background to start repeating at 687px from top. Is it possible?

EDIT: Is it possible that first x pixels of div (from top) have emtpy space and after x pixels backgrund starts?

解决方案

background : url('image path') 0px 287px repeat-y;

This will repeat vertically your background image from 287px from top.

but another way is to set this to your content div :

margin-top:287px;

you best solution is to do like this :

#container{ position:relative; } #background{ background:url('image url'); position:absolute; top:287px; left:0px; z-index:100; } #content{ position:absolute; top:0px; left:0px; z-index:99999; }

更多推荐

CSS开始从固定位置重复背景

本文发布于:2023-10-08 03:03:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471318.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:背景   位置   CSS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!