2016-11-04 61 views
0

我試圖修復與tickmarks和收音機週期複選框。CSS:輸入複選框和單選按鈕外觀

  1. 切換內容:「」未檢查狀態和內容:「\ 2714」檢查狀態我收到了閃爍。所以我讓顏色透明。那是對的嗎?

  2. 刻度線與盒子不完全吻合。如何才能改變那個刻度線?

  3. 如果句子被拆分成行,則正方形和文本落在相同的邊界上。如果兩者應該分開放置,我該怎麼辦?

  4. 單選按鈕上的句點(。)非常小,足以可見。如果我增加字體大小,它會與文本不一致。

我也複製了引導CSS和HTML格式。

這是我的jsfiddle鏈接。 https://jsfiddle.net/488s5e70/2/

input[type="radio"], 
 
input[type="checkbox"] { 
 
    -moz-appearance: none; 
 
    -webkit-appearance: none; 
 
    appearance: none; 
 
    outline: none; 
 
} 
 
input[type="checkbox"]+span:before { 
 
    width: 16px; 
 
    height: 16px; 
 
    border: 1px solid #000; 
 
    content: "\2714"; 
 
    color: transparent; 
 
    display: inline-block; 
 
    font-size: 13px; 
 
    margin-right: 5px; 
 
    text-align: center; 
 
} 
 
input[type="checkbox"]:disabled+span { 
 
    color: #ddd; 
 
} 
 
input[type="checkbox"]:checked+span:before { 
 
    content: "\2714"; 
 
    color: #000; 
 
} 
 
input[type="checkbox"]:disabled:checked+span:before { 
 
    content: "\2714"; 
 
    color: #ddd; 
 
} 
 
input[type="checkbox"]:disabled+span:before { 
 
    border: 1px solid #ddd; 
 
} 
 
input[type="radio"]+span:before { 
 
    width: 16px; 
 
    height: 16px; 
 
    border: 1px solid #000; 
 
    content: "."; 
 
    color: transparent; 
 
    display: inline-block; 
 
    font-size: 13px; 
 
    font-weight: bold; 
 
    margin-right: 5px; 
 
    border-radius: 8px; 
 
    text-align: center; 
 
} 
 
input[type="radio"]:disabled+span { 
 
    color: #ddd; 
 
} 
 
input[type="radio"]:checked+span:before { 
 
    content: "\00b7"; 
 
    color: #000; 
 
} 
 
input[type="radio"]:disabled:checked+span:before { 
 
    content: "\00b7"; 
 
    color: #ddd; 
 
} 
 
input[type="radio"]:disabled+span:before { 
 
    border: 1px solid #ddd; 
 
}
<div class="container"> 
 
    <div class="checkbox"> 
 
    <label> 
 
     <input type="checkbox" value="" checked> 
 
     <span>Option one is this and that&mdash;be sure to include why it's greatOption one is this and that&mdash;be sure to include why it's greatOption one is this and that&mdash;be sure to include why it's great</span> 
 
    </label> 
 
    </div> 
 
    <div class="checkbox"> 
 
    <label> 
 
     <input type="checkbox" value=""> 
 
     <span>Option one is this and that&mdash;be sure to include why it's great</span> 
 
    </label> 
 
    </div> 
 
    <div class="checkbox"> 
 
    <label> 
 
     <input type="checkbox" value="" disabled> 
 
     <span>Option one is this and that&mdash;be sure to include why it's great</span> 
 
    </label> 
 
    </div> 
 
    <div class="checkbox"> 
 
    <label> 
 
     <input type="checkbox" value="" disabled checked> 
 
     <span>Option one is this and that&mdash;be sure to include why it's great</span> 
 
    </label> 
 
    </div> 
 

 

 
    <div class="radio"> 
 
    <label> 
 
     <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1"> 
 
     <span>Option one is this and that&mdash;be sure to include why it's great</span> 
 
    </label> 
 
    <label> 
 
     <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked> 
 
     <span>Option one is this and that&mdash;be sure to include why it's great</span> 
 
    </label> 
 
    <label> 
 
     <input type="radio" name="optionsRadios2" id="optionsRadios1" value="option1" disabled> 
 
     <span>Option one is this and that&mdash;be sure to include why it's great</span> 
 
    </label> 
 
    <label> 
 
     <input type="radio" name="optionsRadios2" id="optionsRadios1" value="option1" checked disabled> 
 
     <span>Option one is this and that&mdash;be sure to include why it's great</span> 
 
    </label> 
 
    </div> 
 
</div>

+0

看看Font Awesome。它可能有你想要的圖形http://fontawesome.io/icons/ –

+0

我不想使用字體真棒。那是我的問題。我應該通過css和html完成。 –

回答

1
  1. 透明度,而不是內容 「」

其正道!它甚至更好。每一件事情是行


  • 當其有關字體的,沒有關於在所有相同和真實的顯示保修擬合刻度
  • 瀏覽器,我只是喜歡的背景圖片複選框,PNG圖像

    如果你有移動端用戶,請注意你的元素中的所有內容(打勾和球)可能得到改變 plain text replaced with android emoticons


  • 單獨塊
  • 只有2列的表可能是最快的解決方案。


  • 無線電
  • 使用另一個角色,我的產品是 「●」 或 「•」 然而,最好的辦法就是background-image

    input[type="radio"]:checked+span:before{ 
        content:"\25CF"; /* or any better character */ 
        color:#000; 
    } 
    
    +0

    第3點。如果你能看到我的例子,第一個複選框包含多行測試。例如它可以是條款和條件的彙總聲明。在這種情況下,複選框應該是分開的。 –

    +0

    更新了第3和第2點。 –

    1

    對,有些事情我會改變來解決這個問題。

    1. Flexbox,Flexbox無處不在。
    2. 爲什麼使用一段時間,當我們可以用一個BLACK CIRCLE

    你可以找到不同的形狀here如果鍵入「(十六進制值),」作爲你的內容纔會顯示。

    這是我所做的。

    input[type="radio"], 
     
    input[type="checkbox"] { 
     
        position: relative; 
     
        -moz-appearance: none; 
     
        -webkit-appearance: none; 
     
        appearance: none; 
     
        outline: none; 
     
    } 
     
    input[type="checkbox"]+span:before { 
     
        width: 16px; 
     
        height: 16px; 
     
        border: 1px solid #000; 
     
        content: "\2714"; 
     
        color: transparent; 
     
        display: inline-block; 
     
        font-size: 13px; 
     
        margin-right: 5px; 
     
        text-align: center; 
     
        /* new code notice me! */ 
     
        display: inline-flex; 
     
        align-items: center; 
     
        justify-content: center; 
     
    } 
     
    input[type="checkbox"]:disabled+span { 
     
        color: #ddd; 
     
    } 
     
    input[type="checkbox"]:checked+span:before { 
     
        content: "\2714"; 
     
        color: #000; 
     
    } 
     
    input[type="checkbox"]:disabled:checked+span:before { 
     
        content: "\2714"; 
     
        color: #ddd; 
     
    } 
     
    input[type="checkbox"]:disabled+span:before { 
     
        border: 1px solid #ddd; 
     
    } 
     
    input[type="radio"]+span:before { 
     
        width: 16px; 
     
        height: 16px; 
     
        border: 1px solid #000; 
     
        content: "."; 
     
        color: transparent; 
     
        display: inline-block; 
     
        font-size: 13px; 
     
        font-weight: bold; 
     
        margin-right: 5px; 
     
        border-radius: 8px; 
     
        text-align: center; 
     
        /* new code notice me! */ 
     
        display: inline-flex; 
     
        align-items: center; 
     
        justify-content: center; 
     
    } 
     
    input[type="radio"]:disabled+span { 
     
        color: #ddd; 
     
    } 
     
    /* \25cf is the code for BLACK CIRCLE */ 
     
    input[type="radio"]:checked+span:before { 
     
        content: "\25cf"; 
     
        color: #000; 
     
    } 
     
    input[type="radio"]:disabled:checked+span:before { 
     
        content: "\25cf"; 
     
        color: #ddd; 
     
    } 
     
    input[type="radio"]:disabled+span:before { 
     
        border: 1px solid #ddd; 
     
    }
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/> 
     
    <div class="container"> 
     
        <div class="checkbox"> 
     
        <label> 
     
         <input type="checkbox" value="" checked> 
     
         <span>Option one is this and that&mdash;be sure to include why it's greatOption one is this and that&mdash;be sure to include why it's greatOption one is this and that&mdash;be sure to include why it's great</span> 
     
        </label> 
     
        </div> 
     
        <div class="checkbox"> 
     
        <label> 
     
         <input type="checkbox" value=""> 
     
         <span>Option one is this and that&mdash;be sure to include why it's great</span> 
     
        </label> 
     
        </div> 
     
        <div class="checkbox"> 
     
        <label> 
     
         <input type="checkbox" value="" disabled> 
     
         <span>Option one is this and that&mdash;be sure to include why it's great</span> 
     
        </label> 
     
        </div> 
     
        <div class="checkbox"> 
     
        <label> 
     
         <input type="checkbox" value="" disabled checked> 
     
         <span>Option one is this and that&mdash;be sure to include why it's great</span> 
     
        </label> 
     
        </div> 
     
    
     
        <div class="radio"> 
     
        <label> 
     
         <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1"> 
     
         <span>Option one is this and that&mdash;be sure to include why it's great</span> 
     
        </label> 
     
        <label> 
     
         <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked> 
     
         <span>Option one is this and that&mdash;be sure to include why it's great</span> 
     
        </label> 
     
        <label> 
     
         <input type="radio" name="optionsRadios2" id="optionsRadios1" value="option1" disabled> 
     
         <span>Option one is this and that&mdash;be sure to include why it's great</span> 
     
        </label> 
     
        <label> 
     
         <input type="radio" name="optionsRadios2" id="optionsRadios1" value="option1" checked disabled> 
     
         <span>Option one is this and that&mdash;be sure to include why it's great</span> 
     
        </label> 
     
        </div> 
     
    </div>

    的Flexbox的線;

    • display:inline-flex;
    • align-items:center;
    • justify-content:center;

    他們的意思是; - 我內心的東西應該使用flexbox, - 它們應該垂直居中, - 它們應該水平居中。

    我希望你覺得這有幫助:-)