Crafting an innovative horizontal CSS spotlight using conic-gradient styling

Seeking advice: I need to implement three spotlights on a webpage

  • One shining directly downwards
  • One angled from the left to the upper-top
  • One angled from the right to the upper-top

I managed to create a vertical spotlight using CSS conic-gradient, but I'm having trouble with the horizontal conical spotlights from the left and right.

Any CSS experts out there who can simplify this for me? Are there any CSS tools available to assist with this task?

body {
      background-color: black;
    }

    .light_center {
        transform-origin: center top;
        height: 120vh;
        left: 1.05vw;
        top: 0px;
        rotate: -1deg;
        position: absolute;
        width: 98.5vw;
        z-index:-10;
        background:
          conic-gradient(
            at 50% 5%,
            transparent 43%,
            hsl(0, 0%, 100%) 47%,
            hsl(0, 0%, 100%) 53%,
            transparent 57.5%
            )
          50% -25px / 100% 100%;
            
          background-blend-mode: overlay;
          background-repeat: no-repeat;
          mix-blend-mode: screen;
          opacity: 1;
          filter: blur(10px);
        
          -webkit-mask-image: radial-gradient(
          circle at 50% 0%,
          black 5%,
          transparent 70%
        );
      }
<html>
      <div class="light_center"></div>
</html>

Despite successfully creating a top-down vertical spotlight on a dark background, I am struggling with setting up the horizontal equivalents. Any insights on an easier approach to accomplish this would be greatly appreciated.

Answer №1

In my opinion, the most straightforward approach with the current source is to simply rotate it. If I've interpreted the question correctly.

I believe you can manage the spotlight as a single class and make adjustments to the angle accordingly.

body {
  background-color: black;
}

.light_center {
  transform-origin: center top;
  height: 120vh;
  left: 1.05vw;
  top: 0px;
  rotate: -1deg;
  position: absolute;
  width: 98.5vw;
  z-index: -10;
  background: conic-gradient(at 50% 5%, transparent 43%, hsl(0, 0%, 100%) 47%, hsl(0, 0%, 100%) 53%, transparent 57.5%) 50% -25px / 100% 100%;
  background-blend-mode: overlay;
  background-repeat: no-repeat;
  mix-blend-mode: screen;
  opacity: 1;
  filter: blur(10px);
  -webkit-mask-image: radial-gradient(circle at 50% 0%, black 5%, transparent 70%);
}

.light_left {
  transform-origin: center top;
  height: 120vh;
  left: -41.95vw;
  top: 0px;
  rotate: -28deg;
  position: absolute;
  width: 98.5vw;
  z-index: -10;
  background: conic-gradient(at 50% 5%, transparent 43%, hsl(0, 0%, 100%) 47%, hsl(0, 0%, 100%) 53%, transparent 57.5%) 50% -25px / 100% 100%;
  background-blend-mode: overlay;
  background-repeat: no-repeat;
  mix-blend-mode: screen;
  opacity: 1;
  filter: blur(10px);
  -webkit-mask-image: radial-gradient(circle at 50% 0%, black 5%, transparent 70%);
}

.light_right {
  transform-origin: center top;
  height: 120vh;
  left: 43.05vw;
  top: 0px;
  rotate: 32deg;
  position: absolute;
  width: 98.5vw;
  z-index: -10;
  background: conic-gradient(at 50% 5%, transparent 43%, hsl(0, 0%, 100%) 47%, hsl(0, 0%, 100%) 53%, transparent 57.5%) 50% -25px / 100% 100%;
  background-blend-mode: overlay;
  background-repeat: no-repeat;
  mix-blend-mode: screen;
  opacity: 1;
  filter: blur(10px);
  -webkit-mask-image: radial-gradient(circle at 50% 0%, black 5%, transparent 70%);
}
<div class="light_left"></div>
<div class="light_center"></div>
<div class="light_right"></div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can we define a style or CSS for one element depending on the characteristics of another element?

One challenge I'm facing involves a 3rd party library (fullcalendar) that automatically sets the height of elements based on internal calculations to ensure they look good in any viewport: <div style="height: 72px;"> Unfortunately, not all ele ...

Make sure to include the !important declaration when setting the fill property for

When attempting to apply !important to the fill property of an SVG file, I'm encountering issues with the syntax. Despite my efforts, the !important directive is not being correctly applied to the fill property, resulting in the circle element renderi ...

Chrome browser rendering image as PHP/CSS/HTML web navigation bar

I've hit a snag while working on my small website. The navigation of the website is functioning properly in Internet Explorer, but in Google Chrome, it's not clickable. Initially, I thought the issue might be related to the background image of ...

Issue with Bootstrap side navbar not collapsing when clicked on a link

Currently, I'm working on creating a website for a friend. While I used to have some experience with coding in the past, it has been a while and I am a bit rusty. This time around, I decided to use bootstrap for the project. However, I'm struggli ...

An alternative to Beautiful Soup for Python 3.2

Looking to create a web crawler for extracting information from various web pages, I discovered Beautiful Soup which seemed like an excellent tool. It allows me to parse entire documents, create dom objects, iterate through them, and extract attributes sim ...

Tips for revealing a hidden div by clicking on another div?

I have a Google visualization chart inside a div tag. I would like to display this chart in a pop-up box when clicking on the chart's div. I am utilizing jQuery for this feature. ...

Using javascript to transform the entire list item into a clickable link

Currently, I am using PHP in WordPress CMS to populate slides on a slider. Each slide contains a link at the bottom, and my goal is to target each slide (li) so that when clicked anywhere inside it, the user is directed to the URL specified within that par ...

The combination of Asp.net and Bootstrap offers a powerful

I am facing an issue with using Bootstrap in my ASP.NET project. The page displays correctly on a desktop, but when I resize the page to mobile phone size, the navigation panel does not stay in dropdown position. Here is my code: <%@ Page Language="C ...

Unable to display image using jQuery load() function on an HTML page

I have implemented the following code snippet to load an HTML page within a div: $("#htmlViewer").load("conversion_test/to_convert_3264/"+getPageName(pageCount)+".htm", function(response, status, xhr) { if (status == "error") { ...

Excessive gap located above the section element

On the web page I'm practicing with, I've noticed an unwanted space at the top of the "Favorite Food" section. To center my unordered list, I made the "section" elements inline-block, but this created the issue. How can I remove that space at the ...

Wavy CSS Animation

For assistance with my spinning image, please check out this fiddle: https://jsfiddle.net/dricardo1/9a8p6srb/ Hello! I'm struggling with a spinning image that has a noticeable wobble when rotating. I can't seem to find a solution to make the rot ...

Is there a way to achieve a double background color effect in CSS while ensuring that the text is centered within the second background color element?

How can I achieve a layout similar to the one shown in this image: ul menu li tags Should I use two tags for each element? Here is an example: <ul class="menu"> <div class="outside"><li class="inside"><a href="#">Firefox</a ...

Is creating an expanding tab in CSS a difficult task?

I am in the process of developing a college website and I am curious about the difficulty level involved in creating an expanding tab on the side of the webpage. The idea is that when users hover over the tab with their mouse, it would expand to reveal add ...

Troubleshooting CSS Hover Not Displaying Properly in Angular 14

In the footer class of my HTML, there is a code snippet with chevrons: <div class="link-list"> <div *ngFor="let link of insideLinksLeft | originalOrderKeyValue" class="link"> <a [href]="link.val ...

Guide to switching classes with jquery

On my webpage, I have a star rating system that I want to toggle between "fa fa-star" and "fa fa-star checked" classes. I found some information on how to do this here: Javascript/Jquery to change class onclick? However, when I tried to implement it, it di ...

The addClass, removeClass, and css functions in jQuery are malfunctioning

I stumbled upon this website and I am looking to switch the font color from black to white. I attempted various methods but unfortunately, none of them seemed to work: Implementing jQuery's addClass function (to add a class to the SPAN tag) Uti ...

Progressively increasing the time by 15 seconds during each iteration of the CSS @each loop

I recently made changes to a CSS script that involves the repetition of an animation task. Rather than repeating a segment of code 30 times, I decided to streamline it using a loop. Now, there are 30 <div></div> segments and each one undergoes ...

Modify PHP script to extract the Document Object Model (DOM) from a specified URL

Hey there, I'm currently using this code to extract and display the HREFs of all "A" tags from a URL. However, my output includes the entire link when I only want the name portion after http://twitter.com/namehere So, I'm looking to clean up my ...

Guide to making a sliding animation appear when hovering over a menu using jQuery

I have noticed a common feature on many websites, but I am unsure of how to explain it. At times, there are sliding elements in the navigation, like an arrow under menu items that moves when the user hovers over different links. Here is an example of a s ...

Creating visuals from written content

I am attempting to transform Y[0] into an image rather than text. Currently, it is only displayed as a plain text link and not as an image. <html> <head> <script type="text/javascript"> function modifyContent(){ var rows=document.g ...