Created
February 23, 2023 07:31
-
-
Save codepediair/8119ffab94bf45b11af297d828307561 to your computer and use it in GitHub Desktop.
spoiler Text In Html, Css and JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<link rel="stylesheet" href="./main.css"> | |
</head> | |
<body> | |
<div class="container" dir="rtl"> | |
برنامه نویسی خوب کسی است که <span class="spoiler">بیشتر یاد میگیرد </span> | |
</div> | |
<script src="./script.js"></script> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@900&display=swap'); | |
body{ | |
background-color: #1D1D2C; | |
font-family: 'Noto Sans Arabic', sans-serif; | |
font-size: 24px; | |
} | |
.container{ | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
color:#F7F4E9; | |
margin: auto; | |
width: 100%; | |
padding: 10px; | |
} | |
.spoiler { | |
color: #EBA63F; | |
background-color: #EBA63F; | |
border-radius: 2px; | |
user-select: none; | |
padding-left: 0.3rem; | |
padding-right: 0.3rem; | |
} | |
.spoiler:hover { | |
cursor: default; | |
} | |
.spoiler-hover:hover, .spoiler-shown { | |
color: #1D1D2C; | |
background-color: #3CBCC3; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("DOMContentLoaded", () => { | |
document.querySelectorAll(".spoiler") | |
.forEach(item => { | |
item.onclick = () => { | |
if (item.classList.contains("spoiler-shown")) | |
item.classList.remove("spoiler-shown"); | |
else | |
item.classList.add("spoiler-shown"); | |
}; | |
}); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment