1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+
4+ < head >
5+ < title > Code With Hossein</ title >
6+
7+ <!-- Montserrat Font -->
8+ < link href ="https://fonts.googleapis.com/css2?family=Montserrat&display=swap " rel ="stylesheet ">
9+
10+ < style >
11+ * {
12+ margin : 0 ;
13+ padding : 0 ;
14+ }
15+
16+ body {
17+ height : 100vh ;
18+ display : flex;
19+ align-items : center;
20+ justify-content : center;
21+ background : # 151320 ;
22+ }
23+
24+ /* Box container */
25+ .box {
26+ position : relative;
27+ width : 400px ;
28+ height : 400px ;
29+ color : # fff ;
30+ background : # 151320 ;
31+ font : 700 2rem 'Montserrat' ;
32+ line-height : 400px ;
33+ text-align : center;
34+ text-transform : uppercase;
35+ border-radius : 50% ;
36+ /* Makes the box circular */
37+ z-index : 1 ;
38+ /* Ensures the box is above the frame */
39+ transition : transform 0.3s ease;
40+ /* Add transition for smooth hover effect */
41+ transform-style : preserve-3d;
42+ /* For 3D effect */
43+ will-change : transform;
44+ /* Optimizes the transformation */
45+ }
46+
47+ /* 3D effect on hover */
48+ .box : hover {
49+ transform : rotateY (15deg ) rotateX (15deg );
50+ /* Slight 3D tilt on hover */
51+ }
52+
53+ /* Moving part of the white border with purple glow */
54+ .box ::before ,
55+ .box ::after {
56+ content : '' ;
57+ z-index : -1 ;
58+ position : absolute;
59+ width : calc (100% + 30px );
60+ height : calc (100% + 30px );
61+ top : -15px ;
62+ left : -15px ;
63+ border-radius : 50% ;
64+ /* Matches the circular shape of the box */
65+ background : linear-gradient (45deg , rgba (255 , 255 , 255 , 1 ) 20% , rgba (255 , 255 , 255 , 0 ) 30% , rgba (255 , 255 , 255 , 0 ) 70% , rgba (255 , 255 , 255 , 1 ) 80% );
66+ background-size : 300% ;
67+ animation : borderMove 4s linear infinite;
68+ box-shadow : 0 0 30px 20px rgba (128 , 0 , 255 , 0.8 );
69+ /* Purple glow effect */
70+ }
71+
72+ .box ::after {
73+ filter : blur (50px );
74+ /* Blurred glow effect */
75+ }
76+
77+ /* Frame behind the box */
78+ .frame {
79+ position : absolute;
80+ top : -40px ;
81+ /* Adjust as necessary */
82+ left : -40px ;
83+ /* Adjust as necessary */
84+ width : 480px ;
85+ /* Adjust size to be slightly bigger than the .box */
86+ height : 480px ;
87+ /* Adjust size to be slightly bigger than the .box */
88+ z-index : -2 ;
89+ /* Puts the frame behind the box */
90+ }
91+
92+ /* Overlay with name */
93+ .overlay {
94+ position : absolute;
95+ top : 0 ;
96+ left : 0 ;
97+ width : 100% ;
98+ height : 100% ;
99+ background : rgba (0 , 0 , 0 , 0.7 );
100+ /* Semi-transparent black background */
101+ display : flex;
102+ flex-direction : column;
103+ align-items : center;
104+ justify-content : center;
105+ color : # fff ;
106+ font-size : 2rem ;
107+ opacity : 0 ;
108+ transition : opacity 0.3s ease-in-out;
109+ border-radius : 50% ;
110+ /* Keeps the overlay circular */
111+ line-height : 1.2 ;
112+ /* Reduce the line height to reduce vertical gaps */
113+ }
114+
115+ .overlay div {
116+ margin : 5px 0 ;
117+ /* Controls the space between the divs */
118+ font-size : 1.2rem ;
119+ /* Adjust font size if needed */
120+ }
121+
122+ /* Add margin above the links */
123+ .overlay .links {
124+ margin-top : 25px ;
125+ /* Add a slight gap above the links */
126+ }
127+
128+
129+
130+ /* Show the overlay on hover */
131+ .box : hover .overlay {
132+ opacity : 1 ;
133+ }
134+
135+
136+
137+ /* Animation for moving border */
138+ @keyframes borderMove {
139+ 0% {
140+ background-position : 0 0 ;
141+ }
142+
143+ 100% {
144+ background-position : 300% ;
145+ }
146+ }
147+
148+ @media (prefers-reduced-motion) {
149+ .box {
150+ transform : none !important ;
151+ }
152+ }
153+ </ style >
154+
155+ </ head >
156+
157+ < body >
158+
159+ < div class ="box ">
160+ <!-- Frame PNG behind the box -->
161+ < img class ="frame " src ="frame.png " alt ="Frame " />
162+ <!-- Image inside the circular box -->
163+ < img src ='./pic.png ' alt ="Image Description "
164+ style ="width: 100%; height: 100%; object-fit: cover; border-radius: 50%; ">
165+ <!-- Name overlay -->
166+ < div class ="overlay ">
167+ < div > name</ div >
168+ < div > coloumn </ div >
169+ < div class ="links "> links</ div >
170+ </ div >
171+
172+
173+
174+ < script >
175+ const card = document . querySelector ( ".box" ) ; // Selecting the box class
176+ const THRESHOLD = 15 ;
177+
178+ function handleHover ( e ) {
179+ const { clientX, clientY, currentTarget } = e ;
180+ const { clientWidth, clientHeight, offsetLeft, offsetTop } = currentTarget ;
181+
182+ const horizontal = ( clientX - offsetLeft ) / clientWidth ;
183+ const vertical = ( clientY - offsetTop ) / clientHeight ;
184+
185+ const rotateX = ( THRESHOLD / 2 - horizontal * THRESHOLD ) . toFixed ( 2 ) ;
186+ const rotateY = ( vertical * THRESHOLD - THRESHOLD / 2 ) . toFixed ( 2 ) ;
187+
188+ currentTarget . style . transform =
189+ `perspective(${ currentTarget . clientWidth } px) rotateX(${ rotateY } deg) rotateY(${ rotateX } deg)` ;
190+ }
191+
192+ function resetStyles ( e ) {
193+ e . currentTarget . style . transform =
194+ `perspective(${ e . currentTarget . clientWidth } px) rotateX(0deg) rotateY(0deg)` ;
195+ }
196+
197+ const motionMatchMedia = window . matchMedia ( "(prefers-reduced-motion)" ) ;
198+
199+ if ( ! motionMatchMedia . matches ) {
200+ card . addEventListener ( "mousemove" , handleHover ) ;
201+ card . addEventListener ( "mouseleave" , resetStyles ) ;
202+ }
203+ </ script >
204+
205+ </ body >
206+
207+ </ html >
0 commit comments