HtmlNinja-用img标签还是background-image?
2010-11-29 16:45
253 查看
以下内容为Stackoverflow上整理的,仅供参考
PRO 用IMG标签
UseIMGplus alt attribute if the image is part of the content such as a logo or diagram or person (real person, not stock photo people). —sanchothefat
如果图片是内容的重要部分例如logo,人员信息的头像等,用img标签,别忘了alt属性
Use
IMGif you intend to have people print your page and you want the image to be included by default. —JayTee
如果你想别人打印你的页面时连图片一起打印,那末用img
Use
IMG(with
alttext) when the image has an important semantic meaning, such as a warning icon. This ensures that the meaning of the image can be communicated in all user-agents, including screen readers.
如果图片有很重要的语义,例如表示警告的图标,为了保证被别的客户端设备例如屏幕阅读器所识别,那末使用IMG标签,别忘了alt属性
Use
IMGif you rely on browser scaling to render an image in proportion to text size.
当用户改变文本尺寸比例时(通过浏览器如ctr+),使用IMG标签可以使图片正常按比例缩放
Use
IMGfor multiple overlay images in IE6.
IE6下面多张图片交叠效果需要用IMG标签(具体用处不明)
Use
IMGwith a
z-indexin order to stretch a background image to fill its entire window.
使用img标签以及z-index可以撑开整个窗口的背景图。(具体不知道啥意思)
Using
imginstead of
background-imagecan dramatically improve performance of animations over a background.
针对图片进行动画交互时使用img标签可显著提升性能
CON 用背景图
Use CSS background images if the image is not part of the content. —sanchothefat图片不是内容的主体组成部分时,考虑用背景图
Use CSS background images when doing image-replacement of text eg. paragraphs/headers. —sanchothefat
需要使用图片替代文字的时候考虑用背景图,比如标题内容、段落内容,有时候需要用更有质感的图片替代部分内容
Use
background-imageif you intend to have people print your page and you do not want the image to be included by default. —JayTee
别人打印你的网页,你不想让他打印到图片时考虑用背景图
Use
background-imageif you need to improve download times, as with CSS sprites.
合图即css sprite可减少服务器请求次数,用背景图
Use
background-imageif you need for only a portion of the image to be visible, as with CSS sprites.
用背景图可以利用css的background-position控制图片的可见范围
相关文章推荐
- 何时使用img标签,何时使用background-image背景图像
- 何时使用img标签,何时使用background-image背景图像
- 该如何选择 background-image 和 img 标签
- div+background-image和img标签的选择
- 何时使用img标签,何时使用background-image背景图像
- Html学习笔记---background-image及img导入图片比较
- 何时使用img标签,何时使用background-image背景图像
- html中img标签显示图片属性写法与background差异
- 何时使用img标签,何时使用background-image背景图像
- 前端HTML<img>标签图像的属性和使用/图像img与背景background的区别
- img标签src=""和background-image:url();引发两次请求页面bug
- 简单的将一个html(xml)文本中的img标签(图片)提取出来的方法
- 解析字符串中所有的html中img标签的url
- 在html <table> 标签的中background和bgcolor两个属性有什么关系?
- 正则表达式提取HTML中IMG标签的SRC地址
- HTML <img> 标签
- HTMLimg标签的alt属性和title属性使用介绍
- HTML 修改img标签的src属性
- HTML img标签align属性
- C#正则表达式提取HTML中IMG标签的SRC地址