简体   繁体   English

跨浏览器图像

[英]Cross-Browser Images

So I have decided to use images for the text in my navbar links so I can use the font I want and not worry about cross-browser rendering issues. 因此,我决定在导航栏链接中为文本使用图像,以便可以使用所需的字体,而不必担心跨浏览器渲染问题。 But I have run into another cross-browser issue. 但是我遇到了另一个跨浏览器问题。 Due to internet explorer's image resizing issues, I need to export the images from photoshop at the same height and width as they will be displayed. 由于Internet Explorer的图像大小调整问题,我需要从photoshop中以与显示时相同的高度和宽度导出图像。 But now there is a white, pixelated border around my images in certain spots(see image). 但是现在在某些位置我的图像周围有一个白色的像素化边框(参见图像)。 My shopping cart icon is also being affected. 我的购物车图标也受到了影响。 screenshot of my navbar 我的导航栏的屏幕截图

Using images instead of text because you want to avoid cross-browser issues is not a good approach. 因为要避免跨浏览器问题,所以使用图像而不是文本不是一个好方法。 You should use the css @font-face rule 您应该使用css @ font-face规则

`@font-face{
font-family: 'pick your font';
src: url("your_font.otf");}`

You'll need to download the .otf and the .eot files of the font you want and upload them to the site (different browsers support different sets of font formats). 您需要下载所需字体的.otf和.eot文件,然后将它们上传到站点(不同的浏览器支持不同的字体格式集)。 Then you can reference them like this: 然后,您可以像这样引用它们:

@font-face{
 font-family: 'your_font';
 src: url('your_font.eot?#iefix') format('embedded-opentype'),
       url('your_font.woff') format('woff'),
       url('your_font.ttf') format('truetype')
       ;}

Font squirrel is a good source to get free font files (in all formats) 字体松鼠是获取免费字体文件(所有格式)的好来源

Also those white lines are appearing because the images were not sharp enough when you coloured them. 还会出现这些白线,因为在对它们上色时图像不够清晰。 That usually happens when you try and resize an small image and change its color. 当您尝试调整小图像的大小并更改其颜色时,通常会发生这种情况。

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

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