html - anchor 仅在按钮的下半部分起作用

标签 html css button

我有一个问题。在我的 website .我有一个按钮,当我单击它时,我想将我发送到另一个 link但只有当我将它推到下半部分时它才会起作用。

这是代码:

<div id="button" onclick="location.reload();location.href='http://andreicarpen.com/cv.pdf'">
<div id="butttop" onclick="location.reload();location.href='http://andreicarpen.com/cv.pdf'"></div>
<div id="buttbottom" onclick="location.reload();location.href='http://andreicarpen.com/cv.pdf'"></div>
<div id="buttbody" onclick="location.reload();location.href='http://andreicarpen.com/cv.pdf'"></div>
<div id="buttfloor" onclick="location.reload();location.href='http://andreicarpen.com/cv.pdf'"></div>
</div>

#button {


  height: 130px;
  width: 300px;
  margin-top:37%;
  position: absolute;
 left:50%;
 margin-left: -150px;
  cursor:pointer;

}

#button div {
  position: absolute;

}

#buttfloor {
  height: 50px;
  width: 300px;
  background: #34495e;
  border-radius: 50%;
  margin-top: 80px;
  z-index: 1;

}

#butttop {
  background: #e74c3c;
  height: 40px;
  width: 250px;
  border-radius: 50%;
  z-index:3;
  margin-left: 25px;
   -webkit-transition: all .2s;
  -moz-transition: all .2s ;
  -ms-transition: all .2s;
  -o-transition: all .2s;
  transition: all .2s;

}

#buttbottom {
  background: #c0392b;
  height: 40px;
  width: 250px;
  border-radius: 50%;
  margin-top: 80px;
  margin-left: 25px;
  z-index:2;

}

#buttbody {
  background: #c0392b;
  height: 80px;
  width: 250px;
  border-radius: 0;
  margin-top: 20px;
  margin-left: 25px;
  -webkit-transition: all .2s;
  -moz-transition: all .2s ;
  -ms-transition: all .2s;
  -o-transition: all .2s;
  transition: all .2s;
  z-index:2;

}

#button:active #buttbody{
  height: 40px;
  margin-top: 60px;

} 

#button:active #butttop{
  margin-top: 40px;

}

最佳答案

如果你去掉这两个:

#button:active #buttbody{
  height: 40px;
  margin-top: 60px;

} 

#button:active #butttop{
  margin-top: 40px;

}

它将是可点击的。 Here's a jsfiddle for it

关于html - anchor 仅在按钮的下半部分起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20575329/

相关文章:

javascript - 在页面加载时选择 jstree 插件中的节点

android - 如何在 Android 上的 WebView 中嵌入 YouTube 剪辑

jquery - 带有 .removeAttr 的多重选择器

html - 允许按钮在响应式网格中完全展开而不截断文本

css - 使用 CSS 在循环中将图像行向上滑动到 Bootstrap 面板主体内

html - 在 CSS 按钮外填充

ASP.NET 自定义按钮控件 - 如何覆盖 OnClientClick 但保留现有行为?

javascript - Jquery 在点击图片时切换

html - bootstrap 4 导航栏的背景颜色问题

java - Android studio-为按钮添加样式