아래 두단계 소스
https://css-tricks.com/the-options-for-password-revealing-inputs/">The Options for Password Revealing Inputs | CSS-Tricks
https://css-tricks.com/the-options-for-password-revealing-inputs/">https://css-tricks.com/the-options-for-password-revealing-inputs/
</p>
<pre tabindex="0">
<code data-lang="javascript" id="actual-js-code">const button = document.querySelector("button");
const oldMethodInput = document.querySelector(".old-method input");
button.addEventListener("click", () => {
document.documentElement.classList.toggle("show-passwords");
if (oldMethodInput.getAttribute("type") === "password") {
oldMethodInput.setAttribute("type", "text");
} else {
oldMethodInput.setAttribute("type", "password");
}
});</code></pre>
<p> </p>
<p>--</p>
<p>html 내용</p>
<pre tabindex="0">
<code data-lang="htmlmixed" id="actual-html-code"><main>
<div>
<button>toggle security</button>
</div>
<form class="old-method">
<h2>Classic Technique</h2>
<input type="password" value="password">
<p>Flop out <code>type="password"</code> for <code>type="text"</code> in HTML.</p>
<p>⚠️ Downsides: doesn't play nice with all password managers.</p>
</form>
<form class="alt-1">
<h2>WebKit-Specific Technique</h2>
<input type="text" value="password">
<p>Use <code>type="text"</code> with <code>-webkit-text-security</code> in CSS.</p>
<p>⚠️ Downsides: Not using the sematically correct input type. Doesn't work in all browsers and probably never will.</p>
</form>
<form class="alt-2">
<h2>Modern CSS Technique</h2>
<input type="password" value="password">
<p>Use <code>input-security</code> in CSS.</p>
<p>⚠️ Downsides: Not supported in all browsers yet.</p>
</form>
</main></code></pre>
<p><code data-lang="htmlmixed">--- </code></p>
<p><code data-lang="htmlmixed">css 내용</code></p>
<p> </p>
<pre tabindex="0">
<code data-lang="css" id="actual-css-code">.alt-1 input {
-webkit-text-security: square;
}
.show-passwords .alt-1 input {
-webkit-text-security: none;
/* <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-security" target="_blank" rel="noopener noreferrer">https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-security</a> */
}
.show-passwords .alt-2 input {
input-security: none;
/* <a href="https://drafts.csswg.org/css-ui/#input-security" target="_blank" rel="noopener noreferrer">https://drafts.csswg.org/css-ui/#input-security</a> */
}
form {
display: grid;
grid-template-columns: 1fr minmax(300px, min-content) 1fr;
background: #546e7a;
box-shadow: inset 0 0 100px rgb(0 0 0 / 0.4);
border-bottom: 1px solid rgba(255 255 255 / 0.4);
border-top: 1px solid rgba(0 0 0 / 0.4);
color: white;
padding: 2rem;
}
form > * {
grid-column: 2 / 3;
}
html {
font: 100%/1.4 system-ui;
}
h2 {
margin: 0 0 0.5rem 0;
}
p {
margin: 0.5rem 0;
}
body {
margin: 0;
}
main div {
background: #f4511e;
text-align: center;
padding: 2rem;
position: sticky;
top: 0;
}
button {
border: 0;
font: 130%/1.4 system-ui;
background: white;
border-radius: 6px;
padding: 0.5rem 2rem;
}
button:hover,
button:focus {
background: #eee;
}
button:active {
position: relative;
top: 1px;
}
input {
font: 150%/1.4 system-ui;
}</code></pre>
<p>
toggle 버튼 대신 select 의 option 항목 선택으로 동일효과 나타내도록
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인전체 질문 목록
답변대기
답변대기
답변대기
답변대기
답변대기
답변대기
답변대기
답변대기
채택
답변대기
답변대기
답변대기
답변대기
채택
채택
답변대기
답변대기
답변대기
채택