Fanmade
Fanmade

Reputation: 306

Limit width on Bootstrap input-group

I'm struggling with a problem for several days now and I couldn't find a solution yet, even though I've tried myself with different approaches, searched google and the mighty stackoverlow for hours.

The set-up: I've got a panel with two list-groups next to each other, where relations can be managed. On the left are the linked items, on the right all available items that are not linked yet (featuring a pagination and all). The js-logic is working flawless. Clicking on a question-mark does display details for the item. Clicking on a plus moves an item to the left list, clicking on an "x" moves it back to the right. Of course the icons are properly switched, too.

The problem: The items are user-generated and the form is used both on big and small screens (used bootstrap for that reason). Some of the items do have a rather long name, limiting the users to keep it short is not an option here. If the text is too long, it just breaks out of the layout.

What I tried so far: Since the input-groups work with simulating table-elements, I've tried several approaches with table-layout:fixed;, but that doesn't seem to work if it's not really a table. Then I tried several approaches with containing different elements in div-containers and giving them percentual sizes. It never worked. Now I'm experimenting with cutting the text server-side, but that looks stupid if the screen is wide enough and the text is cut anyway.

Does someone smarter than me have a solution that makes overflow:hidden; and text-overflow:ellipis; work on those elements?

Here is a (very cleaned-up) fiddle to work with: https://jsfiddle.net/Fanmade/9vf8xvuL/

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="panel panel-default">
  <div class="panel-body">
    <div class="row">
      <div class="col-md-6">
        <ul class="list-group" id="left">
          <li class="list-group-item">
            <h4 class="text-center">Header Left</h4>
          </li>
          <li class="list-group-item">
            <div class="input-group">
              <a href="#" class="btn input-group-addon info-button">
                <i class="fa fa-question-circle-o fa-lg"></i>
              </a>
              <button class="btn btn-default form-control" type=button>
                Element 1
              </button>
              <a href="#" class="btn switch btn-remove input-group-addon">
                <i class="fa fa-times fa-lg"></i>
              </a>
            </div>
          </li>
           <li class="list-group-item">
            <div class="input-group">
              <a href="#" class="btn input-group-addon info-button">
                <i class="fa fa-question-circle-o fa-lg"></i>
              </a>
              <button class="btn btn-default form-control" type=button>
                Element 2
              </button>
              <a href="#" class="btn switch btn-remove input-group-addon">
                <i class="fa fa-times fa-lg"></i>
              </a>
            </div>
          </li>
           <li class="list-group-item">
            <div class="input-group">
              <a href="#" class="btn input-group-addon info-button">
                <i class="fa fa-question-circle-o fa-lg"></i>
              </a>
              <button class="btn btn-default form-control" type=button>
                Element 3
              </button>
              <a href="#" class="btn switch btn-remove input-group-addon">
                <i class="fa fa-times fa-lg"></i>
              </a>
            </div>
          </li>
        </ul>
      </div>
      <div class="col-md-6">
        <ul class="list-group" id="left">
          <li class="list-group-item">
            <h4 class="text-center">Header Right</h4>
          </li>
          <li class="list-group-item">
            <div class="input-group">
              <a href="#" class="btn input-group-addon info-button">
                <i class="fa fa-plus fa-lg"></i>
              </a>
              <button class="btn btn-default form-control" type=button>
                Element 4
              </button>
              <a href="#" class="btn switch btn-remove input-group-addon">
                <i class="fa fa-question-circle-o fa-lg"></i>
              </a>
            </div>
          </li>
           <li class="list-group-item">
            <div class="input-group">
              <a href="#" class="btn input-group-addon info-button">
                <i class="fa fa-plus fa-lg"></i>
              </a>
              <button class="btn btn-default form-control" type=button>
                Element 5 just has a really long text and I don't want to cut it when there is enough space on wide screens
              </button>
              <a href="#" class="btn switch btn-remove input-group-addon">
                <i class="fa fa-question-circle-o fa-lg"></i>
              </a>
            </div>
          </li>
           <li class="list-group-item">
            <div class="input-group">
              <a href="#" class="btn input-group-addon info-button">
                <i class="fa fa-plus fa-lg"></i>
              </a>
              <button class="btn btn-default form-control" type=button>
                Element 6
              </button>
              <a href="#" class="btn switch btn-remove input-group-addon">
                <i class="fa fa-question-circle-o fa-lg"></i>
              </a>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>

Edit after the answers: Thank you both so much for the answer! I'm feeling so stupid right now. Of course the answer had to be so simple and I was just searching in the wrong direction.

Upvotes: 1

Views: 1098

Answers (2)

MSH
MSH

Reputation: 1287

It will work :

button { 
      white-space: normal !important; 
      height: auto !important; 
  }

Upvotes: 1

SESN
SESN

Reputation: 1283

The working fiddle is https://jsfiddle.net/sesn/y98pz4hj/1/ Here is your answer

button { white-space: normal !important; height: auto !important; }

Upvotes: 1

Related Questions