首頁  >  問答  >  主體

如何刪除 html 超連結「a」標籤的預設連結顏色?

<p>預設連結顏色為藍色。 如何刪除 html 超連結標籤 <code><a></a></code><a> 的預設連結顏色? </a></p>
P粉432906880P粉432906880394 天前873

全部回覆(2)我來回復

  • P粉884548619

    P粉8845486192023-08-24 13:50:34

    嘗試這樣的事情:

    a {
        color: #0060B6;
        text-decoration: none;
    }
    
    a:hover {
        color:#00A0C6; 
        text-decoration:none; 
        cursor:pointer;  
    }

    如果text-decoration不起作用,請將其變更為:

    text-decoration: none !important;

    !important 規則會覆寫 text-decoration 屬性的所有其他樣式。您可以在此處閱讀更多相關資訊。

    回覆
    0
  • P粉403804844

    P粉4038048442023-08-24 00:19:50

    繼承值

    a { color: inherit; }

    ...將導致元素呈現其父級的顏色(我認為這就是您正在尋找的)。

    現場示範如下:

    a {
      color: inherit;
    }
    <p>The default color of the html element is black. The default colour of the body and of a paragraph is inherited. This
      <a href="http://example.com">link</a> would normally take on the default link or visited color, but has been styled to inherit the color from the paragraph.</p>

    回覆
    0
  • 取消回覆