Search code examples
htmlcssimageborder

CSS Border Issues with Picture Card/w Avatar and I Can't align card with form when 600px or Greater


I am trying to code the following image and text using CSS. I have tried several iterations of code but something always messes up. Here is the image and the following requirements for the finished product: Css Picture Card with Avatar and Text

Here is what I've done in HTML/CSS. This includes HTML/CSS for a form that accompanies this Picture Card and the reason I included all of it is because I'm new to coding and I'm not sure if I'm getting the CSS for the form and the picture card mixed up. I will include what my finished product looks like thus far:

fieldset {
    border: 0;
}

form {
    margin: 0 auto;
    width: 600px;
    padding: 1em;
    border: 1px solid #CCC;
    border-radius: 1 em;
    font-family: Arial, Helvetica, sans-serif;
}

form div+div {
    margin-top: 1em;
}

label {
    display: inline-block;
    width: 90px;
    text-align: right;
}

legend {
    border-bottom: 1px solid black;
}

input, textarea {
    font-family: Arial, Helvetica, sans-serif;
    width: 425px;
    box-sizing: border-box;
    border: 1px solid #999;
}

textarea {
    vertical-align: top;
    height: 5em;
}

select {
    font-family: Arial, Helvetica, sans-serif;
    width: 425px;
}

button {
    margin-left: .5em;
}

.card {
    display: grid;
    grid-gap: 20px;
    width: 344px;
    box-shadow: 0px 4px 8px rbga(0, 0, 0, 0.2);
    transition: box-shadow;
}

.card:hover {
    box-shadow: 0px 2px 4px rgba(0, 0, 0, .3);
    transition: .75s;
}

.cardtext {
    display: inline;
    grid-gap: 20px;
}

.image1 {
    height: 194px;
}

.h3 {
    font-size: 22px;
    color: #000;
}

.image2 {
    float: left;
    border-radius: 50%;
    margin: 0 1rem;
}

.secondary, .body_text {
    color: #232F34;
    flex-wrap: wrap;
}

.body-text {
    font-size: 11px;
    padding: 16px;
}

@media screen and (min-width: 600px) {
    form {
        width: 600px;
    }
    label {
        display: grid;
        margin: 0;
        text-align: left;
        width: 600px;
    }
    input, select, textarea {
        width: 600px;
    }
}

@media screen and (max-width: 600px) {
    form {
        width: auto;
    }
    label {
        display: grid;
        margin: 0;
        text-align: left;
        width: auto;
    }
    input, select, textarea {
        width: auto;
    }
}
<!DOCTYPE html>
<html lang="eng">

<head>
  <meta charset="UTF-8">
  <title>App Academy HTML/CSS Assessment</title>
  <link rel="stylesheet" href="site.css">
</head>

<body>
  <form action="/pets" method="post">
    <fieldset>
      <div>
        <label for="name">Name</label>
        <input type="text" id="name" name="pet_name">
      </div>

      <div>
        <label for="name">Type</label>
        <select id="type" name="pet_type">
          <option value="cat">Cat</option>
          <option value="dog">Dog</option>
          <option value="hamster">Hamster</option>
          <option value="other">Other</option>
          <option value="zebra">Zebra</option>
        </select>
      </div>

      <div>
        <label for="bio">Biography</label>
        <textarea id="bio" name="pet_bio"></textarea>
      </div>

      <div>
        <label for="owner_email">Owner's Email</label>
        <input type="email" id="owner-email" name="pet_owner_email">
      </div>

      <div>
        <div class="submit">
          <button type="submit" id="new-pet-submit-button">Create new pet
          </button>
        </div>

        <div>
          <button type="reset">Reset</button>
        </div>
      </div>
    </fieldset>
  </form>

  <div class="card">
    <div class="image1">
      <img src="images/desert.jpg" class="image1" alt="desert"></a>
    </div>

    <div class="header">
      <div class="image2">
        <img src="images/person-avatar.jpg" class="imagee" alt="person" </a>
      </div>

      <div class="cardtext">
        <h3>Title goes here</h3>
        <p class="secondary">Secondary text</p>
        <p class="bodytext">Greyhound divisively hello coldly wonderfully marginally far upon excluding.</p>
      </div>
    </div>
  </div>


</body>

</html>

Form with Picture Card and Text in Chrome Browser


Solution

  • Here you go! it's not exactly the way you wanted. but it's enough to get you going.

    .card {
        border-style: solid; border-color: #e9e9e9;
        display: grid;
        grid-gap: 20px;
        width: 344px;
        box-shadow: 0px 4px 8px rbga(0, 0, 0, 0.2);
        transition: box-shadow;
    }
    
    .card:hover {
        box-shadow: 0px 2px 4px rgba(0, 0, 0, .3);
        transition: .75s;
    }
    
    .cardtext {
        display: inline;
        grid-gap: 20px;
    }
    
    .image1 {
        width: 100%;
        height: 194px;
    }
    
    h3 {
        margin: auto;
        font-size: 22px;
        color: #000;
    }
    
    .image2 img {
        margin-left: 5%;
        float: left;
        width: 10%;
    }
    
    .secondary, .body_text {
        display: inline;
        color: #232F34;
        flex-wrap: wrap;
    }
    
    .bodytext {
        text-align: center;
    }
    
    .body-text {
        font-size: 11px;
        padding: 16px;
    }
      <div class="card">
        <div class="image1">
          <img src="https://image.shutterstock.com/image-photo/sunset-over-sand-dunes-desert-260nw-1384187327.jpg" class="image1" alt="desert">
        </div>
    
        <div class="header">
          <div class="image2">
            <img src="https://p.kindpng.com/picc/s/464-4644512_circle-avatar-picture-png-transparent-png.png" class="imagee" alt="person">
          </div>
    
          <div class="cardtext">
            <h3>Title goes here</h3>
            <p class="secondary">Secondary text</p>
            <p class="bodytext">Greyhound divisively hello coldly wonderfully marginally far upon excluding.</p>
          </div>
        </div>