2016-11-04 62 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, - 它们应该垂直居中, - 它们应该水平居中。

    我希望你觉得这有帮助:-)