2016-04-25 72 views
-1

當然,我在CSS Button Generator中設計了它,因爲我對CSS無論如何都很懶惰和糟糕,但是在我嘗試粘貼代碼之前,它一直在工作!CSS風格按鈕不起作用?

因此,對於上下文,我決定將我的整個代碼添加到pastebin鏈接,如果它太麻煩了,很抱歉。 Click here.

但是,我不能得到它的工作,但是,如果顯示花哨的CSS樣式,按鈕將無法正常工作。如果該按鈕有效,則它位於超鏈接版本中。幫幫我?

+0

它在標籤內!我沒有發佈我的整個代碼,因爲它可能是一個痛苦,如果有必要,我會包含一個pastebin鏈接! – Roy

回答

1

雖然我是新手我自己,因爲據我所知document.getElementById("myButton").addEventListener("click", function()必須保持在script標籤

像這樣:

<script> 
document.getElementById("myButton").addEventListener("click", function() 
</script> 

檢查是否奏效

0

可悲的是超鏈接無法正常工作作爲按鈕,儘管事實上它可以看起來像一個樣式

我的建議是風格的按鈕,你試圖塑造hy perlink

一個簡單的調試方法測試的天氣超鏈接可以作爲按鍵會的onclick增加的超級鏈接

這個問題被關閉,但有一個公認的答案,我覺得可能有利於你 Add onclick event to hyperlink

+0

不,不。這不是一個真正的超鏈接。我在解釋自己時很糟糕。我將包含一個[pastebin](http://pastebin.com/rwQh0UcM)鏈接以供參考。 – Roy

+0

任何使用 2016-04-25 22:55:15

0

這工作。 。複製下面的代碼螞蟻嘗試

document.getElementById("myButton").addEventListener("click", function(){alert();})
<a href="#" class="myButton" id="myButton">green</a> 
 

 
<style> 
 
.myButton { 
 
\t background-color:#44c767; 
 
\t -moz-border-radius:28px; 
 
\t -webkit-border-radius:28px; 
 
\t border-radius:28px; 
 
\t border:1px solid #18ab29; 
 
\t display:inline-block; 
 
\t cursor:pointer; 
 
\t color:#ffffff; 
 
\t font-family:Arial; 
 
\t font-size:17px; 
 
\t padding:16px 31px; 
 
\t text-decoration:none; 
 
\t text-shadow:0px 1px 0px #2f6627; 
 
} 
 
.myButton:hover { 
 
\t background-color:#5cbf2a; 
 
} 
 
.myButton:active { 
 
\t position:relative; 
 
\t top:1px; 
 
} 
 
</style>