HTML创建<a href...=""> with style

时间:2017-07-11 08:04:43

标签: html css href

I've created a link that looks like a button like this:

<a target='_blank' href="mailto:me@myemail.com?Subject=bla bla" style='background:#44ff22;color:#ffffff;font-size:15px;padding:8px 12px;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;text-decoration:none;'>Email Me</a>

the problem is that the clickable area is not the entire box (it's on the top third portion of the "button") so one might think its not working

How can I create the clickable rectangle area?

2 个答案:

答案 0 :(得分:2)

为什么要这么麻烦?只需将标签放在按钮旁边

即可
<a><button></button></a>

答案 1 :(得分:0)

display: blockdisplay: inline-block属性添加到您的样式中。

&#13;
&#13;
a {
  background:#44ff22;
  color:#ffffff;
  font-size:15px;
  padding:8px 12px;
  border-radius:3px;
  -moz-border-radius:3px;
  -webkit-border-radius:3px;
  text-decoration:none;
  
  display: block; /* Added */
}
&#13;
<a target='_blank' href="mailto:me@myemail.com?Subject=bla bla">Email Me</a>
&#13;
&#13;
&#13;

&#13;
&#13;
a {
  background:#44ff22;
  color:#ffffff;
  font-size:15px;
  padding:8px 12px;
  border-radius:3px;
  -moz-border-radius:3px;
  -webkit-border-radius:3px;
  text-decoration:none;
  
  display: inline-block; /* Added */
}
&#13;
<a target='_blank' href="mailto:me@myemail.com?Subject=bla bla">Email Me</a>
&#13;
&#13;
&#13;

相关问题