删除按钮周围的灰色框

时间:2017-08-07 12:05:25

标签: html css button

正如标题所示,我无法移除围绕我的按钮的灰色框。我尝试过使用outline: none但是没有用。

你可以在这里看到它(JSFiddle):



.btn-group {
  background: #4abdac;
  background-image: -webkit-linear-gradient(top, #4abdac, 4abdac);
  background-image: -moz-linear-gradient(top, #4abdac, 4abdac);
  background-image: -ms-linear-gradient(top, #4abdac, 4abdac);
  background-image: -o-linear-gradient(top, #4abdac, 4abdac);
  background-image: linear-gradient(to bottom, #4abdac, 4abdac);
  -webkit-border-radius: 33;
  -moz-border-radius: 33;
  border-radius: 33px;
  font-family: Arial;
  color: #000;
  font-size: 20px;
  padding: 10px 20px 10px 20px;
  text-decoration: none;
}

<div><button><a class="btn-group" style="color: #000;" href="www.example.com"><span style="color: #ffffff;">Example Text&nbsp;</span></a></button></div>
&#13;
&#13;
&#13;

6 个答案:

答案 0 :(得分:0)

只需删除button标记即可:

https://jsfiddle.net/Lsjgdt4d/

答案 1 :(得分:0)

只需用

替换您的代码
<style>
.btn-group {
  background: #4abdac;
  background-image: -webkit-linear-gradient(top, #4abdac, 4abdac);
  background-image: -moz-linear-gradient(top, #4abdac, 4abdac);
  background-image: -ms-linear-gradient(top, #4abdac, 4abdac);
  background-image: -o-linear-gradient(top, #4abdac, 4abdac);
  background-image: linear-gradient(to bottom, #4abdac, 4abdac);
  -webkit-border-radius: 33;
  -moz-border-radius: 33;
  border-radius: 33px;
  font-family: Arial;
  color: #000;
  font-size: 20px;
  padding: 10px 20px 10px 20px;
  text-decoration: none;
}
</style>
<div>
<a class="btn-group" style="color: #000;" href="www.example.com"><span style="color: #ffffff;">Example Text&nbsp;</span></a></div>

答案 2 :(得分:0)

将此css与您的css代码一起放入

button{
  border: none;
  background: transparent;
}

答案 3 :(得分:0)

将样式应用于按钮元素并压缩div:

<a  style="color: #000;" href="www.example.com"><button class="btn-group">
<span style="color: #ffffff;">Example Text&nbsp;</span></button></a>

答案 4 :(得分:0)

在你的问题中,你不会删除按钮的默认样式,这就是你获得灰色背景的原因,你可以用这种风格删除它

button {
   border:none;
   background-color:transperant;
   outline:none;
}

然后你不需要在按钮内使用锚标记就像这样调用

&#13;
&#13;
.btn-group {
  background: #4abdac;
  background-image: -webkit-linear-gradient(top, #4abdac, 4abdac);
  background-image: -moz-linear-gradient(top, #4abdac, 4abdac);
  background-image: -ms-linear-gradient(top, #4abdac, 4abdac);
  background-image: -o-linear-gradient(top, #4abdac, 4abdac);
  background-image: linear-gradient(to bottom, #4abdac, 4abdac);
  -webkit-border-radius: 33;
  -moz-border-radius: 33;
  border-radius: 33px;
  font-family: Arial;
  color: #fff;
  font-size: 20px;
  padding: 10px 20px 10px 20px;
  text-decoration: none;
  border:none;
}
&#13;
<div>
<button class="btn-group" onclick="window.location.href='www.example.com'">Example Text</button>
</div>
&#13;
&#13;
&#13;

答案 5 :(得分:0)

删除按钮标记并将样式显示:inline-block添加到标记。因为标签是内联元素。我们必须将块元素集样式更改为display:inline-block。

&#13;
&#13;
.btn-group {
  background: #4abdac;
  background-image: -webkit-linear-gradient(top, #4abdac, 4abdac);
  background-image: -moz-linear-gradient(top, #4abdac, 4abdac);
  background-image: -ms-linear-gradient(top, #4abdac, 4abdac);
  background-image: -o-linear-gradient(top, #4abdac, 4abdac);
  background-image: linear-gradient(to bottom, #4abdac, 4abdac);
  -webkit-border-radius: 33;
  -moz-border-radius: 33;
  border-radius: 33px;
  font-family: Arial;
  color: #000;
  font-size: 20px;
  padding: 10px 20px 10px 20px;
  text-decoration: none;
  margin-top:10px;
  display:inline-block;
}
&#13;
<div><a class="btn-group" style="color: #000;" href="www.example.com"><span style="color: #ffffff;">Example Text&nbsp;</span></a></div>
&#13;
&#13;
&#13;