1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【メモ】hoverで画像の上に文字

Last updated at Posted at 2020-08-22

検索した1番目に持ってた記事で動かず、
2番目のものもうまくいかなかったので
今後自分がまた使えるように軽まとめ。

--- HTML ---

<div class="hover-effect">
 <img src="images/four.png">
 <div class="mask">
   <p class="caption">文字</p>
 </div>
</div>

--- CSS ---

.hover-effect {
 overflow: hidden;
 position: relative;
}
.hover-effect .caption {
 text-align: left;
 padding: 10px;
  color: #fff;
  font-size: .85em;
  display: table-cell;
  vertical-align: middle;
}
.hover-effect .mask {
 width: 100%;
 height: 100%;
 position: absolute;
 top: 0;
 left: 0;
 opacity: 0;
 background-color: rgba(0, 0, 0, 0.728);
  display: table;
}
.hover-effect:hover .mask {
 opacity: 1;
}

maskをhoverで表示させる感じ。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?