Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Word-wrap not working in bootstrap 3

I am trying to create a button having some text over it. But the text is not wrapping on the button. Here is what i have done.

<div class="form-group">
  <div class="col-md-6 col-sm-6 col-xs-6">
    <input type="radio" id="1" class="hidden">
    <label for="1" class="btn btn-info btn-preference  pull-right">Stability</label> 
  </div>
  <div class="col-md-6 col-sm-6 col-xs-6">
    <input type="radio" id="1" class="hidden">
    <label for="1" class="btn btn-primary btn-preference text-center">
      <span class="break-wo">Freedom and Risk</span>                                                        
    </label> 
  </div>
</div>

Here is the Link for bootfly

like image 867
Shahzeb Khan Avatar asked Jan 24 '14 11:01

Shahzeb Khan


People also ask

What is Bootstrap wrap?

Introduction of Wrap Bootstrap The bootstrap wrap is used to cover or wrap the flex items in a flex container.It has main three classes which is.flex-wrap,.flex-nowrap,.flex-wrap-reverse.First is.flex-wrap for wrapping flax content. Second is.flex-nowrap for no wrapping in flex container.

How to use word wrap in CSS?

Word-wrap is supported in IE 5.5+, Firefox 3.5+, and WebKit browsers such as Chrome and Safari. CSS: Word-Wrap Property (view demo) You can specify either normalor break-wordvalue with the word-wrap property. Normalmeans the text will extend the boundaries of the box. Break-wordmeans the text will wrap to next line.

What is word-wrap and how do I use it?

For example, you can use it to prevent text extending out the box and breaking the layout. This commonly happens when you have a long URL in the sidebar or comment list. Word-wrap is supported in IE 5.5+, Firefox 3.5+, and WebKit browsers such as Chrome and Safari.

Why does word-wrap break-word not work?

In fact, word-wrap:break-word sometimes does not properly if an element has no width determined, or it is determined with relative values (e.g. %). Reply wisadl Dec 10, 2010 at 4:05 am


2 Answers

It's not the wrap, it's white-space: nowrap; which is preventing the text to wrap when used .btn which contains white-space: nowrap; so use white-space: normal;

label[for="1"].btn {
    white-space: normal;
}

Demo


Note: Your ID value is invalid, you cannot start an id with a number

like image 83
Mr. Alien Avatar answered Oct 23 '22 00:10

Mr. Alien


Have you tried adding white-space: normal; to your span class="break-wo"? This should help.

like image 28
Stephan Weinhold Avatar answered Oct 23 '22 00:10

Stephan Weinhold