Text and background-color overlay on image

ぐ巨炮叔叔 提交于 2019-12-04 06:41:35

I made an example for you. http://jsfiddle.net/kb3Kf/2/

The main thing that was missing was that you gave the text an Absolute position but didn't give the wrapper a Relative one, like so:

.img-overlay
{
    position: relative;
}

It's really simple, you can take it to many directions. Tell me if that's what you wanted.

You are just missing setting the position of the parent img-overlay element. When something has a position of "absolute", that refers to where it is in relation to its parent. The parent needs to have positioning.

.img-overlay {
    position: relative;
    width: 300px;

}

.img-overlay img {
width:100%;
}

.overlay {
  position: absolute;
  width:100%;
  height: 100%;
  top:0px;
  left:0px;
  background-color: rgba(255,255,255,0.5);

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!