<p>Hover over the box</p>
<div class=foo>
<h1>Bactrian Camel</h1>
<p>The Bactrian camel is the largest mammal in its native range and is the largest living camel.</p>
</div>
@import url('https://fonts.googleapis.com/css?family=Cormorant+Garamond');
.foo {
--bgc: #FFCC03;
--dim: 300px;
width: var(--dim);
height: var(--dim);
background-color: var(--bgc);
position: relative;
/* for decor */
display: table-cell;
vertical-align: middle;
}
.foo::before,
.foo::after {
content: '';
position: absolute;
left: 0;
top: 0;
}
.foo, .foo:hover, .foo::before, .foo::after,
.foo:hover::before, .foo:hover::after {
transition: transform 500ms ease-in ;
}
.foo::before {
width: 100%;
height: 100%;
background: url("https://upload.wikimedia.org/wikipedia/commons/6/63/Camel_%28PSF%29-transparent.png") center/cover;
z-index: -1;
}
.foo::after {
--b: 20px;
width: calc(100% - var(--b));
height: calc(100% - calc(var(--b) * 2));
border: var(--b) solid transparent;
border-left: none;
box-shadow: inset 0 var(--dim) 0 var(--bgc);
filter: brightness(.8);
z-index: -2;
}
.foo:hover::before,
.foo:hover::after {
transform: translateX(100%);
}
/* for decor */
html {
font-size: 16pt;
font-family: 'Cormorant Garamond', serif;
}
.foo h1 {
text-align: center;
font-size: 1.3rem;
font-variant: small-caps;
}
.foo p {
margin: auto;
width: 80%;
text-align: center;
}
@media (max-width: 619px) {
.foo {
--dim: 150px;
}
.foo p {
display: none;
}
html {
font-size: 12pt;
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.