Home  >  Article  >  Web Front-end  >  css奇特用法之 IMG添加背景图片配合显示效果惊艳_html/css_WEB-ITnose

css奇特用法之 IMG添加背景图片配合显示效果惊艳_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:42:401471browse

  • IMG标签本身是显示图片的,但通过CSS可以再为其设置背景图片,让其和自身的图片配合来显示,最终的效果会让你惊叹。当然,这个发现来自于老外,所以代码马上与大家分享。再此之前,我也从来没有想到过这个思路,我想这种思路可以应用的地方相当多了。
  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><title>CSS奇特用法:为IMG设置背景图片</title><style type="text/css">div {background: url('http://www.codefans.net//jscss/demoimg/201312/blur.jpg') no-repeat top left;width:232px;height: 200px; }img {display:block;background: url('http://www.codefans.net//jscss/demoimg/201312/parallax.gif') no-repeat bottom left;padding: 93px 100px 75px 100px;}</style></head><body><div><img src="http://www.codefans.net//jscss/demoimg/201312/Anime_runner.gif" alt="runner" /></div></body></html>

     

     

    ----转载

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn