1

I have created a layout in which there are buttons with text.

What I am trying to accomplish is to get the flexbox to work properly on IE and figure out how to get the text to align at the top of each.

I tried vertical-align: top; with no luck:

Text aligned at top enter image description here

.flexbox {
  width: 100%;
  table-layout: fixed;
}
.flexbox tr {
  display: flex;
}
.flexbox tr td {
  flex: 1;
  display: flex;
}
button {
  flex: 1;
}
<table class=flexbox>
  <tr>
    <td>
      <button>Hello there my name is bob and this is a test Hello there my name is bob and this is a test Hello there my name is bob and this is a test</button>
      <td style="vertical-align:top;">
        <button>B</button>
        <td>
          <button>C</button>
          <td>
            <button>D</button>
            <td>
              <button>E</button>
              <td>
                <button>GF</button>
              </td>
  </tr>
</table>

http://jsfiddle.net/tXS6w/443/

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
user2402107
  • 913
  • 5
  • 22
  • 43

2 Answers2

1

Flexbox doesn't play nice with the button element. In fact, button doesn't even recognize flex properties in some browsers.

Here's an alternative that may work for you. It's pure CSS, responsive and works across browsers (tested on Chrome, FF and IE11). Also, no heights needed.

.flexbox {
  display: flex;
}
.flexbox > section {
  flex: 1;
  display: flex;
  text-align: center;
  margin: 10px;
  min-width: 50px;
  border: 1px solid #777;
  background: linear-gradient(to bottom, #fafafa 0%, #ddd 100%);
}
.flexbox > section > a {
  flex: 1;
  padding: 2px 5px;
  color: black;
  text-decoration: none;
}
.flexbox > section:hover {
  background: linear-gradient(to bottom, #f1f1f1 0%, #d1d1d1 100%);
}
<div class="flexbox">
  <section>
    <a href="javascript:void(0)">
      Hello there my name is bob and this is a test Hello there my name
      is bob and this is a test Hello there my name is bob and this is a
      test
    </a>
  </section>
  <section>
    <a href="javascript:void(0)">B</a>
  </section>
  <section>
    <a href="javascript:void(0)">C</a>
  </section>
  <section>
    <a href="javascript:void(0)">D</a>
  </section>
  <section>
    <a href="javascript:void(0)">E</a>
  </section>
  <section>
    <a href="javascript:void(0)">GF</a>
  </section>
</div>

jsFiddle

Community
  • 1
  • 1
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
0

Change all your buttons, except the ones from the first column, for example:

<button>B</button>

To have a span wrapping its content text:

<button><span>B</span></button>

Now you can set the span to fill the button's space as you need:

button > span {
  position: absolute;
  top: 3px;
  left: 0px;
  right: 0px;
  bottom: 3px;
}

Don't forget to position button as relative:

button {
  flex: 1;
  position: relative;
}

Also, as a side note, it is a good practice to always indent your html and close the tags properly (in this case, the tds' closing tags were missing).

See also a working responsive Fiddle here.

falsarella
  • 12,217
  • 9
  • 69
  • 115