【发布时间】:2015-07-03 09:44:34
【问题描述】:
我正在尝试制作一个带有标签/文本的圆形按钮(我在考虑提交按钮或链接到另一个页面),然后当您将鼠标悬停时它具有不同的文本。我已经能够单独找到所有这些东西的教程,但我不能完全让它们发挥作用。
目前我有:
HTML
<div class='button'>
<a href='activities.php'>
<div class='text'> hello world </div>
<img src="/Images/budapest.jpg">
</a>
</div>
CSS
.button img { /*http://codeitdown.com/css-round-buttons/*/
display: block;
width: 30vmin;
height: 30vmin;
line-height: 50px;
border: 2px;
border-radius: 50%;
color: #000000;
text-align: center;
text-decoration: none;
background: #000000;
font-size: 20px;
font-weight: bold;
z-index: 1;
}
.text{
display: block;
}
.text:hover {
display: none;
z-index: 2;
}
.button input[type=submit].nav {
font-family: 'Optima', sans-serif;
height: auto;
width: auto;
background: #111111;
border-radius: 1vmin;
color: #FFFFFF;
font-size: 2vmin;
z-index: 2;
}
该按钮当前是我想要的图像 - 是的,并且确实重定向到正确的页面。但是,文本“hello world”总是显示(而不是仅在悬停时),位于图像上方(而不是在其顶部),我可以单击它或按钮来重定向我。另外,当我悬停时如何改变文本?
更新
剩下的问题是文本不在按钮/图像内。
我的代码
.button img { /*http://codeitdown.com/css-round-buttons/*/
display: block;
width: 30vmin;
height: 30vmin;
line-height: 50px;
border: 2px;
border-radius: 50%;
color: #000000;
text-align: center;
text-decoration: none;
background: #000000;
font-size: 20px;
font-weight: bold;
z-index: 1;
}
.button .text-after {
display: none;
}
.button:hover .text-after {
display: inline;
}
.button:hover .text-before {
display: none;
}
<div class='button'>
<a href='activities.php'>
<span class="text-before">Before</span>
<span class="text-after">After</span>
<img src="/Images/budapest.jpg">
</a>
</div>
【问题讨论】: