Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
239 views
in Technique[技术] by (71.8m points)

css - How do you put <a> tags here on my html code so that it doesn't affect it's background-color and color or text?

I wanted to put "a" tags around my "div class="button" but the thing is, when I put the "a" tags with href, the "a" tag is working, but at the same time it is replacing the background-color and color of the text with the color of Facebook. Please help me.

Here are the HTML codes:

footer {
  background-color: #000000;
  display: -ms-grid;
  display: grid;
  height: 100%;
  width: 100%;
  place-items: center;
}

footer p {
  color: #ffffff;
}

footer p .highlight {
  color: #00ffff;
}

.wrapper .button {
  display: inline-block;
  height: 50px;
  width: 50px;
  margin: 0 5px;
  overflow: hidden;
  background: #ffffff;
  border-radius: 50px;
  cursor: pointer;
  -webkit-box-shadow: 0 10px 10px rgba(0, 0, 0, 0.1);
          box-shadow: 0 10px 10px rgba(0, 0, 0, 0.1);
  -webkit-transition: all 0.3s ease-out;
  transition: all 0.3s ease-out;
}

.wrapper .button .icon {
  display: inline-block;
  text-align: center;
  height: 50px;
  width: 50px;
  border-radius: 50%;
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
  line-height: 50px;
  color: #000000;
  -webkit-transition: all 0.3s ease-out;
  transition: all 0.3s ease-out;
}

.wrapper .button .icon i {
  font-size: 25px;
  line-height: 50px;
  -webkit-transition: all 0.3s ease-out;
  transition: all 0.3s ease-out;
}

.wrapper .button span {
  font-size: 20px;
  font-weight: 500;
  line-height: 50px;
  margin-left: 10px;
}

.wrapper .button:hover {
  width: 200px;
}

.wrapper .button:nth-child(1):hover .icon {
  background: #4267b2;
}

.wrapper .button:nth-child(2):hover .icon {
  background: #1da1fe;
}

.wrapper .button:nth-child(3):hover .icon {
  background: radial-gradient(circle farthest-corner at 35% 90%, #fec564, transparent 50%), radial-gradient(circle farthest-corner at 0 140%, #fec564, transparent 50%), radial-gradient(ellipse farthest-corner at 0 -25%, #5258cf, transparent 50%), radial-gradient(ellipse farthest-corner at 20% -50%, #5258cf, transparent 50%), radial-gradient(ellipse farthest-corner at 100% 0, #893dc2, transparent 50%), radial-gradient(ellipse farthest-corner at 60% -20%, #893dc2, transparent 50%), radial-gradient(ellipse farthest-corner at 100% 100%, #d9317a, transparent), -webkit-gradient(linear, left top, left bottom, from(#6559ca), color-stop(30%, #bc318f), color-stop(50%, #e33f5f), color-stop(70%, #f77638), to(#fec66d));
  background: radial-gradient(circle farthest-corner at 35% 90%, #fec564, transparent 50%), radial-gradient(circle farthest-corner at 0 140%, #fec564, transparent 50%), radial-gradient(ellipse farthest-corner at 0 -25%, #5258cf, transparent 50%), radial-gradient(ellipse farthest-corner at 20% -50%, #5258cf, transparent 50%), radial-gradient(ellipse farthest-corner at 100% 0, #893dc2, transparent 50%), radial-gradient(ellipse farthest-corner at 60% -20%, #893dc2, transparent 50%), radial-gradient(ellipse farthest-corner at 100% 100%, #d9317a, transparent), linear-gradient(#6559ca, #bc318f 30%, #e33f5f 50%, #f77638 70%, #fec66d 100%);
}

.wrapper .button:nth-child(4):hover .icon {
  background: #ff0000;
}

.wrapper .button:hover .icon i {
  color: #ffffff;
}

.wrapper .button:nth-child(1) span {
  color: #4267b2;
}

.wrapper .button:nth-child(2) span {
  color: #1da1fe;
}

.wrapper .button:nth-child(3) span {
  color: #c32aa3;
}

.wrapper .button:nth-child(4) span {
  color: #ff0000;
}

.wrapper {
  margin-top: 20px;
}
<footer class="responsive">
  <div class="wrapper">
    <div class="button">
      <div class="icon">
        <i class="fab fa-facebook-f"></i>
      </div>
      <span>Facebook</span>
    </div>

    <div class="button">
      <div class="icon">
        <i class="fab fa-twitter"></i>
      </div>
      <span>Twitter</span>
    </div>

    <div class="button">
      <div class="icon">
        <i class="fab fa-instagram"></i>
      </div>
      <span>Instagram</span>
    </div>

    <div class="button">
      <div class="icon">
        <i class="fab fa-youtube"></i>
      </div>
      <span>YouTube</span>
    </div>
  </div>

  <p> Copyright &copy; <span class="highlight"> Tanikala </span> Music Ph. All Rights Reserved </p>
</footer>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you are not into design then you can use little javascript.

 <div class="button" onclick="redirectMe('https://instagram.com')">
        <div class="icon">
            <i class="fab fa-instagram"></i>
        </div>
        <span>Instagram</span>
</div>  

And in footer you can simply define the function redirectMe()

<script>function redirectMe(link){ window.location.href = "${link}"; } </script>  

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...