我正在编写一段代码,其中跨度嵌套在链接中,这适用于Chrome但不适用于FF或IE,任何想法?我也尝试了与span的嵌套链接,但也没有工作。我知道在锚内有一些关于跨度的规则但是用我当前的编码无法弄明白。 非常感谢
grid = [
['.', '.', '.', '.', '.', '.'],
['.', 'O', 'O', '.', '.', '.']
]

.button {
position: relative;
display: inline-block;
border-radius: 20px;
border: 2px solid #ffcc00;
background-color: #006534;
color: #FFFFFF;
text-align: center;
font-size: 16px;
padding: 9px;
width: 230px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
top: -40px;
left: -255px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
color: #FFFFFF;
}
.button span:after {
content: '»';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
color: #FFFFFF;
}
.button:hover span {
padding-right: 25px;
color: #FFFFFF;
}
.button:hover span:after {
opacity: 1;
right: 0;
color: #FFFFFF;
}

答案 0 :(得分:1)
.button {
position: relative;
display: inline-block;
border-radius: 20px;
border: 2px solid #ffcc00;
background-color: #006534;
color: #FFFFFF;
text-align: center;
font-size: 16px;
padding: 9px;
width: 230px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
top: 0px;
left: 0px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
color: #FFFFFF;
}
.button span:after {
content: '»';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
color: #FFFFFF;
}
.button:hover span {
padding-right: 25px;
color: #FFFFFF;
}
.button:hover span:after {
opacity: 1;
right: 0;
color: #FFFFFF;
}

<div>
<a href="link" class="button"><span>taddaa</span></a>
</div>
&#13;
您可以在锚标记中使用按钮类。因此无需在按钮
中添加锚标记答案 1 :(得分:0)
a {
display: inline-block; /* inline by default */
padding: 1rem 2rem;
background: gray;
color: white;
}
a span {
border: 1px solid white;
}
<a class='link' href='http://example.com'>
<span>Link title?</span>
</a>
答案 2 :(得分:0)
Tyy按钮样式
.button {
display: inline-block;
border-radius: 20px;
border: 2px solid #ffcc00;
background-color: #006534;
color: #FFFFFF;
text-align: center;
font-size: 16px;
padding: 9px;
width: 230px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
答案 3 :(得分:0)
这是更好的方法,不使用按钮,并在所有浏览器上工作
a {
background: #000;
padding: 10px 20px;
border-radius: 5px;
text-decoration: none;
color: orange;
font-weight: bold;
transition: all 6000;
box-sizing: border-box;
}
span {
position: relative;
left: 0;
}
a:hover span {
left: -5px;
transition: left 1s;
}
a:hover span:after {
content: ' »';
position: absolute;
}
<a href="link"><span>Become a member today</span></a>