【问题标题】:Styling angular-ui-bootstrap checkbox (label)样式化 angular-ui-bootstrap 复选框(标签)
【发布时间】:2015-06-09 22:13:57
【问题描述】:

我在 stackoverflow link 上发现了这种很酷的风格,但我不知道如何将它应用到来自 angular-ui 的 chekcbox,它们是标签。

我尝试将它们添加为类,效果发生了变化,但活动的类继续搞砸一切,它们看起来很奇怪。

【问题讨论】:

  • 你能把你的代码贴在这里吗...我的意思是到目前为止你到底尝试了什么。

标签: css twitter-bootstrap angular-ui


【解决方案1】:

这里是工作 plunkr...http://plnkr.co/edit/6CFc73JZTWujUQWnTrWr?p=preview

基本上只需添加这个 CSS,

.btn-primary {
  background: url('http://lorempixel.com/output/people-q-c-50-50-1.jpg') no-repeat;
  height: 50px;
  width: 50px;
  display: block;
  border-radius: 50%;
  position: relative;
  transition: all 0.4s;
  border: solid 5px #FFF;
  box-shadow: 0 0 1px #FFF; /* Soften the jagged edge */
}
/* Provide a border when hovered and when the checkbox before it is checked */
.btn-primary:hover,
.btn-primary.active,
.btn-primary:focus{
  border: solid 5px #F00;
  box-shadow: 0 0 1px #F00; /* Soften the jagged edge */
}
/* 
- Create a pseudo element :after when checked and provide a tick
- Center the content
*/
.btn-primary.active::after {
  content: '\2714'; /*content is required, though it can be empty - content: '';*/
  display: block;
  height: 1.5em;
  width: 1em;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  margin: auto;
  color: #F00;
}
.btn-primary.active{
  background: url('http://lorempixel.com/output/people-q-c-50-50-1.jpg') no-repeat;
}

而在 HTML 中,

<button type="button" class="btn btn-primary" ng-model="singleModel" btn-checkbox btn-checkbox-true="1" btn-checkbox-false="0"></button>

【讨论】:

  • 但是现在所有的“btn-primary”都是这样的,有什么办法可以改变吗?
  • 只需将一个类添加到您的按钮,例如my-custom-btn `,它看起来像&lt;button type="button" class="btn btn-primary my-custom-btn" ng-model="singleModel" btn-checkbox btn-checkbox-true="1" btn-checkbox-false="0"&gt;&lt;/button&gt; 现在只需将上述CSS 中的所有btn-primary 替换为类my-custom-btn
  • 感谢您的回复,但我设法让它工作并更换了大部分。
猜你喜欢
  • 2018-11-13
  • 2019-07-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-07
相关资源
最近更新 更多