制作五個自己的鏈接,可以通過CSS的偽元素和樣式來實(shí)現(xiàn),下面是一個簡單的示例代碼:
<!DOCTYPE html> <html> <head> <style> .links { position: relative; width: 200px; height: 40px; margin: 0 auto; } .links a { position: absolute; top: 0; left: 0; width: 40px; height: 40px; border: 1px solid #000; border-radius: 50%; text-align: center; line-height: 40px; } .links a:nth-child(1) { background-color: #f00; } .links a:nth-child(2) { background-color: #0f0; } .links a:nth-child(3) { background-color: #00f; } .links a:nth-child(4) { background-color: #ff0; } .links a:nth-child(5) { background-color: #f0f; } </style> </head> <body> <div class="links"> <a href="#">1</a> <a href="#">2</a> <a href="#">3</a> <a href="#">4</a> <a href="#">5</a> </div> </body> </html>
在這個示例中,我們創(chuàng)建了一個包含五個鏈接的div
元素,每個鏈接都用一個a
元素表示,通過CSS,我們設(shè)置了div
元素的寬度、高度和居中顯示,以及a
元素的樣式,包括邊框、邊框圓角、文本居中和背景顏色,每個鏈接的背景顏色都不同,通過CSS的偽元素和樣式來實(shí)現(xiàn)。
版權(quán)聲明:除非特別標(biāo)注,否則均為本站原創(chuàng)文章,轉(zhuǎn)載時請以鏈接形式注明文章出處。