circular spotlight - Free Download Circular Spotlight In jQuery And CSS3

Free Download Circular Spotlight In jQuery And CSS3

Posted on

This time I will share jQuery Plugin and tutorial about Circular Spotlight In jQuery And CSS3, hope it will help you in programming stack.

circular spotlight - Free Download Circular Spotlight In jQuery And CSS3
File Size: 5.47 KB
Views Total: 309
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A circular spotlight effect that always follows the cursor on mouse movement. Can be used to highlight critical elements and new features on the webpage.

Built using CSS background: radial-gradient property. jQuery is used to make the cursor always stay within the center of the spotlight.

How to use it:

1. Create a container for the circular spotlight.

1 <div class="spotlight"></div>

2. Transform the DIV container into a circular spotlight.

01 .spotlight {
02   position: fixed;
03   top: 0;
04   left: 0;
05   width: 100%;
06   height: 100%;
07   pointer-events: none;
08   background: radial-gradient(50px 50px at center center, transparent, transparent 100px, rgba(0, 0, 0, 0.6) 150px);
09   opacity: 0;
10   animation: fadein 2s 1s 1 both;
11 }
12  
13 @keyframes fadein {
14   0% {
15     opacity: 0;
16   }
17   100% {
18     opacity: 1;
19   }
20 }

3. Include the necessary jQuery library on the page.

1 <script src="/path/to/cdn/jquery.slim.min.js"></script>

4. Make the spotlight follow your cursor on mouse movement.

1 $(function(){
2   $('.spotlight').attr({ 
3     'style':'background:radial-gradient(50px 50px at '+ e.clientX +'px '+ e.clientY +'px, transparent, transparent 100px, rgba(0,0,0,0.6) 150px)'
4   });
5 });

This awesome jQuery plugin is developed by KazuyoshiGoto. For more Advanced Usages, please check the demo page or visit the official website.