html - CSS:输入复选框和单选按钮外观

标签 html css twitter-bootstrap

我正在尝试修复带有刻度线的复选框和带有句点的 radio 。

  1. 在未检查状态和内容:“\2714”检查状态下切换内容:“”我遇到了闪烁。所以我使颜色透明。对吗?

  2. 刻度线与框不完全吻合。如何只改变那个刻度线?

  3. 如果句子被分成几行,正方形和文本落在相同的边距上。如果两者都应该在单独的 block 中,我该怎么办?

  4. 单选按钮上的句点 (.) 非常小,可以看到。如果我增加字体大小,它就会与文本不对齐。

我也复制了 bootstrap 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>

最佳答案

  1. 透明而不是内容“”

这是正确的做法!它甚至更好。一切正常


  1. 适合刻度线

当它是关于字体时,不保证在所有浏览器中显示相同和真实,我只是更喜欢复选框的背景图像,png 图像

如果您有移动端用户,请注意您的元素(tick 和 ball)中的所有内容都可能发生变化 plain text replaced with android emoticons


  1. 单独的 block

只有 2 列的表格可能是最快的解决方案。


  1. radio

换个字吧,我给的是“●”或“•” 然而最好的方法是 background-image

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

关于html - CSS:输入复选框和单选按钮外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40415165/

相关文章:

jquery - 关闭其内容上的滑动到顶部 Accordion

html - 调整菜单之间的差距

html - 顺风 : equal height columns

javascript - 第二次选择菜单更改基于第一次选择菜单

jquery - 由于 JQuery DataTable 格式,Bootstrap 标签和字段对齐不起作用

HTML 文本格式

html - 可调整大小的搜索框,右侧有图片

r - lmer 对象中使用的 bootstrap() 函数

javascript - Twitter Bootstrap 崩溃 : change display of toggle button

jquery - 数据目标上的导航栏折叠不会在点击时折叠/展开