cari
  • Log masuk
  • Daftar
Penetapan semula kata laluan berjaya

Ikuti proiects vou berminat dengan andi aet terbaru mengenai mereka

pautan CSS

Pautan CSS

Pautan yang berbeza boleh mempunyai gaya yang berbeza.


Gaya pautan

Gaya pautan, anda boleh menggunakan mana-mana sifat CSS (seperti warna, fon, latar belakang, dan lain-lain).

Pautan khas boleh mempunyai gaya yang berbeza, bergantung pada statusnya.

Empat status pautan ialah:

  • a:pautan - pautan biasa, tidak dilawati

  • a: dilawati - pautan bahawa pengguna telah melawat

  • a:tuding tetikus - apabila pengguna mengarahkan tetikus pada pautan

  • a:aktif - pautan itu Pada saat anda klik


Instance

    <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
<style>
a:link {color:#FF0000;}    /* unvisited link */
a:visited {color:#00FF00;} /* visited link */
a:hover {color:#FF00FF;}   /* mouse over link */
a:active {color:#0000FF;}  /* selected link */
</style>
</head>

<body>
<p><b><a href="/css/" target="_blank">这是一个链接</a></b></p>
<p><b>注意:</b> a:hover 必须在 a:link 和 a:visited 之后,需要严格按顺序才能看到效果。</p>
<p><b>注意:</b> a:active 必须在 a:hover 之后。</p>
</body>
</html>

Jalankan program dan cuba


Apabila menetapkan gaya untuk beberapa keadaan pautan, terdapat juga beberapa peraturan pesanan:

  • a:tuding mesti mengikut a:pautan dan a:dilawati

  • a:aktif mesti mengikut a:tuding


Gaya pautan biasa

Lihat dalam keadaan apa ia berdasarkan contoh perubahan warna pautan di atas.

Mari kita beralih kepada memautkan gaya dengan beberapa gaya biasa yang lain:


Hiasan Teks

Atribut hiasan teks digunakan terutamanya untuk mengalih keluar garis bawah dalam pautan:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
<style>
a:link {text-decoration:none;}    /* unvisited link */
a:visited {text-decoration:none;} /* visited link */
a:hover {text-decoration:underline;}   /* mouse over link */
a:active {text-decoration:underline;}  /* selected link */
</style>
</head>

<body>
<p><b><a href="/css/" target="_blank">This is a link</a></b></p>
<p><b>注意:</b> hover必须在:link和 a:visited之后定义才有效.</p>
<p><b>注意:</b>active必须在hover之后定义是有效的.</p>
</body>
</html>

Jalankan program untuk melihat


Warna latar belakang

Atribut warna latar belakang menentukan warna latar belakang pautan:

     <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
<style>
a:link {background-color:#B2FF99;}    /* unvisited link */
a:visited {background-color:#FFFF85;} /* visited link */
a:hover {background-color:#FF704D;}   /* mouse over link */
a:active {background-color:#FF704D;}  /* selected link */
</style>
</head>

<body>
<p><b><a href="/css/" target="_blank">This is a link</a></b></p>
<p><b>注意:</b> hover必须在:link和 a:visited之后定义才有效.</p>
<p><b>注意:</b>active必须在hover之后定义是有效的.</p>
</body>
</html>

Jalankan atur cara untuk mencubanya


Lagi contoh

Tambah gaya hiperpautan yang berbeza

    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>php中文网(php.cn)</title>
    <style>
        a.one:link {color:#ff0000;}
        a.one:visited {color:#0000ff;}
        a.one:hover {color:#ffcc00;}

        a.two:link {color:#ff0000;}
        a.two:visited {color:#0000ff;}
        a.two:hover {font-size:150%;}

        a.three:link {color:#ff0000;}
        a.three:visited {color:#0000ff;}
        a.three:hover {background:#66ff66;}

        a.four:link {color:#ff0000;}
        a.four:visited {color:#0000ff;}
        a.four:hover {font-family:monospace;}

        a.five:link {color:#ff0000;text-decoration:none;}
        a.five:visited {color:#0000ff;text-decoration:none;}
        a.five:hover {text-decoration:underline;}
    </style>
</head>

<body>
<p>将鼠标移至链接上改变样式.</p>

<p><b><a class="one" href="" target="_blank">这个链接改变颜色</a></b></p>
<p><b><a class="two" href="" target="_blank">这个链接改变字体大小</a></b></p>
<p><b><a class="three" href="" target="_blank">这个链接改变背景颜色</a></b></p>
<p><b><a class="four" href="" target="_blank">这个链接改变字体类型</a></b></p>
<p><b><a class="five" href="" target="_blank">这个链接改变文字修饰</a></b></p>
</body>

</html>

Jalankan program untuk mencubanya


Contoh

Buat kotak pautan

       <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
<style>
a:link,a:visited
{
	display:block;
	font-weight:bold;
	color:#FFFFFF;
	background-color:#98bf21;
	width:120px;
	text-align:center;
	padding:4px;
	text-decoration:none;
}
a:hover,a:active
{
	background-color:#7A991A;
}
</style>
</head>

<body>
<a href="/css/" target="_blank">这是一个链接</a>
</body>
</html>

Jalankan program dan cuba



fail baharu
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <style> a:link,a:visited { display:block; font-weight:bold; color:#FFFFFF; background-color: #64ce7a; width:120px; text-align:center; padding:4px; text-decoration:none; } a:hover,a:active { background-color: #c65355; } </style> </head> <body> <a href="" target="_blank">这是一个链接</a> </body> </html>
Tetapkan Semula Kod
Operasi automatik
serahkan
Pratonton Clear
  • Cadangan kursus
  • Muat turun perisian kursus