How to hide or show an element with css?
- نفیسه افقی 2 سال قبل سوال کرد
- شما باید برای ارسال دیدگاه وارد شوید
use display:none
to hide and display:block
to show an element (display
has values other than block):
In the code bellow, “you have to accept the registration rules” is hidden and is show when the “details” button is clicked:
<!DOCTYPE html>
<html>
<head>
<style>
#panel, .flip {
font-size: 16px;
padding: 10px;
text-align: center;
background-color: #4CAF50;
color: white;
border: solid 1px #a6d8a8;
margin: auto;
}
#panel {
display: none;
}
</style>
</head>
<body>
<p class="flip" onclick="myFunction()">details</p>
<div id="panel">
<p>you have to accept the registration rules</p>
</div>
<script>
function myFunction() {
document.getElementById("panel").style.display = "block";
}
</script>
</body>
</html>
* You can also use visibility:hidden
to make an element hidden.
- نفیسه افقی 2 سال قبل پاسخ داد
- آخرین ویرایش 2 سال قبل
- شما باید برای ارسال دیدگاه وارد شوید