Search code examples
materialize

MaterializeCSS card-action can only align links, not buttons with forms


I am using the first basic card example from http://materializecss.com/cards.html as a starting point. The card-action div contains two links that render beautifully.

Now I want to add a new card action that doesn't just open a link but performs an action. This could probably be done using a standard link with an tag as well but since I'm using Rails my standard way is that this action becomes a button with a form around it. It looks like this now:

<div class="row">
    <div class="col s12 m6">
      <div class="card blue-grey darken-1">
        <div class="card-content white-text">
          <span class="card-title">Card Title</span>
          <p>I am a very simple card. I am good at containing small bits of information.
          I am convenient because I require little markup to use effectively.</p>
        </div>
        <div class="card-action">
          <a href="#">This is a link</a>
          <a href="#">This is a link</a>
          <form>
            <a class="waves-effect waves-light btn">button</a>
          </form>              
        </div>
      </div>
    </div>
  </div>

I would have expected that the button is nicely aligned with the two existing links, in one row at the bottom of the card. But what actually happens is that the button appears in the line below.

How can I align a button with a form together with standard HTML link tags in one row?

UPDATE: here is a JSFiddle with the code above: https://jsfiddle.net/hendrikbeck/zq1pv3y6/


Solution

  • You just need to add display: inline to your form tag.

    See the updated JSFiddle : https://jsfiddle.net/zq1pv3y6/2/