Css transparent form above image

This is what I'm trying to achieve.

I have:

    #image1 {
    position: absolute;
    bottom: 0px;
    align-self: auto;
    background-color: #dc022e;
    width: 340px;
    height: 100px;
    border-radius: 50% / 100%;
    border-bottom-left-radius: 0;
    /*transform: rotate(10deg);*/
    border-bottom-right-radius: 0;
    opacity: 0.8;
    }
    
    #image2 img {
    width: 80%;
    }
<div>
  <div id="image2">
    <img src="http://t1.gstatic.com/images?q=tbn:ANd9GcThtVuIQ7CBYssbdwtzZjVLI_uw09SeLmyrxaRQEngnQAked5ZB">
  </div>
  <div id="image1"></div>
</div>
Run codeHide result

Finally, I do not know how to make it rotate and with the fields, as in the picture

+6
source share
3 answers

A quick example of this would be to use a pseudo-element and set the image in the background.

div {
  position: relative;
  height: 300px;
  width: 500px;
  background: url(http://lorempixel.com/500/300);/*image path*/
  overflow: hidden;/*hides the rest of the circle*/
}

div:before {
  content: "";
  position: absolute; /*positions with reference to div*/
  top: 100%;
  left: 50%;
  width: 0;/*define value if you didn't want hover*/
  height: 0;
  border-radius: 50%;
  background: tomato;/*could be rgba value (you can remove opacity then)*/
  opacity: 0.5;
  transform: translate(-50%, -50%);/*ensures it is in center of image*/
  transition: all 0.4s;
}


/*Demo Only*/
div:hover:before {/*place this in your pseudo declaration to remove the hover*/
  height: 100%;
  width: 150%;/*this makes the shape wider than square*/
  transform: translate(-50%, -50%) rotate(5deg);/*ensures it is in center of image + rotates*/
}
div {/*This stuff is for the text*/
  font-size: 40px;
  line-height: 300px;
  text-align: center;
}
<div>HOVER ME</div>
Run codeHide result
+3
source

Instead of nested elements, you can simply use a pseudo-element. This is located at the bottom of the div container. To do this you need to position:relative, and overflow:hiddenin the container div. In addition, pseudo-elements always need to be declared content.

, left | width | height . .

"" rgba(r,g,b,a), a - .

passepartout border.

#image2{
    position:relative;
    border:10px solid #888;
    overflow:hidden;
    box-shadow:0 0 4px #aaa;
}

#image2::after {
    content:"";
    display:block;
    position: absolute;
    bottom: 0;left:-10%;
    background-color: #dc022e;
    width: 120%;
    height: 60%;
    border-radius: 100% 100% 0 0;
    opacity: 0.8;
}
    
#image2 img {
    width: 100%;
    display:block;
    position:relative;
}
<div id="image2">
    <img src="http://t1.gstatic.com/images?q=tbn:ANd9GcThtVuIQ7CBYssbdwtzZjVLI_uw09SeLmyrxaRQEngnQAked5ZB">
  </div>
Hide result
+3

position: absolute position: relative , . Fiddle. , !

: , img. CBroe, , , . , , - , .

+1
source

Source: https://habr.com/ru/post/1015760/


All Articles