CSS 如何从 f.label 中删除粗体
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20127591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove Bold from f.label
提问by kamusett
I'm stylizing a webpage developed on Rails.
我正在设计一个在 Rails 上开发的网页。
So, I have a form with the checkbox of password remember. The problem Is it is always on bold and I can't change it. I've changed successfully the font-style, to italic, the color, but I couldn't remove the bold that was set as default (I guess).
所以,我有一个带有密码记住复选框的表单。问题是它总是以粗体显示,我无法更改它。我已经成功地将字体样式更改为斜体,颜色,但我无法删除设置为默认值的粗体(我猜)。
Below my code:
在我的代码下面:
<% if devise_mapping.rememberable? -%>
<div class="remember_forgot_top remember_me_position"><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
<% end -%>
Someone knows how to remove the bold and how to stylize the label?
有人知道如何去除粗体以及如何对标签进行样式化吗?
PS: I'm using twitter bootstrap.
PS:我正在使用推特引导程序。
回答by kamusett
I fixed this problem overriding the label
我解决了这个问题,覆盖了标签
label {
font-weight: normal !important;
}
Thanks to @vucko who gave me help.
感谢@vucko 给了我帮助。
回答by Jussi Hirvi
As I only sometimes want a non-bold label text, I solved it by using a css class in the label helper:
由于我有时只想要一个非粗体的标签文本,我通过在标签助手中使用一个 css 类来解决它:
<%= label :model, :fieldname, class: "not-bold" %>
And in the stylesheet:
在样式表中:
.not-bold {font-weight:normal !important;}
回答by Neil Loftin
the question is a bit old, but I just stumbled across this myself while updating an old 3.x bootstrap site to 4.x; bootstrap.min.css has styling for labels to set to 700 font weight. it does not appear to be present in bootstrap 4.x; overwriting the label css with !important after calling bootstrap works, as would using a higher degree of specificity (identifier, multiple classes, etc) on css for that element. My problem is solved by undoing this action, or namely, putting the bold styling back on these labels that have lost their boldness in our upgrade.
这个问题有点老了,但我自己在将旧的 3.x 引导站点更新到 4.x 时偶然发现了这个问题;bootstrap.min.css 将标签样式设置为 700 字体粗细。它似乎不存在于 bootstrap 4.x 中;在调用 bootstrap 工作后用 !important 覆盖标签 css,就像在该元素的 css 上使用更高程度的特异性(标识符、多个类等)一样。我的问题是通过撤消此操作来解决的,即,将粗体样式重新放在这些在我们升级中失去了粗体的标签上。