Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> HTML

HTML <area> coords Attribute


แอตทริบิวต์ coords ขององค์ประกอบ <area> ใช้ตั้งค่าพิกัดของพื้นที่ใน image map ใช้แอตทริบิวต์นี้กับ shape attribute และตั้งค่าขนาดและรูปร่างของพื้นที่

Syntax ดังนี้:

<area coords="value">

ภายใต้ value ด้านบน คุณสามารถตั้งค่าพิกัดต่อไปนี้ด้วยพารามิเตอร์ต่างๆ:

x1,y1,x2,y2 พิกัดมุมซ้ายบนและมุมขวาล่างของสี่เหลี่ยม (shape="rect")
x,y,radius พิกัดจุดศูนย์กลางวงกลมและรัศมี (shape="circle")
x1,y1,x2,y2,..,xn,yn พิกัดขอบของ polygon

มาดูตัวอย่างการใช้ coords attribute ของ <area> element:

ตัวอย่าง

<!DOCTYPE html>
<html>
<body>
<h2>Learning</h2>
<p>Learn these technologies with ease....</p>
<img src="/images/usemap.gif" alt="usemap" border="0" usemap="#tutorials"/>
<map name="tutorials">
  <area shape="poly" coords="74,0,113,29,98,72,52,72,38,27" href="/perl/index.htm" alt="Perl Tutorial" target="_blank" />
  <area shape="rect" coords="22,83,126,125" alt="HTML Tutorial" href="/html/index.htm" target="_blank" />
  <area shape="circle" coords="73,168,32" alt="PHP Tutorial" href="/php/index.htm" target="_blank" />
</map>
</body>
</html>

ผลลัพธ์

HTML <area> coords Attribute

ในตัวอย่างข้างต้น เราตั้งค่า map บนภาพดังนี้:

<img src="/images/usemap.gif" alt="usemap" border="0" usemap="#tutorials"/>

ตอนนี้เราตั้งค่า map และ area ภายในสำหรับ shape:

<map name="tutorials">
  <area shape="poly" coords="74,0,113,29,98,72,52,72,38,27" href="/perl/index.htm" alt="Perl Tutorial" target="_blank" />
  <area shape="rect" coords="22,83,126,125" alt="HTML Tutorial" href="/html/index.htm" target="_blank" />
  <area shape="circle" coords="73,168,32" alt="PHP Tutorial" href="/php/index.htm" target="_blank" />
</map>

ขณะตั้งค่า area เราตั้งค่าพิกัดของ area ด้วย coords attribute:

<area shape="rect" coords="22,83,126,125" alt="HTML Tutorial" href="/html/index.htm" target="_blank" />