Floating Div Over An Image

前端 未结 5 907
耶瑟儿~
耶瑟儿~ 2020-12-04 13:06

I\'m having trouble floating a div over an image. Here is what I am trying to accomplish:

5条回答
  •  有刺的猬
    2020-12-04 13:32

    Never fails, once I post the question to SO, I get some enlightening "aha" moment and figure it out. The solution:

        .container {
           border: 1px solid #DDDDDD;
           width: 200px;
           height: 200px;
           position: relative;
        }
        .tag {
           float: left;
           position: absolute;
           left: 0px;
           top: 0px;
           z-index: 1000;
           background-color: #92AD40;
           padding: 5px;
           color: #FFFFFF;
           font-weight: bold;
        }
    Featured

    The key is the container has to be positioned relative and the tag positioned absolute.

提交回复
热议问题