skip to Main Content

I want to create cards with a picture at top, them a paragraph and them a "more info" button, one next to each other, however the code it is not working.

how do I have it it is like this:

<div class>
   <IMG>
  <H3>
  <p>
  <button>

however I’m not sure on how to proceed in CSS, since when I select the class then H3 and P it is not doing nothing, and I’m not really sure on how to create the card

I have selected the class and then H3 and P however the changes are not reflecting on the websitec

2

Answers


  1. Here the example for your case:

      .card {
        display: block;
        width: 300px;
        height: max-content;
        background: lightblue;
        border: thin solid #000;
        padding: 10px;
      }
      .card img {
        max-width: 100%;
        margin-bottom: 10px;
      }
      .card h3 {
        font-size: 28px;
        font-weight: bold;
        margin: 0;
      }
      .card p {
        font-size: 18px;
        margin: 10px 0;
        padding: 0;
      }
      .card button {
        width: 100%;
        height: 40px;
        background: black;
        color: white;
      }
    <div class="card">
        <img src=".../image">
        <h3>Title</h3>
        <p>Body<p>
        <button>Submit</button>
    </div>
    Login or Signup to reply.
  2. Is this what you wanted? Something like this?

    body {
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: #f4f4f4;
    }
    
    .card-box {
      background-color: #fff;
      border-radius: 8px;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      overflow: hidden;
      width: 300px;
    }
    
    .card-box img {
      width: 100%;
      height: auto;
      display: block;
    }
    
    .card-box h3 {
      font-size: 1.8rem;
      margin: 10px;
    }
    
    .card-info {
      padding: 15px;
      background-color: #f0f0f0;
    }
    
    .card-info p {
      font-size: 1.1rem;
      color: #333;
      margin: 10px 0;
    }
    
    .card-info button {
      background-color: #007bff;
      color: white;
      border: none;
      padding: 8px 20px;
      border-radius: 4px;
      cursor: pointer;
    }
    
    .card-info button:hover {
      background-color: #0056b3;
    }
    <div class="card-box">
      <img src="https://lh3.googleusercontent.com/a/AAcHTte94RkylhN_rn3XxxKBbrv_debtVjcZjSNB7ekJgguAKRB3=k-s256">
      <h3>Arturo Rivera</h3>
      <div class="card-info">
        <p>Stack Overflow</p>
        <a target="_blank" rel="noopener noreferrer" href="https://stackoverflow.com/users/22365496/arturo-rivera">
          <button>More Info</button>
        </a>
      </div>
    </div>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search