Search code examples
htmlcssuser-interface

Changing card size in CSS


I have a bunch of cards on my page, i am having a hard time getting them to the same size. I am using Materialize CSS.This is how they are now How do i get them to the same size?

``<div class="valign-wrapper">
      <div class="container">
        <div class="row">
          <div class="col s12 m3">
            <div class="card">
              <div class="card-image">
                <img src="img/4.jpg" class="responsive-img">
              </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 class="col s12 m3">
            <div class="card">
              <div class="card-image">
                <img src="img/4.jpg" class="responsive-img">
              </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 class="col s12 m3">
            <div class="card">
              <div class="card-image">
                <img src="img/4.jpg" class="responsive-img">
              </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 class="col s12 m3">
            <div class="card">
              <div class="card-image">
                <img src="img/blogo.jpg" class="responsive-img">
                <span class="card-title black-text">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>
      </div>
    </div> ``

This is what my main index.html file looks like? And how would i fix the issue for the future. Thank You


Solution

  • Scale the images as background.

    <div class="card-image" style="background-image: url('img/4.jpg');"></div>
    

    In Css

    .card-image {
      background-repeat: no-repeat;
      background-position: 50% 50%;
      background-size: cover;
      width: 300px;
      height: 300px;
    }