如何在 div 的左侧和右侧拥有可平铺的区域?

发布于 2024-12-20 17:47:23 字数 406 浏览 0 评论 0原文

我有一个 div#main,它有一个带有渐晕效果的背景图像。

中心图像背景

我想将此完整图像保留在页面的中心,但我想要一个图形来平铺屏幕的最左侧平铺到该图像,另一个图形从图像的右侧平铺到屏幕的最右侧。我不关心平铺我意识到我可能会要求设计师让图像的左边缘和右边缘具有相同的颜色和纹理,这样我就可以在背景中放置相同的纹理颜色,但我想看看是否我可以按原样解决它。

所以我认为设计师需要创建两个单独的图形。一个与图像的左边缘很好地平铺和混合,另一个图形与图像的右边缘很好地平铺和混合。

我将如何设置我的 div 和 css,以便左侧图块区域知道从屏幕的最左侧开始并停止在图像的左侧,并且右侧图块区域知道从右边缘开始图像并继续到屏幕的最右侧?

I have a a div#main that has a background image with a vignetting effect.

center image background

I want to keep this full image in the center of the page but I would like for a graphic to tile from the far left of the screen to this image, and another graphic to tile from the right side of the image to the far right side of the screen. I'm not concerned with tiling veI realize I could probably ask the designer to have the left and right edges of the image be the same color and texture so I could put the same textured color in the background, but I was trying to see if I can solve it as is.

So I assume I would need for the designer to create two separate graphics. One that tiles and blends in nicely with the left edge of the image, and another graphic that tiles and blends in nicely with the right edge of the image.

How would I set up my div's and css so that the left tile area knows to start at the far left side of the screen and to stop at the left side of the image and also so the right tile area knows to start at the right edge of the image and continue to the far right side of the screen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

标点 2024-12-27 17:47:23

像这样的东西会起作用,其中 bg_tile.jpg 是没有渐晕的平铺背景,而 bg.jpg 是您的描述中发布的图像:

#main_wrapper {
  background: url(/images/bg_tile.jpg) repeat 50% 0;
}

#main {
    width: 960px;
    height: 300px;
    margin: 0 auto;
    background: url(/images/bg.jpg) no-repeat 50% 0 transparent;
}

Cultureamp(iPad 后面)。检查 css 以查看其实际效果。

Something like this would work, where bg_tile.jpg is the tile-able background without vignetting, and bg.jpg is the image as posted in your description:

#main_wrapper {
  background: url(/images/bg_tile.jpg) repeat 50% 0;
}

#main {
    width: 960px;
    height: 300px;
    margin: 0 auto;
    background: url(/images/bg.jpg) no-repeat 50% 0 transparent;
}

There is a similar effect on Cultureamp (behind the iPad). Check the css to see it in action.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文