我们如何在 css xhtml 代码中实现 PSD 的对角渐变?
首先,我想告诉大家,我不是设计师,也不是 css/xhtml 编码员。我正在向我的一位朋友问这个问题,他正在一个具有对角梯度的网站上工作(这基本上意味着梯度在 X 和 Y 方向上),所以他在切片图像时遇到了问题这样他就可以在背景中填充切片图像,从而保持 X 和 Y 两个方向上的梯度。
所以,就像,如果梯度仅在 X 方向,那么我们通常会切片垂直 1px 宽度的图像。类似地,如果梯度仅在 Y 方向,那么我们通常会切片水平 1px 高度的图像。 但是如果梯度同时在 X 和 Y 方向上怎么办?在这种情况下,我们将如何对图像进行切片,或者我们如何在 CSS/XHTML 中实现它?
非常感谢
Pukhraj
First of all, I want to tell you guys that I'm not a designer and not a css/xhtml coder as well. I'm asking this question for one of my friend, He is working on a site which has diagonal gradient (it basically means that the gradient is in both of the direction X and Y), So he is getting problem in slicing the image for it so that he can fill the sliced image in background in such a way which will maintain the gradient in X and Y both direction.
So, It is like, If gradient is in X direction only than we generally slice a vertical 1px width image. Similarly, If gradient is in Y direction only then we generally slice a horizontal 1px height image. But What if the gradient is in both of the direction X and Y? In this case how will we slice the image or how could we implement it in CSS/XHTML?
Thanks A lot
Pukhraj
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的朋友应该考虑使用 CSS 来做到这一点,只要他/她同意它只在现代的非 IE 浏览器中工作。
示例: http://jsfiddle.net/h9rpE/2/
或者您可以使用背景大小:
示例: http://jsfiddle.net/rLttj/2/
Your friend should consider doing this with CSS, as long as he/she is okay with it working only in modern, non-IE browsers.
Example: http://jsfiddle.net/h9rpE/2/
Or you could use background-size:
Example: http://jsfiddle.net/rLttj/2/
简单的。根本不要拼接它。您可以简单地将背景图像作为一个整体,并在
body
标记中使用 CSS 的background
指令。我看到你遇到的唯一问题是渐变图像的宽度。如果(例如)宽度为 1024 像素,并且客户端摇摆为 1920 像素,他们会看到很多白色。如果不知道您的显示器受众群体是谁以及您的布局,则有点难以回答。Simple. Don't splice it at all. You could simply take the background image as a whole and use CSS'
background
directive in yourbody
tag. Only issue I could see you running into is the width of your gradient image. If it's (for example) 1024px wide and the client is rocking 1920px they'll see a lot of white. It's a little hard to answer without knowing who your monitor demographic is and your layout.