1 2 3 4 5 6 | <span class="magik-responsive-image" id="image-01"> <img src="http://dummyimage.com/200x150/cdcdcd/000/?text=lo-res" alt="TODO"> <style scoped> @media screen and (min-width: 701px){#image-01{background-image:url(http://dummyimage.com/1600x1200/dcdcdc/000/?text=hi-res);}} </style> </span> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | .magik-responsive-image { background-repeat: no-repeat; background-size: 100%; display: block; position: relative; } .magik-responsive-image img { max-width: 100%; } @media screen and (min-width: 701px) { .magik-responsive-image img{ opacity: 0; } } |
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |