在按钮链接中添加css

时间:2012-12-14 17:11:38

标签: css button

如何在按钮中添加链接样式。 所以,我有一个链接样式:

a:link {color:#FFFFFF;}
a:visited {color:#FFFFFF;}
a:hover {color:#FFFFFF;}
a:active {color:#FFFFFF;}

如何将此样式与此按钮css集成。

button {
text-decoration: none;
text-shadow: 0 1px 0 #000000;
font: bold 11px Helvetica, Arial, sans-serif;
color: #FFFFFF;
line-height: 17px;
height: 18px;
display: inline-block;
float: left;
margin: 5px;
padding: 5px 6px 4px 6px;
background: #F3F3F3;
border: solid 1px #D9D9D9;
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
 -webkit-transition: border-color .20s;
 -moz-transition: border-color .20s;
 -o-transition: border-color .20s;
 transition: border-color .20s;
height: 29px !important;
cursor: pointer;
}

3 个答案:

答案 0 :(得分:1)

如果你想将相同的样式应用于多个元素(和元素的类型),那么你应该使用类。

.link:link {color:#FFFFFF;}
.link:visited {color:#FFFFFF;}
.link:hover {color:#FFFFFF;}
.link:active {color:#FFFFFF;}

.button { all of your button styles }

然后在需要的时候一起使用它们:

<input type="button" class="link button" value="I'm a button" />

答案 1 :(得分:1)

使用button a:link, button a:hover, button a:visited, button a:active

但是在按钮内设置链接有什么意义呢?

答案 2 :(得分:0)

我不太了解这个问题,但也许这可以为你服务:

INPUT:hover {background: yellow;}
INPUT:focus {background: #FF99FF;}
INPUT:focus:hover {background: #99FF99;}

INPUT:focus:hover {
text-decoration: none;
text-shadow: 0 1px 0 #000000;
font: bold 11px Helvetica, Arial, sans-serif;
color: #FFFFFF;
line-height: 17px;
height: 18px;
display: inline-block;
float: left;
margin: 5px;
padding: 5px 6px 4px 6px;
background: #F3F3F3;
border: solid 1px #D9D9D9;
border-radius: 2px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
 -webkit-transition: border-color .20s;
 -moz-transition: border-color .20s;
 -o-transition: border-color .20s;
 transition: border-color .20s;
height: 29px !important;
cursor: pointer;

}