Difference between revisions of "User:Tsutomu25/sandbox/Cover3"

From Detective Conan Wiki
Line 1: Line 1:
<includeonly><span id="spoiler-box-{{{1}}}">[[#spoiler-target-{{{1}}}|<span id="show-button-{{{1}}}" class="button-{{{1}}}">Show Spoilers</span>]][[#null|<span id="hide-button-{{{1}}}" class="button-{{{1}}}">Hide Spoilers</span>]]<span id="spoiler-target-{{{1}}}"></span><span id="spoiler-text-{{{1}}}">{{{2}}}</span></span>
+
<includeonly><span id="spoiler-box-{{{1}}}"><span class="button-container-{{{1}}}">[[#spoiler-target-{{{1}}}|<span id="show-button-{{{1}}}" class="button-{{{1}}}">Show Spoilers</span>]]</span><span class="button-container-{{{1}}}">[[#null|<span id="hide-button-{{{1}}}" class="button-{{{1}}}">Hide Spoilers</span>]]</span><span id="spoiler-target-{{{1}}}"></span><span id="spoiler-text-{{{1}}}">{{{2}}}</span></span>
 
{{code
 
{{code
 
|css=
 
|css=
Line 19: Line 19:
 
  left: 0%;
 
  left: 0%;
 
  z-index: 1;
 
  z-index: 1;
 +
}
 +
 +
/* Styles for the containers of buttons */
 +
.button-container-{{{1}}}{
 +
position: absolute;
 +
bottom: 100%;
 +
left: 50%;
 +
transform: translate(-50%, 3px);
 +
display: inline-block;
 +
width: 90px;
 +
height: calc(1em + 13px);
 +
transition: 0.3s ease-in;
 +
visibility: hidden;
 +
opacity: 0;
 +
z-index: 0;
 +
-webkit-user-select: none;
 +
-ms-user-select: none;
 +
user-select: none;
 
}
 
}
  
 
/* Styles for the buttons */
 
/* Styles for the buttons */
 
.button-{{{1}}}{
 
.button-{{{1}}}{
  display: flex;
+
display: flex;
 
  justify-content: center;
 
  justify-content: center;
 
  align-items: center;
 
  align-items: center;
position: absolute;
 
bottom: calc(100% + 7px);
 
left: 50%;
 
transform: translateX(-50%);
 
 
  width: 90px;
 
  width: 90px;
  height: 20px;
+
  height: 1em;
 
  background-color: white;
 
  background-color: white;
  background-clip: content-box;
+
  border-radius: 4px;
  border: solid black;
+
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.6));
border-width: 1px 2px 2px 1px;
 
border-radius: 5px;
 
 
  text-wrap: nowrap;
 
  text-wrap: nowrap;
 
  text-decoration: none;
 
  text-decoration: none;
 
  color: black;
 
  color: black;
font-size: 9pt;
 
transition: 0.3s;
 
transition-delay: 0.1s;
 
visibility: hidden;
 
opacity: 0;
 
z-index: 0;
 
-webkit-user-select: none;
 
-ms-user-select: none;
 
user-select: none;
 
 
}
 
}
 
#spoiler-box-{{{1}}}:hover #show-button-{{{1}}}{     
 
#spoiler-box-{{{1}}}:hover #show-button-{{{1}}}{     
 
  visibility: visible;
 
  visibility: visible;
 
  opacity: 1;
 
  opacity: 1;
 +
transform: translate(-50%, 0);
 
  z-index: 5;
 
  z-index: 5;
 +
}
 +
#spoiler-box-{{{1}}}:hover #hide-button-{{{1}}}{ 
 +
transform: translate(-50%, 0);
 
}
 
}
  
Line 88: Line 95:
  
 
/* Styles to hide the show button and reveal the hide button */
 
/* Styles to hide the show button and reveal the hide button */
#spoiler-box-{{{1}}}:hover:has(#spoiler-target-{{{1}}}:target) #show-button-{{{1}}}{
+
#spoiler-box-{{{1}}}:hover:has(#spoiler-target-{{{1}}}:target) .button-container-{{{1}}}:has(#show-button-{{{1}}}){
/* display: none; */
 
 
  visibility: hidden;
 
  visibility: hidden;
 
  opacity: 0;
 
  opacity: 0;
 
  z-index: 0;
 
  z-index: 0;
 
}
 
}
#spoiler-box-{{{1}}}:hover:has(#spoiler-target-{{{1}}}:target) #hide-button-{{{1}}}{
+
#spoiler-box-{{{1}}}:hover:has(#spoiler-target-{{{1}}}:target) .button-container-{{{1}}}:has(#hide-button-{{{1}}}){
/* display: flex; */
 
 
  visibility: visible;
 
  visibility: visible;
 
  opacity: 1;
 
  opacity: 1;
 
  z-index: 5;
 
  z-index: 5;
}
 
 
/* Style to enable the hyperlinks back */
 
#spoiler-box:hover:has(#spoiler-target:target){
 
pointer-events: auto;
 
 
}
 
}
 
}}
 
}}

Revision as of 11:30, 26 August 2025

It hides the given input of spoiler text and reveals them when the user clicks on them. It takes two values. One is the name of the spoiler and another one is the actual spoiler text. Every time the template is used, every element has to have a unique id and class. Hence spoiler name is required.

Usage

The following is a list of required parameters:

{{User:Tsutomu25/sandbox/Cover3|<spoiler name>|<spoiler text>}}

Limitations

  • When the template is used multiple times on the same page, only one spoiler can remain visible at a time. If the user reveals another spoiler, the previously opened one will automatically be hidden.
  • If the page is refreshed while a spoiler is revealed, that spoiler will remain open even after the page reloads.

Examples

Result: Show SpoilersHide SpoilersThe weapon is Knife

Result: Show SpoilersHide SpoilersThe culprit wore Orange clothes

Result: Show SpoilersHide SpoilersThe culprit is Gosho Aoyama