0

大家好,我制作了一些按钮,这些按钮在 CSS 活动中会产生点击效果。我想用它把我送到另一个我不想改变它的风格的页面。

基本上现在我的跨度中有一些文本链接到 CSS 文件,当它被点击时看起来和行为就像一个按钮。

我尝试使用

HTML

<span class="Home">Home</span>

CSS

.Dashboard span
{
   width: 130px;
   height:34px;
   text-align: center;
   line-height: 25px;
   font-size: 43px;
   font-family: Lemon;
   text-shadow: 2px 2px #FFFFFF;
}
4

3 回答 3

0

您可以使用:activeCSS 伪选择器来定位处于“活动”(“点击”)状态的元素。

如果您使用浏览器检查器,您将能够看到单击按钮时浏览器应用了哪些样式。记下它们,并覆盖它们。例如:

.Dashboard span:active {
  outline: none !important;
}

将禁用出现在活动元素和焦点元素周围的“蓝色框”。

如果您想了解更多信息,请查看http://css-tricks.com/pseudo-class-selectors/

于 2013-10-18T18:29:52.050 回答
0

If you are just looking to redirect using Javascript, you just have to grab the button and make it so that it will execute:

window.location = "http://destination.com";

However something to keep in mind is that CSS is very flexible and you can simply apply that styling to an anchor tag so you don't have to go about this roundabout way of getting this same functionality. In fact, I think this is the preferred way to do it.

于 2013-10-18T18:30:46.700 回答
0

最佳做法是使用锚标记。

<a class="home" href="http://stackoverflow.com">Home</a>

然后是 CSS 选择器:

a.home {

}
于 2013-10-18T23:23:57.333 回答