【问题标题】:How to change brightness in radio buttons using CSS in jQuery mobile如何在 jQuery mobile 中使用 CSS 更改单选按钮的亮度
【发布时间】:2019-11-10 06:11:17
【问题描述】:

我正在尝试使用 CSS 降低 jQuery mobile 中现有单选按钮的亮度(关闭时)。我在我的 html 文件中尝试了以下内容 -

    <style>
  .ui-grid-b .ui-block-b: flip-select.label{
  text-indent: 60%;
  }
  #flip-select{
  text-indent: 60%;
  }
  #radio-choice-h-2a:true{
  filter:brightness(50%);
  }
  .ui-radio .ui-btn.ui-radio-off:after {
  filter: brightness(50%);
  }
  </style>

这是 jQuery mobile 1.4.5 演示中收音机的 html 部分 -

    <div class="ui-grid-b">

  <div class="ui-block-a"><!--row 1 block a-->
    <!--radio button 1-->
    <fieldset id="radio-choice-h-2" data-role="controlgroup" data-type="horizontal" data-role="fieldcontain">
      <legend>NLED</legend>
      <input name="radio-choice-h-2" id="radio-choice-h-2a" value="on" checked="checked" type="radio">
      <label style="background-color: #ff0000" for="radio-choice-h-2a">ON</label>       

在我放入 CSS 内部样式元素后,我没有看到任何变化。我做错了什么吗?我注意到类似的posts。但我想对现有的单选按钮进行更改

这是为了在触摸屏上运行网页。

【问题讨论】:

  • 你的代码对我有用...
  • #radio-choice-h-2a:true - :true 应该是什么?不是我知道的伪类的一部分。这是由 jQuery Mobile 提供/实现的,还是……?
  • 我试图访问 id radio-choice-h-2a 的亮度,这只是我尝试过的事情之一,我认为真正的意思是 ON 状态。不是 jQuery Mobile,而是 CSS。

标签: html css jquery-mobile radio-button


【解决方案1】:

试试这个代码:如果你想降低亮度或改变单选按钮的颜色,你可以很容易地改变背景颜色。

.ui-grid-b{
  margin: 10px;
}

fieldset {
    position: relative;
    padding-left: 24px;
    margin-bottom: 12px;
    display: inline-block;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    margin-right: 40px;
}
fieldset input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

label:after {
  content: "";
    display: block;
    position: absolute;
    top: 50%;
    left: 4px;
    height: 15px;
    width: 15px;
    border: 1px solid #383838;
    border-radius: 50%;
}

label:before {
    content: "";
    position: absolute;
    display: none;
}
fieldset input:checked + label:before {
    display: block;
}
fieldset label:before {
 	top: 56%;
    left: 7px;
    width: 11px;
    display: none;
    height: 11px;
    border-radius: 50%;
    background: #d61722;
}
<div class="ui-grid-b">

  <div class="ui-block-a"><!--row 1 block a-->
    <!--radio button 1-->
    <fieldset id="radio-choice-h-2" data-role="controlgroup" data-type="horizontal" data-role="fieldcontain">
      <legend>NLED</legend>
      <input name="radio-choice-h-2" id="radio-choice-h-2a" value="on" checked="checked" type="radio">
      <label style="background-color: #ff0000" for="radio-choice-h-2a">ON</label> 
      </fieldset>
      </div>
      </div>

【讨论】:

  • 感谢您的建议,唯一不同的是#radio-choice-h-2{ filter: brightness(200%); }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-10
  • 1970-01-01
  • 2011-06-22
相关资源
最近更新 更多