I'm trying to create a searchlight/ spotlight effect that will highlight some text using CSS animations. Heres a fiddle
I would like to have the colouring of the spotlight become more translucent the further away from the light source (using a colour gradient).
Due to my spotlight being a upside down triangle - I cannot seem to do this using the methods outlined here.
Would somebody be able to help me with this?
CSS:
h1 {
color: green;
position: absolute;
}
body {
background-color: black;
overflow: hidden;
margin: 0;
}
.spotlight {
position: relative;
width: 10vw;
height: 0vh;
border-top: 100vh solid rgba(255, 255, 255, 0.25);
border-left: 12vw solid transparent;
border-right: 12vw solid transparent;
background-color: transparent;
-webkit-transform-origin: 50% 100% 0;
z-index: 0;
-webkit-animation: move 7s ease-in-out;
}
@-webkit-keyframes move {
0% {
-webkit-transform: rotate(-30deg) scaleX(0.4);
}
50% {
-webkit-transform: rotate(30deg) scaleX(0.4);
}
100% {
-webkit-transform: rotate(0deg) ;
}
}
HTML:
<html>
<head>
</head>
<body>
<h1>
Some text
</h1>
<div class="spotlight spot1"></div>
</body>
</html>