How to use map tag and area tag

php中世界最好的语言
Release: 2018-03-19 09:20:11
Original
2774 people have browsed it

This time I will show you how to use map tags and area tags, and what are the precautions for map tags and area tags. The following is a practical case, let's take a look.

The purpose of the map tag: is bound to the img tag and is often used to give a special meaning to a certain area of ​​the client image. , click this area to jump to a new document.

Because the map tag is bound to the img tag, we need to add the ID and name attributes to the map tag, and let the usemap attribute in the img tagQuoteThe id or name attribute in the map tag (due to different browsers, the usemap attribute receives the value of one of the two, so usually both the name and id attributes are written with the same value), and matched with the area tag for use.

The sample code is as follows:



    
             中国地图     新疆     西藏     青海     四川     云南     甘肃     宁夏     内蒙古     
Copy after login
The display effect is as follows:

We can It can be seen that this is a map. If it is just a picture, it will look very monotonous, so we use the map tag to give meaning to the regions of each province. Here I click on the Xinjiang region and jump to Xinjiang's Baidu Encyclopedia, as shown below:

In this way, we can directly understand the history and culture of each province without having to Searching one by one makes it more humane.

The area tag defines the area in the image that is given special meaning. Its main values ​​are alt, cooreds, href, shape, target, etc.

1, alt Attribute

Definition: Specifies the alternative text of the area.

Note: If you write the href attribute, the alt attribute is required

2. Cooreds attribute

Definition: Define the coordinates of the relevant area

Description: Used with the shape attribute

 (1 ) When the shape attribute is rect, it means that the relevant area is a rectangle, and the coordinates attribute value is (x1, y1, x2, y2), where x1, y1 are the coordinates of the upper left corner, and x2, y2 are the coordinates of the lower right corner;

  (2) When the shape attribute is circle, it means that the relevant area is a circle, and the coordinates attribute value is (x, y, radius), where x, y are the center coordinates of the circle , radius is the radius of the circle;

(3) When the shape attribute is poly, it means that the relevant area is a polygon, and the cooreds attribute value is (x1,y1,x2,y2, x3,y3......xn,yn), specifies the coordinates of each vertex of the polygon. Since the browser will automatically close the polygon, the tail coordinates do not have to be equal to the first coordinate.

3. href attribute

Definition: Defines the target connected to the relevant area

Note: The href attribute generally has three values ​​

(1) Absolute path: usually used to point to other websites such as (href="https://www.baidu.com" )

 (2) Relative path: usually used to point to a file within your own website such as (href="//favicon.ico")

 (3) Anchor link: usually used to point to the anchor in the page such as (href="#header")

4, shape attribute

Definition: defines the shape of the relevant area

Description: (1) Default value (default): Specifies all areas

(2) RECT: The relevant area is rectangular

This (3) CIRCLE: The relevant area is circular

# This #                                                                                                                                   # Where to open the target link

Instructions: (1)_blank: Open the linked document in a new window

(2)_self: By default, the linked document is opened in the same frame. 4) _top: Open the linked document in the entire window

(5) framename: Open the linked document in the specified frame

Description : The area tag can sometimes be used as a substitute for the a tag, because the a tag cannot directly nest the a tag. In some cases, we have to use it, then we can replace the a tag with the area tag to make the layout more beautiful. Simple.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

What are the steps for jest to test react native components

How to use js’s custom trim function

The above is the detailed content of How to use map tag and area tag. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!