2016-09-30 109 views
0

我在網站的各個部分使用了一個addthis按鈕,我想爲它們添加自定義CSS。我怎樣才能做到這一點?添加自定義CSS添加此按鈕?

<a role="button" tabindex="1" class="at-icon-wrapper at-share-btn at-svc-email" style="border-radius: 2px; background-color: rgb(132, 132, 132);"> 
 
    <span class="at4-visually-hidden">Share to Email</span> 
 
    <span class="at-icon-wrapper" style="line-height: 32px; height: 32px; width: 32px;"> 
 
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="at-icon at-icon-email" style="fill: rgb(255, 255, 255); width: 32px; height: 32px;"> 
 
     <g> 
 
     <g fill-rule="evenodd"></g> 
 
     <path d="M27 22.757c0 1.24-.988 2.243-2.19 2.243H7.19C5.98 25 5 23.994 5 22.757V13.67c0-.556.39-.773.855-.496l8.78 5.238c.782.467 1.95.467 2.73 0l8.78-5.238c.472-.28.855-.063.855.495v9.087z"></path> 
 
     <path d="M27 9.243C27 8.006 26.02 7 24.81 7H7.19C5.988 7 5 8.004 5 9.243v.465c0 .554.385 1.232.857 1.514l9.61 5.733c.267.16.8.16 1.067 0l9.61-5.733c.473-.283.856-.96.856-1.514v-.465z"></path> 
 
     </g> 
 
    </svg> 
 
    </span> 
 
</a>

這是一個按鈕如何出現在控制檯中,但我不能簡單地從這裏走班名,並添加CSS到它,因爲它會影響到其他按鍵也因爲它們可能具有相同的班級名稱。

+0

你想要什麼選擇?一個或跨度裏面? – Tom

+0

元素...... – lakshay

+0

並且正在選擇其他項目嗎? a.at-icon-wrapper.at-share-btn.at-svc-email – Tom

回答

1

/* Styles to simulate addthis formatting */ 
 
.atss .at-share-btn{border:0;padding:0}.atss .at-share-btn,.atss a{position:relative;display:block;width:3pc;margin:0;outline-offset:-1px;text-align:center;float:left;-webkit-transition:width .15s ease-in-out;transition:width .15s ease-in-out;overflow:hidden;background:#e8e8e8;z-index:100030;cursor:pointer}.at4-visually-hidden{position:absolute;clip:rect(1px,1px,1px,1px);padding:0;border:0;overflow:hidden}.atss .at-share-btn span .at-icon,.atss a span .at-icon{position:relative;top:0;left:0;display:block;background-repeat:no-repeat;background-position:50% 50%;width:2pc;height:2pc;line-height:2pc;border:none;padding:0;margin:0 auto;overflow:hidden;cursor:pointer;cursor:hand}.atss .at-share-btn .at-icon-wrapper,.atss a .at-icon-wrapper{display:block;padding:8px 0}a .at-icon-wrapper{cursor:pointer}.at-icon-wrapper{display:inline-block;overflow:hidden} 
 

 
/* overwrite code */ 
 
.at-svc-email .at-icon-wrapper { 
 
    background: green; 
 
} 
 
.at-svc-email .at-icon-wrapper svg { 
 
    fill: tomato!important; 
 
}
<a role="button" tabindex="1" class="at-icon-wrapper at-share-btn at-svc-email" style="border-radius: 2px; background-color: rgb(132, 132, 132);"> 
 
    <span class="at4-visually-hidden">Share to Email</span> 
 
    <span class="at-icon-wrapper" style="line-height: 32px; height: 32px; width: 32px;"> 
 
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="at-icon at-icon-email" style="fill: rgb(255, 255, 255); width: 32px; height: 32px;"> 
 
     <g> 
 
     <g fill-rule="evenodd"></g> 
 
     <path d="M27 22.757c0 1.24-.988 2.243-2.19 2.243H7.19C5.98 25 5 23.994 5 22.757V13.67c0-.556.39-.773.855-.496l8.78 5.238c.782.467 1.95.467 2.73 0l8.78-5.238c.472-.28.855-.063.855.495v9.087z"></path> 
 
     <path d="M27 9.243C27 8.006 26.02 7 24.81 7H7.19C5.988 7 5 8.004 5 9.243v.465c0 .554.385 1.232.857 1.514l9.61 5.733c.267.16.8.16 1.067 0l9.61-5.733c.473-.283.856-.96.856-1.514v-.465z"></path> 
 
     </g> 
 
    </svg> 
 
    </span> 
 
</a>

+0

但這會改變每個有這個類的按鈕的背景。 – lakshay

+0

@lakshay [This](http://stackoverflow.com/a/11918501/6501094)將改變CSS當一個元素有**多個**類。 [實施例](https://jsfiddle.net/tybro0103/covbtpaq/) – Roy123

相關問題