CSS frosted glass effect
CSS only frosted glass effect
by Wayne Humphrey
May 18, 2018
HTML
<!--
Thanks to:
https://medium.com/@AmJustSam/how-to-do-css-only-frosted-glass-effect-e2666bafab91
-->
<div class="blurred-box">
<!-- you dont need the user-login-box html -->
<!-- for demo purposes only and its shit -->
<div class="user-login-box">
<span class="user-icon"></span>
<div class="user-name">Gilfoyle</div>
<input class="user-password" type="text" />
</div>
</div>
CSS
/*
Thanks to: Usama Tahir
https://medium.com/@AmJustSam
*/
*{
margin: 0;
padding: 0;
}
html{
width: 100vw;
height: 100vh;
}
/* CSS which you need for blurred box */
body{
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-position: top;
background-image:url(http://bit.ly/2gPLxZ4);
width: 100%;
height: 100%;
font-family: Arial, Helvetica;
letter-spacing: 0.02em;
font-weight: 400;
-webkit-font-smoothing: antialiased;
}
.blurred-box{
position: relative;
width: 250px;
height: 350px;
top: calc(50% - 175px);
left: calc(50% - 125px);
background: inherit;
border-radius: 2px;
overflow: hidden;
}
.blurred-box:after{
content: '';
width: 300px;
height: 300px;
background: inherit;
position: absolute;
left: -25px;
left position
right: 0;
top: -25px;
top position
bottom: 0;
box-shadow: inset 0 0 0 200px rgba(255,255,255,0.05);
filter: blur(10px);
}
/* Form which you dont need */
.user-login-box{
position: relative;
margin-top: 50px;
text-align: center;
z-index: 1;
}
.user-login-box > *{
display: inline-block;
width: 200px;
}
.user-icon{
width: 100px;
height: 100px;
position: relative;
border-radius: 50%;
background-size: contain;
background-image: url(https://pbs.twimg.com/profile_images/725321660484583424/ArQ4fM3k.jpg);
}
.user-name{
margin-top: 15px;
margin-bottom: 15px;
color: white;
}
input.user-password{
width: 120px;
height: 18px;
opacity: 0.4;
border-radius: 2px;
padding: 5px 15px;
border: 0;
}