onclick关闭cookie栏

时间:2017-06-27 09:41:34

标签: javascript html cookies onclick

我正在开发一个应该显示Cookie栏的应用,如果用户点击了" X"它应该关闭,我已经想过用onclick属性来做,但它会被忽略。

这是我的代码:



			console.log("Ready !");
			var close = function () {
				console.log("close");
			}

.cookie-bar {
  position: fixed;
  width: 100%;
  top: 0;
  right: 0;
  left: 0;
  height: 30px;
  text-align: center;
  line-height: 30px;
  background-color: #800000;
  color: white;
  font-size: 14px;
  font-family: "Lato", sans-serif;
  font-weight: 100;
  transition: .8s;
  animation: slideIn .8s;
  animation-delay: .8s;
  .message {
    white-space: nowrap;
    text-shadow: 0 1px 0 darken(red, 10%);
    @media (max-width: 767px){
      display: none;
    }
  }
  .mobile {
    display: none;
    @media (max-width: 767px){
      display: inline-block;
    }
  }
}
@keyframes slideIn {
  0% {
    transform: translateY(-50px);
  }
  100% {
    transform: translateY(0);
  }
}
.close-cb {
  border: none;
  color: white;
  background: darken(red, 20%);
  position: absolute;
  display: inline-block;
  right: 10px;
  top: 0;
  cursor: pointer;
  border-radius: 3px;
  box-shadow: inset 0 0 3px 0 rgba(0,0,0,.2);
  line-height: 30px;
  height: 30px;
  width: 30px;
  font-size: 16px;
  font-weight: bold;
  &:hover {
    background: darken(red, 10%);
  }
}
.checkbox-cb {
  display: none;
  &:checked + .cookie-bar {
    transform: translateY(-50px);
  }
}

<input class="checkbox-cb" id="checkbox-cb" type="checkbox" onclick="close()"/>
		<div class="cookie-bar" id="cookie">
		  <span class="message">Questo sito utilizza i <a href="cookies.php" style="color:white; text-decoration: underline">cookies</a></span>
		  <label for="checkbox-cb" class="close-cb" >x</a>
		</div>
&#13;
&#13;
&#13;

我可以解决吗?

感谢&#39; S

0 个答案:

没有答案