Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

แต่งลิงค์ด้วย CSS


ในการจัดรูปแบบลิงก์ด้วย CSS อันดับแรก เราควรทราบสถานะลิงก์ต่อไปนี้:ลิงก์ เข้าชมแล้ว โฮเวอร์ และใช้งานอยู่ ใช้คลาสหลอกขององค์ประกอบสมอเพื่อจัดรูปแบบลิงก์ -

a:link for link
a:visited forvisited link
a:link for hover on link
a:active for active link

ตัวอย่าง

เรามาดูตัวอย่างกัน −

<!DOCTYPE html>
<html>
<head>
<style>
a:link {
   color: orange;
   text-decoration: underline;
}
a:hover {
   color: red;
   text-decoration: underline;
}
a:active {
   color: green;
   text-decoration: underline;
}
</style>
</head>
<body>
<h1>Tutorials</h1>
<p><a href="https://www.tutorialspoint.com/java">Java</a></p>
<p><a href="https://www.tutorialspoint.com/chsharp">C#</a></p>
<p><a href="https://www.tutorialspoint.com/jquery">jQuery</a></p>
<p><a href="https://www.tutorialspoint.com/ruby">Ruby</a></p>
<p><a href="https://www.tutorialspoint.com/pytorch">PyTorch</a></p>
</body>
</html>

ผลลัพธ์

แต่งลิงค์ด้วย CSS

ตัวอย่าง

เรามาดูตัวอย่างอื่นกัน −

<!DOCTYPE html>
<html>
<head>
<style>
a:link {
   color: blue;
   text-decoration: none;
}
a:hover {
   color: blue;
   text-decoration: none;
}
a:active {
   color: blue;
   text-decoration: none;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<div>
<p>This is the <a href="https://tutorialspoint.com">reference</a></p>
</div>
</body>
</html>

ผลลัพธ์

แต่งลิงค์ด้วย CSS