- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
你好,我使用了使用超赞字体图标的复选框。我看起来不错,但我仍然需要能够更改框的背景(比如它只更改图标和文本。
我知道我必须在带有标签背景的这一行中添加它,但我不知道如何:
.checkboxes input[type="checkbox"]:checked + i + span,
input[type="checkbox"]:checked + i:before {
color: #2581BC;
}
这里有代码和 CSS。
谢谢。
<div class="row checkboxes">
<div class="col-lg-8">
<label for="check-one">
<input type="checkbox" name="check-one" id="check-one" value="checkone"/>
<i></i> <span>Checkbox 1</span>
</label>
<label for="check-two">
<input type="checkbox" name="check-two" id="check-two" value="check-two"/>
<i></i> <span>Checkbox 2</span>
</label>
</div>
</div>
CSS:
::-moz-selection {
background: white;
}
::selection { background: white; }
.checkboxes label {
display: block;
position: relative;
padding: 6px 2px 10px 20px;
line-height: 28px;
font-weight: normal;
cursor: pointer;
border: 1px solid #e6e7e8;
border-radius:4px;
background:#f6f6f6;
margin-top:16px;
-webkit-tap-highlight-color: transparent;
}
.checkboxes label i {
display: inline-block;
height: 28px;
position: relative;
top: 6px;
font-style: normal;
color: #ccc;
}
.checkboxes label span {
color: #2c3e50;
display: unset;
font-size: 16px;
line-height: 25px;
margin-left: 14px;
min-width: 256px;
}
.checkboxes input[type="radio"],input[type="checkbox"] { display: none; }
.checkboxes input[type="radio"] + i:before, input[type="checkbox"] + i:before {
font-family: 'FontAwesome';
font-size: 24px;
height: 25px;
width: 25px;
display: table;
}
.checkboxes input[type="radio"]:checked + i, input[type="checkbox"]:checked + i {
position: relative;
-webkit-animation: icon-beat 0.1s ease;
animation: icon-beat 0.1s ease;
}
.checkboxes input[type="radio"]:checked + i + span, input[type="checkbox"]:checked + i + span {
-webkit-transition: all 0.1s ease;
transition: all 0.1s ease;
}
.checkboxes input[type="radio"] + i:before { content: "\f10c"; }
.checkboxes input[type="radio"]:checked + i:before { content: "\f111"; }
.checkboxes input[type="radio"]:checked + i + span + label,input[type="radio"]:checked + i + label:before { color: rgba(245,245, 245); }
.checkboxes input[type="checkbox"] + i:before { content: "\f10c"; }
.checkboxes input[type="checkbox"]:checked + i:before { content: "\f05d"; }
.checkboxes input[type="checkbox"]:checked + i + span,
input[type="checkbox"]:checked + i:before { color: #2581BC; }
最佳答案
使用一些 jquery 代码,你可以这样实现它:
$('input[type="checkbox"]').click(function(){
var label = $('label[for='+this.id+']');
if($(this).is(":checked"))
label.addClass("labelselected");
else
label.removeClass("labelselected");
});
JsFiddle 演示:http://jsfiddle.net/dhtfyq25/1/
否则,仅使用 CSS 而不更改 html 是不可能的,因为您无法根据其子值选择父级(标签
)( 输入:选中
)
如果你稍微调整一下 html,那么你可以使用兄弟选择器并仅使用 CSS 实现背景更改:) 为此,你需要将 input
元素移动到标签上方,例如:
<input type="checkbox" name="check-one" id="check-one" value="checkone"/>
<label for="check-one">
<i></i> <span>Checkbox 1</span>
</label>
<input type="checkbox" name="check-two" id="check-two" value="check-two"/>
<label for="check-two">
<i></i> <span>Checkbox 2</span>
</label>
然后,添加这个 CSS:
input[type="checkbox"]:checked + label { background: red !important; }
JsFiddle 演示:http://jsfiddle.net/4pxfjvdv/1/
关于html - Fontawesome 的复选框改变背景颜色(仅 CSS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29171243/
我正在使用 vue.js 2 - 我在我的 App.vue 中添加了一些 mdi 图标,这会在我的项目中生成一个新错误 当我尝试为我的项目提供服务时,但出现如下错误 我还应用了一些命令,但它没有解决我
我们正在启动一个 Angular 6 元素并希望使用 Font Awesome 5.1。 Font Awesome 提供了两个 Node 包: @fortawesome/angular-fontawe
我有一个自定义 SVG 图标,我想将其添加到我的本地 fontawesome 库 (fontawesome-all.js),我根据此处提供的说明将其包含在我的项目资源文件夹中: https://fon
目前我有这个可以展开和折叠的 Accordion :https://jsfiddle.net/cliffeee/a5uxgkmt/15/ . 我想使用 fontawesome 为 Accordion
我正在尝试使用 Font Awesome 5.1.0 在 webpack 4. webpack配置文件的内容: const HtmlWebPackPlugin = require("html-webp
我正在使用 vue-cli。我对 vue 很陌生。我正在尝试更改选择标签右上角的箭头符号。我该怎么做?我尝试寻找解决方案,发现我需要使用 css。但是我们如何在 css 中使用 font-awesom
我在我的 asp.net mvc 项目中使用 fontawesome 4.5。我在控制台上遇到以下错误 我已经在我的字体文件夹中包含了字体 并在layout.cshtml中为fontwesome样式表
我正在尝试使用 HTML5 和 FontAwesome 制作网页。我的问题是:如果我包含一个 FontAwesome 图标,它会出现两次,并且两个副本会相互堆叠(参见此处:image) 我更改了一些
我在页面上的几个地方使用了 Font Awesome 图标,但是当我想在 CSS 中使用它时,它没有显示。我在这里遇到了很多问题,因为我看到其他人也有同样的问题,但没有一个解决方案对我有用: 我的 F
在 Font Awesome 我如何使用此代码:仅在鼠标悬停上工作? 最佳答案 除了覆盖类之外,您还可以创建另一个仅用于悬停的类: .fa-spin-hover:hover { -webkit-a
我用这个 post 来动态加载一些组件 import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; const te
我有一个关于 React 的项目,我需要将 FontAwesome 集成到其中。我找到官方library并按照自述文件中的说明安装它 $ npm i --save @fortawesome/fonta
我的任务是编写一个函数,从 JSON 链接获取比特币交易,使用按钮更改间隔,添加漂亮的向上/向下/线条箭头,具体取决于汇率是否上升/下降/没有变化,并将其显示在网站上。 我什么都有,除了fontawe
我想从 CDN 加载 Fontawesome,但我得到了 跨域请求失败。资源访问受到限制 我知道要解决此问题,应该添加 HTTP header ,但是有什么方法可以避免这样做吗? 我尝试更换'../f
Fontawesome 现在已升级到第 5 版,但我们的许多应用程序仍处于旧版本。我怎样才能找到带有他们的旧版本图标的 content (CSS 属性)列表? 最佳答案 进入图标页面。然后单击左上 A
我想从 CDN 加载 Fontawesome,但我得到了 跨源请求失败。资源访问受限 我知道要解决这个问题,应该添加一个 HTTP header ,但是有什么办法可以避免这样做吗? 我试过更换'../
我正在尝试在 OS X 上的 XeLaTex 中使用 FontAwesome。所以我按照此github中描述的步骤进行操作: 将其保存到您的项目文件夹中,命名为 fontawesome.sty 将\u
这个问题在这里已经有了答案: jquery .text doesn't render HTML elements into the DOM (3 个答案) 关闭 4 年前。 jquery 3.3.1
我正在尝试手动堆叠 Soundcloud 图标并将其显示在正方形上,就像 fa-facebook-square 一样,但我的 Soundcloud 图标是在广场下方创建的。 到目前为止,这是我的代码:
很长一段时间以来,一些 FontAwesome(最新版本)图标在我的元素中不起作用,例如 fa-hashtag,但还有一些其他图标也不起作用。已经在堆栈中检查了一些解决方案,但没有任何效果。 这里是如
我是一名优秀的程序员,十分优秀!