A mirror of my website's source code.

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 checkbox-custom-styles.html

View raw Download
text/html • 2.81 kiB
HTML document, ASCII text, with very long lines (1421)
        
            
1
<!DOCTYPE html>
2
<html lang="en">
3
4
<head>
5
6
7
<meta charset="UTF-8" />
8
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9
<title>Customize an HTML Checkbox - S0G</title>
10
<link rel="stylesheet" href="/src/global.css" />
11
12
<link rel="stylesheet" href="/src/pygments-friendly.css" />
13
14
</head>
15
16
<body>
17
<header>
18
<h2><a href="/">Steve0Greatness</a></h2>
19
<nav>
20
<a href="/blog">Blog</a>
21
</nav>
22
</header>
23
24
<ol role="navigation" class="breadcrumbs" aria-roledescription="Site breadcrumb">
25
<li>
26
<a href="/">Index</a>
27
</li>
28
29
<li >
30
<a href="/blog">
31
Blog Index
32
</a>
33
</li>
34
35
<li aria-current="location">
36
37
Customize an HTML Checkbox
38
39
</li>
40
41
</ol>
42
<main>
43
<article>
44
<h2 id="blog-post-titled">Customize an HTML Checkbox</h2>
45
<time>2022 Feb 19</time>
46
<p><p>Checkboxes are hard to style. But when you're making a website, they may look ugly.</p><input type="checkbox" style="appearance:checkbox"><p>As you can see here, this bland checkbox does not fit into my clearly great website(/s). But really, it does not fit in at all.</p><p>The first step toward styling it how we want it is to give it an appearence of none, and a width and height that are what you want.</p><div class="code-container"><div class="code">input[type="checkbox"] {<div style="margin-left:1em">appearance: none;<br>width: 15px;<br>height: 15px;</div>}</div><div class="preview"><input type="checkbox" style="appearance:none;width:15px;height:15px"></div></div><p>Now we can do whatever we want to it. Also, remeber to add a checked pseudo</p><div class="code-container"><div class="code">input[type="checkbox"] {<div style="margin-left:1em">appearance: none;<br>width: 15px;<br>height: 15px;<br>background: #555;<br>border: 1px #252525 solid;<br>border-radius: 2px;</div>}<br><br>input[type="checkbox"]:checked {<div style="margin-left:1em">background: #ce5aff;</div>}</div><div class="preview"><style>input[type="checkbox"].examplecheckbox3_:checked {background: #ce5aff;}input[type="checkbox"].examplecheckbox3_ {background: #555;}</style><input type="checkbox" class="examplecheckbox3_" style="appearance:none;width:15px;height:15px;border-radius:2px;border:1px #252525 solid"></div></div></p>
47
48
</article>
49
</main>
50
<footer role="group">
51
<div class="footer-link-list-holder">
52
<span aria-hidden="true" id="footer-label-social-accounts" class="footer-link-list-label">Social Accounts</span>
53
<ol class="footer-link-list" aria-labelledby="footer-label-social-accounts">
54
<li><a href="https://mastodon.social/@S0G" rel="me">Mastodon</a></li>
55
<li><a href="https://youtube.com/@s0g">YouTube</a></li>
56
</ol>
57
</div>
58
</footer>
59
</body>
60
61
</html>