2010-01-08 65 views
2

基本上,我只想要RadioButtonList沒有單選按鈕就可以了,我會對rbl進行編碼,以便選定的項目具有不同的背景色,並使它看起來更專業,單選按鈕本身我希望能夠擺脫在外觀方面......如果你知道有任何方法可以做到這一點,請讓我知道!RadioButtonList沒有單選按鈕圈?

+0

任何人都有一些代碼? – 2010-01-08 21:00:25

回答

2

這對我幫助很大: HTTP_://www.ryanfait.com/resources/custom-checkboxes-and-radio-buttons/

此鏈接斷開,原來的主人是永遠..離線,所以內容

也許任何你讀這篇文章,可以嘗試將背景設置爲無輸入在CSS

<style> 
    input { 
     background:none !important; 
    } 
</style> 
+0

謝謝,擺脫單選按鈕左側的空心圓,但它仍然是一個很好的資源,我已將它加入書籤,將upvote你。 – 2010-01-08 19:25:41

1

我想不出任何簡單的方法,不用JavaScript混合一些技巧。

這可能是你想要的東西:
Accessible, Custom Designed Checkbox and Radio Button Inputs Styled with CSS (and a dash of jQuery)

stand-a-lone demo here

用來模擬天生的單選按鈕的圖像:Radio Button Image

+0

謝謝,但這並沒有擺脫單選按鈕左側的空心圓圈 – 2010-01-08 19:25:02

+0

但這些都是圖像。看到我更新的答案。您可以創建自己的無空心圓圈。 – 2010-01-08 19:32:00

+0

我明白你在說什麼,謝謝,將使用此作爲最後的手段,仍然在尋找一個可愛的風格=「button:dissapear.and.dont.come.back」type css style :) – 2010-01-08 19:55:49

0

找到一個合理的解決方案...

<head runat="server"> 
    <title>Test - Hide radio circles from radiobuttonlist</title> 
    <script type="text/javascript"> 
    function hideRadioSymbol() 
    { 
     var rads = new Array(); 
     rads = document.getElementsByName('list1'); //Whatever ID u have given to ur radiolist. 
     for(var i = 0; i < rads.length; i++) 
      document.getElementById(rads.item(i).id).style.display = 'none'; //hide 
    } 
    </script> 
    </head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
     <asp:RadioButtonList ID="list1" runat="server"> 
      <asp:ListItem Value="item1" Text="item1"></asp:ListItem> 
      <asp:ListItem Value="item2" Text="item2"></asp:ListItem> 
     </asp:RadioButtonList> 
    </div> 
    <script type="text/javascript">hideRadioSymbol()</script> //After list is completely rendered/loaded. 
    </form> 
</body> 
</html> 

噢,順便說一句,MVC是真棒,這是如何asp.net 應該已經從開始!

+0

像往常一樣,stackoverflow只是刪除所有的HTML,沒有錯誤的代碼發佈網站的默認邏輯! – 2010-01-10 12:13:39

+0

選擇'101010'按鈕將您的代碼縮進4格並保留格式。 – ChrisF 2010-01-12 16:33:58

+0

謝謝克里斯,固定! – 2010-01-12 16:37:34