Content Box Hover Effects | Css Border Animation On Hover

HTML
<div class="box">
    <span></span>
    <span></span>
    <span></span>
    <span></span>
    <div class="content">
        <h2>Box Hover Effects</h2>
        <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
        	tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
        	quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
        	consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
        	cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
        	proident.
        </p>
    </div>
</div>
CSS
body
{
    margin:0;
    padding:0;
    display:flex;
    justify-content:center;
    align-items:center;
    height:100vh;
    background:#000;
    font-family:sans-serif;
}
.box
{
    position:relative;
    width:340px;
    height:340px;
}
.box .content
{
    position:absolute;
    top:10px;
    left:10px;
    right:10px;
    bottom:10px;
    background:#000;
    padding:20px;
    overflow:hidden;
    text-align:center;
    border:2px solid #fff;
}
.box .content:before
{
    content:'';
    position:absolute;
    top:0;
    left:-100%;
    width:100%;
    height:100%;
    background:rgba(255,255,255,.1);
    transition:0.5s;
    pointer-events:none;
}
.box:hover .content:before
{
    left:-50%;
}
.box .content h2
{
    margin:0 0 12px;
    padding:0;
    color:#fff;
}
.box .content p
{
    margin:0;
    padding:0;
    color:#fff;   
}
.box span
{
    position:absolute;
    top:0;
    left:0;
    width:100%;
    height:100%;
    display:block;
    pointer-events:none;
}
.box span:before
{
    content:'';
    position:absolute;
    width:100%;
    height:2px;
    background:#0f0;
    transform-origin:left;
    transition:0.5s;
}
.box:hover span:before
{
    transform: scaleX(0);    
}
.box span:nth-child(even):before
{
    transform-origin:right;
    transition-delay:0.5s;
}

.box span:nth-child(1)
{
    transform:rotate(0deg);
}
.box span:nth-child(2)
{
    transform:rotate(90deg);
}
.box span:nth-child(3)
{
    transform:rotate(180deg);
}
.box span:nth-child(4)
{
    transform:rotate(270deg);
}

/*
    All the credits: https://www.youtube.com/watch?v=FsCYoDfsTSc
*/

Autor: Leonard

Publicado: 18/07/2022

Compartir Elemento Web

Donar a Compositu
Otras formas de ayudar
  • Compártelo en tus redes sociales.
  • Recomienda los elementos.
  • Regístrate Aquí
  • Deja tu comentario agradeciendo el aporte.

Descarga el código completo del Elemento Web y archivos necesarios (imágenes, librerias, plugins, frameword, etc)

Deja tu comentario