簡體   English   中英

嘗試覆蓋html div中的鏈接樣式,但不起作用

[英]Trying to override link style inside an html div but it isn't working

我對CSS編碼比較陌生。 我一直在網上尋求幫助,但找不到任何有幫助的解決方案。 我最想設置我的代碼的地方如下。

我在單個頁面的CSS窗口中輸入的CSS代碼是:

 div.box_round_background { padding: 5px; } div.box_round { -moz-border-radius: 12px; /* FF1+ */ -webkit-border-radius: 12px; /* Saf3-4 */ border-radius: 12px; /* Opera 10.5, IE 9, Saf5, Chrome */ background-color: #86ae30; } div.box_round h1 { color: #ffffff; padding: 20px; } a.box_round h1:link { color:#ffffff; text-decoration:none; font-weight:normal; } a.box_round h1:visited { color: #e1efc3; text-decoration:none; font-weight:normal; } a.box_round h1:hover { color: #5c7821; text-decoration:underline; font-weight:normal; } a.box_round h1:active { color: #a4ce4b; text-decoration:none; font-weight:normal; } 

我插入到html源代碼中的代碼是:

 <div class="box_round_background"> <div class="box_round"> <a href="/web-design-services"><h1>Web Design Services</h1></a> </div> </div> 

我沒有獲得所需的鏈接顏色結果。 它對鏈接顏色完全沒有太大影響。

誰能幫我弄清楚我可能做錯了什么? 謝謝!

嘗試從更改css選擇器

    a.box_round h1:link
    a.box_round h1:visited
    a.box_round h1:hover
    a.box_round h1:active

    .box_round a:link h1
    .box_round a:visited h1
    .box_round a:hover h1
    .box_round a:active h1

CSS是從更高更密切,所以當你說的工作div.box_round h1你的意思是h1.box_roud然而,在提供的代碼沒有h1只有a標簽。

因此,您只需將h1更改為:

 div.box_round_background { padding: 5px; } div.box_round { -moz-border-radius: 12px; /* FF1+ */ -webkit-border-radius: 12px; /* Saf3-4 */ border-radius: 12px; /* Opera 10.5, IE 9, Saf5, Chrome */ background-color: #86ae30; } div.box_round a { color: #ffffff; padding: 20px; } .box_round a:link { color:#ffffff; text-decoration:none; font-weight:normal; } .box_round a:visited { color: #e1efc3; text-decoration:none; font-weight:normal; } .box_round a:hover { color: #5c7821; text-decoration:underline; font-weight:normal; } .box_round a:active { color: #a4ce4b; text-decoration:none; font-weight:normal; } 
 <div class="box_round_background"> <div class="box_round"> <a href="/web-design-services"><h1>Web Design Services</h1></a> </div> </div> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM