简体   繁体   English

CSS或背景和菜单箭头的图像?

[英]CSS or image for background and menu arrows?

Is is better to use CSS or image for these two cases: 对于这两种情况,最好使用CSS或图像:
1) Need a gradient like shading of purple on my homepage (color fades from dark purple to light purple) 1)需要一个渐变,例如主页上的紫色底纹(颜色从深紫色逐渐变为浅紫色)
2) All the menus on my site have an arrow "More " and when opened it changes to "Less " 2)我网站上的所有菜单都有一个箭头“更多”,当打开时,它变为“减少”

Currently my design team has made the homepage as CSS and the arrows as images. 目前,我的设计团队已将首页设为CSS,将箭头设为图片。 But I cant see any advantage or disadvantage of one over the other or what is best practice to use? 但是我看不到任何一个相对于另一个的优点或缺点,或者什么是最佳实践?

Depends on what browsers you want to support. 取决于您要支持的浏览器。

1) If it needs to be cross-browser compatible across a wide range of browsers, go for an image. 1)如果需要跨各种浏览器跨浏览器兼容,请获取图像。

2) I would stick with images for the arrows. 2)我会坚持使用箭头图像。 They can be made with CSS using border trickery, or canvas, but I don't think it's worth the hassle. 可以使用CSS通过边框骗术或画布来制作它们,但我认为这不值得麻烦。

I recommend the use of images. 我建议使用图像。 They are supported over all browsers and old versions. 所有浏览器和旧版本均支持它们。 You can further apply CSS styling to the images, if needed. 如果需要,您可以进一步将CSS样式应用于图像。

Using CSS to create icons and gradients is difficult and isn't supported across all browsers (especially IE). 使用CSS创建图标和渐变非常困难,而且并非所有浏览器(尤其是IE)都支持使用CSS。

Extra request for multiple images (that cache) > using CSS tricks that aren't cross browser 额外请求多个图像(缓存)>使用非跨浏览器的CSS技巧

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM