JSFiddle - React, Tailwind, and code Playground
by Deepak Sharma
HTML
<ul>
<li><input type="checkbox" id="cb1" />
<label for="cb1">
<img src="https://dummyimage.com/120/000000/ffffff" />
<div class='details'>
<img src="https://www.gravatar.com/avatar/5ec91fffa24a3d04d6a3d498cb9e1b90?s=64" />
</div>
</label>
</li>
<li><input type="checkbox" id="cb2" />
<label for="cb2">
<img src="https://dummyimage.com/120/000000/ffffff" />
<div class='details'>
image 1 details
</div>
</label>
</li>
</ul>
this is another text;
CSS
ul {
list-style-type: none;
}
li {
display: inline-block;
}
input[type="checkbox"][id^="cb"] {
display: none;
}
label {
display: block;
position: relative;
cursor: pointer;
width: 100%;
height: 100%;
}
label:before {
background-color: red;
color: white;
display: block;
border: 1px solid red;
position: absolute;
width: 20px;
height: 20px;
text-align: center;
line-height: 20px;
transition-duration: 0.4s;
}
label > img {
height: 100%;
width: 100%;
}
label img + .details
{
color:white;
position:absolute;
top:0px;
width:100%;
display:none;
margin-top:50%;
transform: translatey(-50%);
text-align:center;
}
:checked + label {
border-color: red;
}
:checked + label:before {
content: "✓";
background-color: red;
outline: 1px solid red;
z-index: 99;
}
:checked + label > img {
z-index: -1;
outline: 1px solid red;
}
:checked + label img + .details
{
display:block;
}