更改位置后按钮不起作用

布朗眼忍者

从哪儿冒出来,我的按钮停止工作我试图将其缩小到导致问题的原因,每当我在我的css- 中添加以下代码段时都会发生这种情况

#filler{
    position:relative;
    left:340px;
    top:85px
}

它一直在工作,突然不起作用,但只有当我尝试定位它时。这是我所有的代码供参考:

function myFunction() {
  $('#Asterisk').empty();
  for (var i = 0; i < 7; i++) {

    for (var a = i; a < 7; a++) {

      $('#Asterisk').append("*");
    }

    $('#Asterisk').append("<br>");


  }


}
#Obelix {
  border: 8px solid black;
  width: 400px;
  height: 200px;
  position: relative;
  left: 250px;
  top: 100px
}

#Getafix {
  width: 400px;
  height: 200px;
  position: relative;
  left: 75px;
  bottom: 126px
}

#Asterisk {
  position: relative;
  right: 325px;
  top: 10px;
  transform: rotate(180deg)
}

#mainwrapper {
  height: 4000px;
  width: 4000px;
  position: relative
}

#filler {
  position: relative;
  left: 340px;
  top: 85px
}

#filler {
  padding: 15px 25px;
  font-size: 24px;
  text-align: center;
  cursor: pointer;
  outline: none;
  color: #fff;
  background-color: #4CAF50;
  border: none;
  border-radius: 15px;
  box-shadow: 0 9px #999;
}

#filler:hover {
  background-color: #3e8e41
}

#filler:active {
  background-color: #3e8e41;
  box-shadow: 0 5px #666;
  transform: translateY(4px);
}
<!DOCTYPE html>

<html>

<head>

  <link rel="stylesheet" type="text/css" href="css/looping.css">


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
  </script>
  <script src="looping.js">
  </script>
</head>
<div id="mainwrapper">

  <body>
    <button id="filler" onclick="myFunction()"> Fill in the box </button>
    <div id="imgbox"> </div>
    <div id="Obelix">
      <div id="Asterisk"> </div>
      <div id="Getafix"> </div>
    </div>
</div>

</html>

马蒂姆

问题是,你的#Getafix div 就在按钮上方,只要你定位它。您可以使用 z-index 来更改此顺序。例如

button {
  z-index: 1;
}

编辑:我为#Getafix 添加了一个几乎透明的浅色背景色,因此您可能会看到它的位置。如果您无法选择使用 z-index(因为您需要它在按钮上方的视觉效果),您可以pointer-events: none;在 #Getafix div 上使用。这会导致#Getafix 忽略所有点击事件,而是传递给底层按钮。不幸的是,浏览器对 poiner-events 的支持很一般(没有 ie10 或以下的支持):http ://caniuse.com/#feat=pointer-events

function myFunction(){
		$('#Asterisk').empty();
		for(var i =0;i<7;i++) { 
			
	    for(var a=i;a<7;a++) { 

		$('#Asterisk').append("*");
				
			}
			
			
		$('#Asterisk').append("<br>");
		
			
		}
		
	
	    }
#Obelix{
    border:8px solid black;
    width:400px;
    height:200px;
    position:relative;
    left:250px;
    top:100px}

    #Getafix{
	width:400px;
    height:200px;
    position:relative;
    left:75px;
    bottom:126px;
    background-color: rgba(0,0,0,.1); /* making the #Getafix div position visible */
    }
	

    #Asterisk{
    position:relative;
    right:325px;
    top:10px;
    transform:rotate(180deg)
    }

    #mainwrapper{
	height:4000px;
    width:4000px;
    position:relative}
   
    #filler{
    position:relative;
    z-index: 1;
    left:340px;
    top:85px
    }
   
    #filler {
    padding: 15px 25px;
    font-size: 24px;
    text-align: center;
    cursor: pointer;
    outline: none;
    color: #fff;
    background-color: #4CAF50;
    border: none;
    border-radius: 15px;
    box-shadow: 0 9px #999;
    }


    #filler:hover {background-color: #3e8e41}

    #filler:active {
    background-color: #3e8e41;
    box-shadow: 0 5px #666;
    transform: translateY(4px);
    }
<!DOCTYPE html>

      <html>
   
      <head>

    <link rel="stylesheet"
    type="text/css"
	href="css/looping.css">
	
    
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">                       
     </script> 
     <script src="looping.js"> </script>
     </head>
     <div id="mainwrapper"> 
     <body>
     <button  id="filler" onclick="myFunction()"> Fill in the box </button>
     <div id="imgbox"> </div>
     <div id="Obelix"> 
     <div id="Asterisk"> </div>  
     <div id="Getafix">  </div>
     </div>
     </div>
     </html>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

按钮的位置不起作用

来自分类Dev

滚动后关闭按钮不起作用

来自分类Dev

动画后,Android按钮不起作用

来自分类Dev

更改UIView的位置不起作用

来自分类Dev

更改Bootstrap Datepicker位置不起作用

来自分类Dev

按钮不起作用并更改边框颜色

来自分类Dev

单选按钮jQuery更改不起作用

来自分类Dev

保存更改按钮不起作用

来自分类Dev

尝试更改按钮的内容不起作用

来自分类Dev

jQuery更改按钮图像不起作用

来自分类Dev

更改htaccess后Fontello不起作用

来自分类Dev

更改htaccess后Fontello不起作用

来自分类Dev

WPF:更改按钮背景颜色后,自定义样式不起作用

来自分类Dev

SwiftUI:更改标签后,ToolbarItem(placement:.principal)中的按钮不起作用

来自分类Dev

html中的某些js更改后,Javascript中的按钮不起作用

来自分类Dev

更改视图模板后,Magento的“添加到购物车”按钮不起作用

来自分类Dev

将设计更改为引导后,按钮onclick回发不起作用

来自分类Dev

为什么更改颜色后我的清除按钮/悬停功能不起作用?

来自分类Dev

按钮不起作用

来自分类Dev

按钮不起作用

来自分类Dev

按钮不起作用

来自分类Dev

Android:我的位置按钮在Android 6.0上不起作用

来自分类Dev

Android:我的位置按钮在Android 6.0上不起作用

来自分类Dev

位置固定时模态显示按钮不起作用

来自分类Dev

在 jframe 中设置按钮的位置不起作用

来自分类Dev

拒绝位置后角度组件不起作用

来自分类Dev

追加后jQuery按钮单击不起作用

来自分类Dev

翻译动画按钮后,单击不起作用

来自分类Dev

为什么单击按钮后重新排序不起作用?