Search code examples
htmlcssspiceworks

I cant get a button to link to sending an email


I am making a meet the staff page for our help desk. Even with everything looking good i am really struggling to make the contact button clickable to send an email. i can easily add a linkable option to email but that looks tacky. i have a feeling its as esy as moving my a tag around but it doesnt seem to work for me where ever I place it im not a very experienced code writer the way it is.

<style type="text/css">/* Three columns side by side */
.column {
  float: left;
  width: 33.3%;
  margin-bottom: 16px;
  padding: 0 8px;
}

/* Display the columns below each other instead of side by side on small screens */
@media screen and (max-width: 650px) {
  .column {
    width: 100%;
    display: block;
  }
}

/* Add some shadows to create a card effect */
.card {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}

/* Some left and right padding inside the container */
.container {
  padding: 0 16px;
}

/* Clear floats */
.container::after, .row::after {
  content: "";
  clear: both;
  display: table;
}

.title {
  color: grey;
}

.button {
  border: none;
  outline: 0;
  display: inline-block;
  padding: 8px;
  color: white;
  background-color: #000;
  text-align: center;
  cursor: pointer;
  width: 100%;
}

.button:hover {
  background-color: #555;
}
</style>
<div class="row">
<div class="column">
<div class="card"><img alt="Amy" src="img1.jpg" style="width:100%" />
<div class="container">
<h2>Amy</h2>

<p class="title">IT Manager</p>

<p>Some text that describes me lorem ipsum ipsum lorem.</p>

<p><a href="mailto:amyh@.org?subject=%5B%20Spiceworks%20%5D%20-">amyh@.org</a></p>

<p><button class="button">Contact</button></p>
</div>
</div>
</div>

<div class="column">
<div class="card"><img alt="Vincent" src="https://ibb.co/N6VjMjD" style="width:100%" />
<div class="container">
<h2>Vincent</h2>

<p class="title">IT Specialist</p>

<p>Some text that describes me lorem ipsum ipsum lorem.</p>

<p><a href="mailto:vincentw@?subject=%5B%20Spiceworks%20%5D%20%-">vincentw@</a></p>

<p><button class="button">Contact</button></p>
</div>
</div>
</div>
</div>


Solution

  • I suggest using CSS to style your <a> elements like you have the <button> elements styled.
    Something like this:

    <a href="mailto..." class="button">Contact</a>
    
    .button {
      display: block;
      padding: 8px;
      color: white;
      background-color: #000;
      text-align: center;
      text-decoration:none;
    }
    

    Here's a demonstration:

    /* Three columns side by side */
    
    .column {
      float: left;
      width: 33.3%;
      margin-bottom: 16px;
      padding: 0 8px;
    }
    
    
    /* Display the columns below each other instead of side by side on small screens */
    
    @media screen and (max-width: 650px) {
      .column {
        width: 100%;
        display: block;
      }
    }
    
    
    /* Add some shadows to create a card effect */
    
    .card {
      box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
    }
    
    
    /* Some left and right padding inside the container */
    
    .container {
      padding: 0 16px;
    }
    
    
    /* Clear floats */
    
    .container::after,
    .row::after {
      content: "";
      clear: both;
      display: table;
    }
    
    .title {
      color: grey;
    }
    
    .button {
      display: block;
      padding: 8px;
      color: white;
      background-color: #000;
      text-align: center;
      text-decoration: none;
    }
    
    .button:hover {
      background-color: #555;
    }
    <div class="row">
    
      <div class="column">
        <div class="card"><img alt="Amy" src="img1.jpg" style="width:100%" />
          <div class="container">
            <h2>Amy</h2>
            <p class="title">IT Manager</p>
            <p>Some text that describes me lorem ipsum ipsum lorem.</p>
            <p><a href="mailto:amyh@.org?subject=%5B%20Spiceworks%20%5D%20-" class="button">Contact</a></p>
          </div>
        </div>
      </div>
    
      <div class="column">
        <div class="card"><img alt="Vincent" src="https://ibb.co/N6VjMjD" style="width:100%" />
          <div class="container">
            <h2>Vincent</h2>
            <p class="title">IT Specialist</p>
            <p>Some text that describes me lorem ipsum ipsum lorem.</p>
            <p><a href="mailto:vincentw@?subject=%5B%20Spiceworks%20%5D%20%-" class="button">Contact</a></p>
          </div>
        </div>
      </div>
    
    </div>