Arrangement of asymmetrical interactive forms

I am in need of creating a design featuring numerous non-rectangular shapes that are interactive and reveal an image when clicked. The concept is to transform an image of stained glass into a webpage where each pane can be clicked to unveil its colorful version, similar to the stained glass windows found in churches.

My vision for this project involves two main components: a colored version of the entire stained glass image, overlaid with a black and white version. Each individual glass pane should be clickable, with a click event toggling between the black and white view and the colored view.

Although I have not discovered a specific approach for achieving this effect with such complex shapes and interactive elements, I have provided an example below to illustrate the desired outcome. In this scenario, each glass segment would be clickable and transition from monochrome to color upon interaction.

The white lines in the image serve to indicate that each pane operates independently from the others, enhancing the interactivity of the design.

https://i.sstatic.net/4KmlR.jpg

Answer №1

Creating a unique design of irregular clickable polygons can be achieved using inline SVG and the following:

This method enables you to craft any kind of interactive shape and ensure responsiveness.

Take a look at this example demonstrating how to create interactive shapes with hover and focus states:

svg {
  display:block;
  width:40%;
  height:auto;
  margin:0 auto;
}
polygon {  
  fill:#ccc;
  stroke:#fff;
  stroke-width:0.3;
  transition: fill .15s;
}
a:hover .teal { 
  fill:teal;
}
a:hover .pink { 
  fill:pink;
}
a:focus .teal, 
a:focus .pink { 
  fill:orange;
}
<svg viewbox="0 0 20 19">
  <a xlink:href="#"><polygon class="teal" points="0 0 10 5 8 10 0 5" /></a>
  <a xlink:href="#"><polygon class="pink" points="0 0 10 5 15 0" /></a>
  <a xlink:href="#"><polygon class="teal" points="0 5 8 10 0 15" /></a>
  <a xlink:href="#"><polygon class="teal" points="15 0 10 5 20 19" /></a>
  <a xlink:href="#"><polygon class="pink" points="20 19 10 5 8 10" /></a>
  <a xlink:href="#"><polygon class="teal" points="20 19 8 10 0 15 8 13" /></a>
  <a xlink:href="#"><polygon class="pink" points="20 19 0 19 0 15 8 13" /></a>
  <a xlink:href="#"><polygon class="pink" points="15 0 20 19 20 20 20 0" /></a>
  <a xlink:href="#"><polygon class="teal" points="20 17 18 16 16 17 17 20 20 20" /></a>
</svg>

The polygon element specifically deals with polygons. For creating curved shapes, it is recommended to utilize the path element along with curve commands.

Answer №2

Utilizing image area maps can be extremely beneficial for your website.

Check out this awesome tool that makes creating image maps a breeze!

For instance:

<img src="url/to/your/image.jpg" alt="" usemap="#Map" />
<map name="Map" id="Map">
    <area alt="" title="" href="LINK1" shape="poly" coords="380,163,448,127,515,163,457,205" />
    <area alt="" title="" href="LINK2" shape="poly" coords="140,13,48,1,55,13,47,12" />
</map>

In essence, you can designate different clickable areas with specific links on your images. It's much simpler to show than tell how it works! :)

Answer №3

Completing this task may take some time, however, the following resource could be beneficial for you:

function helloWorld(area) {
  console.log('You\'ve clicked the correct area') 
}
#container { position: relative; }
#info { 
  position: absolute;
  bottom: 90px;
  left: 85px;
  background: yellow;
  display: inline-block;
}
<section id="container">
<img src="https://i.sstatic.net/4KmlR.jpg" alt="" usemap="#Map" />
<map name="Map" id="Map">
    <area alt="" title="" href="javascript:helloWorld()" shape="poly" coords="66,282,73,284,79,303,78,320,49,328,48,317" />
    [...]
</map>

<span id="info">&lt;== click here</span>
</section>

Answer №4

Are you seeking information about the <map>-element?

Although it typically generates rectangular clickable regions, there are ways to incorporate javascript onclick functions to detect mouse positioning in specific areas. This allows for detection of circular, triangular, or irregularly shaped areas.

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

Unveiling the Truth about Svelte Transitions

Recently, I attempted to incorporate the guidance provided in this repl () for implementing flying and fading effects on divs. However, it seems that I may have a slight misunderstanding regarding the concept... To tackle this, I designed a component rese ...

Deselect the checkbox if you are checking a different checkbox

Struggling with my code, it's hit or miss. Feeling defeated. Seeking assistance to uncheck a checkbox when another checkbox is checked. Check out the code below: JavaScript: $("#1 #checkAll").change(function() { if ($("#1 #checkAll").is(' ...

Upon loading, make sure to click on the link located within the third <li> tag

I am working with a list (<ul>): <ul class="options_inner"> <li><a data-dk-dropdown-value=".option1"></a></li> <li><a data-dk-dropdown-value=".option2"></a></li> <li><a data- ...

What could be causing the error "Unexpected identifier 'trytoCatch' while trying to minify?

I recently updated my script.js and now I'm looking to use "minify" in Node.js to compress it. When I type the command minify script.js > script.min.js into the terminal, I get an error message that says: /node_modules/bin/minify.js:3 import "tryTo ...

Accessing information from a JSON array

I am encountering difficulties in fetching data from a JSON file. Whenever I click the button, it triggers the call function which then retrieves data from the json.jsp file containing an array. However, I am unable to retrieve the data successfully. Below ...

Show image in ReactJS using flask send_file method

Using Flask's send_file function, I send an image to the client in the following way: @app.route('/get-cut-image',methods=["GET"]) def get_cut_img(): response = make_response(send_file(file_path,mimetype='image/png')) respon ...

Exploring the world of CSS and designing layouts using multiple div elements

Upon reviewing this website, I must admit it is getting close to what I envision. However, being a perfectionist and new to HTML and CSS, I find myself struggling to achieve the desired outcome. The layout consists of two divs named topred and top yellow, ...

Deactivate the checkboxes with varying attributes

My goal is to disable checkboxes with different warehouse locations once a warehouse is selected. For instance, if I select California, I want all checkboxes from other states to be disabled. This should be based on the whseID attribute, but I am strugglin ...

Animate a div to sense whether it has reached the top or bottom position

Is it possible for a div to animate when it reaches almost halfway while scrolling? I'm looking to achieve this effect on a sticky sidebar, similar to how it works on this website: sample This is the code I have: $(function(){ // document ready ...

Is it possible for the Observable call in Angular 4 to function similarly to jQuery's synchronous AJAX method?

As I have a business logic function that needs to use HttpGet and I must wait for the result before continuing, jQuery's ajax can handle this easily. But I am curious if Observables have a similar feature? I was hoping for the result to be: John An ...

The Twitch API is providing inaccurate channel information

Currently facing an issue while working with the Twitch API. When making a GET request to /api.twitch.tv/helix/search/channels?query=[STREAMER_NAME], it seems to be returning the wrong streamer/user. For instance: /api.twitch.tv/helix/search/channels?quer ...

In Node.js, it is essential to use req.session.save() to ensure that sessions are properly saved

While developing a website with Node.js, Express, and Redis for session management, I noticed an issue where my session variable (isLoggedIn) wasn't being saved after refreshing the page. Strangely, calling req.session.save() after setting the variabl ...

Position the Crossmark to align with text using CSS styling

How can I properly align a crossmark and a checkmark with the text behind them? The checkmark looks aligned well, but the crossmark appears to be slightly off to the top-right. I'm hesitant to adjust margins and paddings as it may cause issues when th ...

Guidelines for linking a promise function to a JSX component

How can we use React components to handle the result of a promise function and map it to JSX components? <Promise on={myFunc}> <Pending> ... </Pending> <Resolved> {(data: any) => ( ... )} ...

Give a CSS Element a specific class

Can all h3 elements be styled with the class responsive-heading using only CSS? Take a look at the CSS snippet provided for more clarity: h3 { .responsive-heading } /* The responsive-heading class is defined in another CSS file and includes: .respons ...

Using TypeScript generics with the `keyof` operator may result in rejection

I created a custom method using the RXJS library which looks like this : function Subject<T>(t: T):T { return t; } In addition, I defined an interface that specifies the structure of my application values. Additional keys can be added to this i ...

What could be causing a tooltip to remain visible even after a mouseleave event in a React application

My goal is to display a tooltip when the mouse enters an item, and hide it when the mouse leaves. I created a demo that works perfectly fine. Check out the working demo here The above code successfully shows the tooltip on hover and hides it on leave. I ...

Initializing JavaScript prior to registering the Polymer element

When upgrading from Polymer version v0.5 to v1.0, the process of registering Polymer elements seems to have changed. Previously, in Polymer v1.0, we were able to execute JavaScript code from the index.html file to initialize all the necessary objects in ou ...

Is there a way to use an Angular $watch to determine the specific changes made to $scope.value?

I am monitoring a variable called $scope.value with a watch in my code. There are two ways in which the value can be updated: The first is by updating it from the controller, such as through any services. The second way is that any input event can also ...

Update overall font size to be 62% for a consistent look across the website

Recently, I developed a browser extension that adds an overlay button to the LinkedIn website. Everything was running smoothly until I discovered that LinkedIn uses a global font-size: 62,5% that completely messes up my design.. https://i.stack.imgur.com ...