css > divごとリンクボタンにする

html
  1. <div class="box">
  2. <a href="#">LINK</a>
  3. <img src="hoge.jpg" width="100" height="100" />
  4. <p>○○○○○○○○○○</p>
  5. </div>
  6.  

css
  1. div.box {
  2. position: relative;
  3. margin:0;
  4. }
  5. div.box:hover {
  6. text-decoration: underline;
  7. }
  8. a {
  9. display: block ;
  10. position: absolute;
  11. left: 0;
  12. top: 0;
  13. width: 100%;
  14. height: 100%;
  15. text-indent:-999px;
  16. background/*\**/: #fff\9; /*IE7、8用ハック 背景色をつけて、*/
  17. filter:alpha(opacity=0); /*IE7、8用ハック フィルターで透明に*/
  18. }
  19. a:hover {
  20. background-color: #ffffff;
  21. opacity:0.3;
  22. }
  23.  


a要素をブロック要素に変え、
width:100%;とheight:100%;と指定して、
親要素div.boxの上に絶対配置






最終更新:2013年02月06日 17:01