7-2 无固定width/height容器内的绝对定位元素拉伸
本节编程练习不计算学习进度,请电脑登录imooc.com操作

无固定width/height容器内的绝对定位元素拉伸

无固定width/height容器内的绝对定位元素拉伸

任务

老师视频里的不同布局写法,不是习题!!不是习题!!!

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>无固定width/height容器内的绝对定位元素拉伸</title>
  6. <style>
  7. body {
  8. background-color: #ddd;
  9. }
  10. img {
  11. vertical-align: bottom;
  12. }
  13. .container {
  14. display: inline-block;
  15. position: relative;
  16. }
  17. .cover {
  18. position: absolute;
  19. left: 0; top: 0; right: 0; bottom: 0;
  20. background-color: #fff;
  21. opacity: .5; filter: alpha(opacity=50);
  22. }
  23. </style>
  24. </head>
  25.  
  26. <body>
  27. <span class="container">
  28. <i class="cover"></i>
  29. <img src="http://img1.sycdn.imooc.com//547c34cf000171a002560191.jpg" width="512" height="381">
  30. </span>
  31. <span class="container">
  32. <i class="cover"></i>
  33. <img src="http://img1.sycdn.imooc.com//547c34c9000171a002560191.jpg" width="256" height="191">
  34. </span>
  35. </body>
  36. </html>
下一节