0

我想更改我的按钮,使它们看起来不像默认的灰色按钮。我已将此添加到我的 CSS 中以尝试使它们看起来不同:

.button {
border-top: 1px solid #2b2b2b;
background: #2b2b2b;
background: -webkit-gradient(linear, left top, left bottom, from(#262626), to(#2b2b2b));
background: -webkit-linear-gradient(top, #262626, #2b2b2b);
background: -moz-linear-gradient(top, #262626, #2b2b2b);
background: -ms-linear-gradient(top, #262626, #2b2b2b);
background: -o-linear-gradient(top, #262626, #2b2b2b);
padding: 7px 14px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;
-moz-box-shadow: rgba(0,0,0,1) 0 1px 0;
box-shadow: rgba(0,0,0,1) 0 1px 0;
text-shadow: rgba(0,0,0,.4) 0 1px 0;
color: white;
font-size: 16px;
font-family: 'Lucida Grande', Helvetica, Arial, Sans-Serif;
text-decoration: none;
vertical-align: middle;
}
.button:hover {
border-top-color: #303030;
background: #303030;
color: #ffffff;
}
.button:active {
border-top-color: #2b2b2b;
background: #2b2b2b;
}

这是我在页面上制作按钮的 html:

<button type="button" onClick="window.location.href='https://itunes.apple.com/gb/podcast/canon-slade-digital-leaders/id588207792'">Find our Podcasts on iTunes ⇒&lt;/button>

但由于某种原因,这些按钮看起来并没有什么不同。

我哪里做错了?:/

4

3 回答 3

2

不要使用:

.button {}

不带点使用:

button {}
于 2013-11-10T20:41:57.457 回答
2

您正在为课程 .button设置样式...button改为使用。jsFiddle 示例

更新的 CSS:

button {
    border-top: 1px solid #2b2b2b;
    background: #2b2b2b;
    background: -webkit-gradient(linear, left top, left bottom, from(#262626), to(#2b2b2b));
    background: -webkit-linear-gradient(top, #262626, #2b2b2b);
    background: -moz-linear-gradient(top, #262626, #2b2b2b);
    background: -ms-linear-gradient(top, #262626, #2b2b2b);
    background: -o-linear-gradient(top, #262626, #2b2b2b);
    padding: 7px 14px;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    -webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;
    -moz-box-shadow: rgba(0,0,0,1) 0 1px 0;
    box-shadow: rgba(0,0,0,1) 0 1px 0;
    text-shadow: rgba(0,0,0,.4) 0 1px 0;
    color: white;
    font-size: 16px;
    font-family: 'Lucida Grande', Helvetica, Arial, Sans-Serif;
    text-decoration: none;
    vertical-align: middle;
}
button:hover {
    border-top-color: #303030;
    background: #303030;
    color: #ffffff;
}
button:active {
    border-top-color: #2b2b2b;
    background: #2b2b2b;
}
于 2013-11-10T20:42:11.247 回答
0

这是我输入的代码

.container0 {
  position: center;
  width: 100%;
  max-width: 400px;
}  
.container0 .btn0 {
  position: absolute;
  top: 85%;
  left: 49.5%;
  transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  background-color: red;
  color: white;
  font-size: 16px;
  padding: 12px 24px;
  border: none;
  cursor: pointer;
  border-radius: 5px;
  text-align: center;
}

.container0 .btn0:hover {
  background-color: green;
}
<div class="container0">
  <button class="btn0">Add to cart</button>
</div>

此代码有效。请检查一下

于 2021-04-08T13:26:47.987 回答