42

I'm stylizing a webpage developed on 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.

kamusett
  • 1,403
  • 1
  • 12
  • 22

4 Answers4

72

I fixed this problem overriding the label

label {
    font-weight: normal !important;
}

Thanks to @vucko who gave me help.

Peon
  • 7,902
  • 7
  • 59
  • 100
kamusett
  • 1,403
  • 1
  • 12
  • 22
  • 4
    I was able to fix it without the `!important`. I put this code after the `@import "bootstrap";`. – Powers Sep 29 '15 at 21:46
  • 5
    As @Powers alluded to - please avoid using `!important` if you don't have to! Someone else will want a label bold in another scenario, and you'll have started an `!important` war. Love, not war. – jbyrd Nov 01 '18 at 19:41
  • The accepted answer will be problem when I want to set font-weight again with JS/DOM. – Trần Hữu Hiền Sep 18 '20 at 08:45
4

As I only sometimes want a non-bold label text, I solved it by using a css class in the label helper:

<%= label :model, :fieldname, class: "not-bold" %>

And in the stylesheet:

.not-bold {font-weight:normal !important;}
Jussi Hirvi
  • 565
  • 3
  • 6
0

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.

0

Bootstrap v4.4.1

The accepted answer will be problem when I want to set font-weight again with JS/DOM.

If you notice debug css, you will see:

label:not(.form-check-label):not(.custom-file-label) {
    font-weight: 700;
}

So, add a class "form-check-label" into your tag, it will be not bold.

Trần Hữu Hiền
  • 872
  • 1
  • 9
  • 22