How to Create Floating Box Effect using HTML and CSS ? Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The floating box effect is a classical example of a custom box-shadow technique. In this technique, we create realistic-looking shadows without using the box-shadow property that is provided by the CSS. Approach: The approach is to use after selector to use create shadow using the blur function. HTML Code: In this section, we have created the basic structure of the body. Here, we have used a <div> tag containing class attribute to render the floating box on the screen. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Floating Box</title> </head> <body> <h1>GeeksForGeeks</h1> <div class="geeks"></div> </body> </html> CSS Code: In this section, we have used some CSS property to design floating box and assign some styles on them. The following steps describe the CSS properties: Step 1: First we have done some basic styling like providing a background, creating a box, and aligning everything to the center of the page.Step 2: Now, use the after selector to create a thin line below the box that we have created and then use blur function to give it the shadow effect. Tip: Try use a darker color and a low value for blur function for shadow. If not, you might end up making your shadow transparent. CSS <style> body { background: green; } h1 { display: flex; justify-content: center; color: white; font-size: 40px; } .geeks { width: 400px; height: 250px; background: white; position: absolute; top: 16%; left: 35%; border-radius: 20px; } .geeks::after { content: ""; position: absolute; bottom: -30px; background: rgb(43, 42, 42); width: 90%; height: 4px; left: 3%; border-radius: 50%; filter: blur(3px); } </style> Complete Code: It is the combination of the above two codes. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width,initial-scale=1.0"> <title>Floating Box</title> <style> body { background: green; } h1 { display:flex; justify-content: center; color: white; font-size: 40px; } .geeks { width:400px; height:250px; background: white; position: absolute; top:16%; left:35%; border-radius: 20px; } .geeks::after { content: ""; position: absolute; bottom: -30px; background: rgb(43, 42, 42); width: 90%; height:4px; left:3%; border-radius:50%; filter: blur(3px); } </style> </head> <body> <h1>GeeksForGeeks</h1> <div class="geeks"></div> </body> </html> Output: Comment More infoAdvertise with us Next Article How to create Image Folding Effect using HTML and CSS? S sirohimukul1999 Follow Improve Article Tags : Web Technologies Web Templates Similar Reads How to create Image Folding Effect using HTML and CSS? In this article, we are going to create an image folding effect below the main image. This is a simple project, we can achieve our target only by using HTML and CSS. Approach: Create the main div in which we are creating 4 list tags.Use of nth-child() selector property to give different styles to di 2 min read How to Create Liquid Filling Effect on Text using HTML and CSS ? The liquid fill text animation can be done using CSS | ::before selector. We will use key frames to set height for each frame of animation. Please make sure you know about both CSS | ::before selector and CSS | @keyframes Rule before try this code.The basic styling of the text can be done differentl 3 min read How to Create Shock Wave or Explosion Effect using HTML and CSS? The shock wave effect is also known as the explosion effect. It is one of the simple CSS effects. For a beginner, it is one of the best examples to learn the concept of pseudo-elements. The pseudo-element that we are using is hover. First, try to create from own before jumping into the code to under 3 min read How to create paper corner fold effect on hover by using HTML and CSS? The folding effect is quite attractive on the website, may you have seen on some websites when you hover on the paging layout it gets folded on the corner. The folding corner effect can be achieved by using HTML and CSS only. The below sections will guide you on how to create the animation. In this 3 min read How to create a Spotlight Effect using HTML and CSS ? In this article, we are going to create a spotlight effect over the image when we hover over it. This is mainly based on HTML, CSS and JavaScript. The below steps have to be followed to create this effect.HTML Section: In this section, we will create a container elements for the background image and 4 min read How to create Neumorphism Effect using HTML and CSS ? Neumorphism (neomorphism) is a modern way of styling web-elements of any web-page and providing a 3D effect. This animation effect can be easily generated by using HTML and CSS. Box-shadow property of CSS can be used to implemented Neumorphism. It is used to add a dark shadow to one side and a light 2 min read Like