How To Create Glass Effect In HTML And CSS | Glassmorphism | letsbug
Today in this article we are trying something that we have not done in a while that is we are creating a glass like effect in html and css or creating a card in css with glassmorphism. This is going to be a very simple project but we can use this effect in our many different project as per our needs.
So to get started we just need a code editor and a browser to view it and nothing more. But you should know a little bit of HTML and CSS to get started. So here are the steps.
Glassmorphism Preview
Step one : Setup a HTML document
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Glass Effect</title>
</head><body> </body></html>
Step Two : Add HTML elements
<section> <h1>Glass Effect</h1> <article> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure, praesentium. Rem fugiat numquam nihil, saepe minus sequi aperiam? Corrupti, fugiat.</p> </article></section>
Step Three : Add Glassmorphism Stylings
<style> body { background-image:url('https:source.unsplash.com/random/400x400/?beach'); background-size: cover; background-repeat: no-repeat; box-sizing: border-box; font-family: 'Open Sans', sans-serif; font-size: 14px; line-height: 1.42857143; color: #333; height:80vh; display: grid; place-items: center; } section{ background: inherit; width:70%; color:white; padding:1rem; border-radius: .3rem; filter: drop-shadow(0 0 .5rem rgba(0,0,0,.5)); border:none; position:relative; z-index: 1; } section::after{ content:''; position:absolute; top:0; left:0; width:100%; height:100%; border-radius: .3rem; z-index:-1; filter: blur(5px); background: inherit;
} section h1{ font-size: 1.5rem; font-weight: lighter; color:white; } section article{ color:white; letter-spacing: 1px; }
</style>
As you saw creating a Glassmorphism effect is very easy. But let me clear one thing the styling that you see in the styles tag. All of that is not required to make this glass effect but i have use them to make is more beautiful. Main styling is in the section tag and section tags after pseudo element.
Thankyou, ☺
Comments
Post a Comment