带有褪色边框的动态布局

发布于 2024-12-13 23:36:32 字数 556 浏览 5 评论 0原文

我正在努力将设计好的网页布局变为现实。这个设计可能有点不寻常,所以我不确定是否可以实现。基本上,我将有一个 900px 的固定宽度内容框。内容框将位于页面主体的中间。我想在页面上添加两个垂直列,其中包含淡入淡出的 png。左侧 png 将从左侧的纯黑色变为右侧的透明。右侧的 png 将从右侧的纯黑色渐变为左侧的透明。这两个 png 的宽度均为 250 像素。一旦所有内容都定位完毕,布局应该看起来像一张左右边缘褪色的纸张。然而,诀窍在于重新调整页面大小。我想确保当屏幕宽度小于 1500px 时(两列都部分位于屏幕之外),这些列不会在内容框下方滑动,而只是收缩到零。请考虑下面的图片。黑色轮廓是屏幕,蓝色是内容,红色是列。当屏幕宽度为 1500px 时,列和内容对齐得很好。幻觉(无边界)是一个褪色的图像。 ![屏幕宽度为 1500 像素时的布局][1] 当屏幕拉伸时,列会分开,但仍保留褪色的外观。 ![屏幕宽度超过 1500px 时的布局][2] 最后,当屏幕宽度小于 1500px 时,列会缩小,但每列的背景图像以不会破坏褪色外观的方式附加(例如,左列缩小并且黑色更接近内容框的左侧是不正确的)。 ![屏幕宽度小于 1500px 时的布局][3]

** 无法发布图像 :(

I am working on bringing a designed webpage layout to life. The design may be a little unusual so I am not sure whether it is possible to achieve. Basically, I will have a fixed-width content box of 900px. The content box will be positioned in the middle of the page body. I want to add two vertical columns to the page with fading pngs. The left png will face from solid black on the left to transparent on the right. The right png will fade from solid black on the right to transparent on the left. The two pngs will be 250px wide each. Once everything is positioned, the layout should look like a paper that has faded on the left and right edges. However, the trick is in re-sizing the page. I would like to make sure that when the screen is less than 1500px wide (both of the columns are partially outside of the screen), the columns do not slide under the content box but simply shrink to zero. Please, consider the images below. Black outline is the screen, blue is the content, and red are the columns. When the screen is 1500px wide, the columns and content are aligned well. The illusion (without borders) is of a fading image. ![Layout when screen is 1500px wide][1] When the screen is stretched, the columns grow apart and still the faded look is kept. ![Layout when screen is more than 1500px wide][2] Finally, when the screen is less than 1500px wide, the columns shrink but the background image of each column is attached in a way that does not break the faded look (for example, it would be incorrect for left column to shrink and black get closer to the left side of the content box). ![Layout when screen is less than 1500px wide][3]

** Could not post images :(

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

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

发布评论

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

评论(1

岁月染过的梦 2024-12-20 23:36:33

最好是 jquery 和 css3 的混合。

Jquery 将允许您将主要内容保持居中,并在两侧各有一个 div。 CSS3 允许你在两侧都有渐变,而不需要图像。唯一的缺点是,如果浏览器不兼容 CSS3,它将不会显示渐变。唯一不兼容的是 IE8 及更早版本。但有一些插件可以提供帮助(Modenizr 和 IE Chrome Tab)

Jquery

$(document).ready(function(){
 windowWidth = $(window).width();
 divWidth = (windowWidth - 900) / 2;
 $('#left_container').css({width: divWidth+"px"});
 $('#right_container').css({width: divWidth+"px"});
});

$(window).resize(function() {
 windowWidth = $(window).width();
 divWidth = (windowWidth - 900) / 2;
 $('#left_container').css({width: divWidth+"px"});
 $('#right_container').css({width: divWidth+"px"});
});

Left Div CSS

background-image: linear-gradient(90 , #FFFFFF 0%, #000000 52%);
background-image: -o-linear-gradient(90 , #FFFFFF 0%, #000000 52%);
background-image: -moz-linear-gradient(90 , #FFFFFF 0%, #000000 52%);
background-image: -webkit-linear-gradient(90 , #FFFFFF 0%, #000000 52%);
background-image: -ms-linear-gradient(90 , #FFFFFF 0%, #000000 52%);

background-image: -webkit-gradient(
 linear,
 90 90,
 right 90,
 color-stop(0, #FFFFFF),
 color-stop(0.52, #000000)
);

Right Div CSS

background-image: linear-gradient(270 , #FFFFFF 0%, #000000 52%);
background-image: -o-linear-gradient(270 , #FFFFFF 0%, #000000 52%);
background-image: -moz-linear-gradient(270 , #FFFFFF 0%, #000000 52%);
background-image: -webkit-linear-gradient(270 , #FFFFFF 0%, #000000 52%);
background-image: -ms-linear-gradient(270 , #FFFFFF 0%, #000000 52%);

background-image: -webkit-gradient(
 linear,
 270 270,
 left 270,
 color-stop(0, #FFFFFF),
 color-stop(0.52, #000000)
);

Best would to be a mix of jquery and css3.

Jquery will alow you to keep the Main content centered and have a div on both sides. While CSS3 will allow you to have a gradient on both sides with no need for images. Only down side is that if the browser is not CSS3 compliant it will not show the gradient. Only one that is not compliant is IE8 and earlier. But there are addons that will help (Modenizr and IE Chrome Tab)

Jquery

$(document).ready(function(){
 windowWidth = $(window).width();
 divWidth = (windowWidth - 900) / 2;
 $('#left_container').css({width: divWidth+"px"});
 $('#right_container').css({width: divWidth+"px"});
});

$(window).resize(function() {
 windowWidth = $(window).width();
 divWidth = (windowWidth - 900) / 2;
 $('#left_container').css({width: divWidth+"px"});
 $('#right_container').css({width: divWidth+"px"});
});

Left Div CSS

background-image: linear-gradient(90 , #FFFFFF 0%, #000000 52%);
background-image: -o-linear-gradient(90 , #FFFFFF 0%, #000000 52%);
background-image: -moz-linear-gradient(90 , #FFFFFF 0%, #000000 52%);
background-image: -webkit-linear-gradient(90 , #FFFFFF 0%, #000000 52%);
background-image: -ms-linear-gradient(90 , #FFFFFF 0%, #000000 52%);

background-image: -webkit-gradient(
 linear,
 90 90,
 right 90,
 color-stop(0, #FFFFFF),
 color-stop(0.52, #000000)
);

Right Div CSS

background-image: linear-gradient(270 , #FFFFFF 0%, #000000 52%);
background-image: -o-linear-gradient(270 , #FFFFFF 0%, #000000 52%);
background-image: -moz-linear-gradient(270 , #FFFFFF 0%, #000000 52%);
background-image: -webkit-linear-gradient(270 , #FFFFFF 0%, #000000 52%);
background-image: -ms-linear-gradient(270 , #FFFFFF 0%, #000000 52%);

background-image: -webkit-gradient(
 linear,
 270 270,
 left 270,
 color-stop(0, #FFFFFF),
 color-stop(0.52, #000000)
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文