Shunjid Rahman
Shunjid Rahman

Reputation: 419

Materialize CSS: Change horizontal cards into vertical cards in mobile

I have a material design card which is initially horizontal in desktop view. The problem is I have huge amount of text in the card-content. So, In mobile the image in the left of the horizontal card remains small and the large text expands the card which seems weird.

<div class="card horizontal">
    <div class="card-image">
      <img src="src/lib/svg/undraw_science_fqhl.png">
    </div>
    <div class="card-stacked">
      <div class="card-content">
       <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>
    </div>
    <div class="card-action">
     <a href="#">This is a link</a>
    </div>
  </div>
</div>

enter image description here

What I want is to make this horizontal is to change into vertical card in mobile like this:

enter image description here

How can I solve this problem?

Upvotes: 1

Views: 1562

Answers (1)

Abhishek Pakhare
Abhishek Pakhare

Reputation: 494

You need to use materialize grid with the card:

Following is your code solution: Code

Materialize card documentation

<div class="row">
    <div class="col s12 m7">
        <div class="card">
            <div class="card-image">
                <img src="images/sample-1.jpg">
                <span class="card-title">Card Title</span>
            </div>
            <div class="card-content">
                <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>
            </div>
        </div>
    </div>
</div>

Upvotes: 2

Related Questions