![]() ![]() The values are just the text values of the shape and coords attributes of the area element. The function takes two parameters: shape The type of shape ( circle, poly, or rect) coords A comma-separated list of coordinate values It’s pretty simple, but in case anyone else needs this I thought I’d share. I couldn’t find a function to do that so I wrote my own. In a recent project I was working on a script interacting with an image map consisting of irregular areas and needed to find the center of each of these areas. By using the element, you can add images of all formats, and the browser will use the first format it recognizes, and ignore any of the following elements.How to find the center of an area element with JavaScript Some browsers or devices may not support all image formats. The browser will use the first element with matching attribute values, and ignore any of the following elements. If you have a small screen or device, it is not necessary to load a large image file. There are two main purposes for the element: 1. Show different images for different screen sizes: Each element has a media attribute that defines when the image is the most suitable. This way the browser can choose the image that best fits the current view and/or device. The element contains one or more elements, each referring to different images through the srcset attribute. The HTML element gives web developers more flexibility in specifying image resources. This way, the background image will cover the entire element, with no stretching (the image will keep its original proportions): If you want the background image to cover the entire element, you can set the background-size property to cover. If the background image is smaller than the element, the image will repeat itself, horizontally and vertically, until it reaches the end of the element:īackground-image: url('example_img_girl.jpg') If you want the entire page to have a background image, you must specify the background image on the element: This tag is also commonly referred to as the element.You can associate a hyperlink with this clickable area. Specify the background image in the element: The HTML tag defines a clickable area ( or hotspot) inside of an image map.To add a background image on an HTML element, use the HTML style attribute and the CSS background-image property: ExampleĪdd a background image on a HTML element: Example Now we have enough data to create a clickable rectangular area:Ī background image can be specified for almost any HTML element. The coordinates 270,350 is located 270 pixels from the left margin and 350 pixels from the top: So, the coordinates 34,44 is located 34 pixels from the left margin and 44 pixels from the top: The coordinates for shape="rect" come in pairs, one for the x-axis and one for the y-axis. You must also define some coordinates to be able to place the clickable area onto the image. You must define the shape of the clickable area, and you can choose one of these values: Different shapes have different coordinate requirements (see below). Multiple coordinate values are separated by commas. Coordinates start at 0,0 which is the top-left corner of the area. A clickable area is defined using an element. The coords attribute specifies the coordinates of an area's image map. The name attribute must have the same value as the ‘s usemap attribute. The element is used to create an image map, and is linked to the image by using the required name attribute: Tip: You can use any image as an image map! The usemap value starts with a hash tag # followed by the name of the image map, and is used to create a relationship between the image and the image map. The only difference from other images is that you must add a usemap attribute: To create an image map you need an image, and some HTML code that describes the clickable areas. The idea behind an image map is that you should be able to perform different actions depending on where in the image you click. Try to click on the computer, phone, or the cup of coffee in the image below: The areas are defined with one or more tags. An image map is an image with clickable areas. With HTML image maps, you can create clickable areas on an image. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |