有人可以帮我吗。我想要页面顶部的警报框。当我单击关闭时,div将关闭,但刷新后会返回。
我该如何解决?
我的代码是:CSS
.alert {
padding: 20px;
background-color: #f44336;
color: white;
}
.closebtn {
margin-left: 15px;
color: white;
font-weight: bold;
float: right;
font-size: 22px;
line-height: 20px;
cursor: pointer;
transition: 0.3s;
}
.closebtn:hover {
color: black;
}
HTML
<div class="alert">
<span class="closebtn" onclick="this.parentElement.style.display='none';">×</span>
<strong>Alert:</strong> Close this bar, after refresh page this bar is not visibile.
</div>
也将其添加到: