Skip to content

Commit 41df53a

Browse files
authored
Update example.html
1 parent 5f8fef4 commit 41df53a

File tree

1 file changed

+21
-33
lines changed

1 file changed

+21
-33
lines changed

example.html

+21-33
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
background: #222;
1414
color: #ccc;
1515
}
16-
body {
17-
font-size: 2rem; /* 2rem = 20px in our setup. */
18-
}
16+
body { font-size: 2rem } /* 2rem = 20px in our setup. */
1917
html button {
2018
font-size: 2rem;
2119
cursor: pointer;
@@ -28,13 +26,8 @@
2826
border-bottom: 0.5rem solid hsl(345 100% 28%);
2927
border-radius: 12px;
3028
transition: all 0.3s;
31-
&:hover {
32-
background: hsl(345 100% 60%);
33-
transform: translateY(-0.2rem);
34-
}
35-
&:active {
36-
transform: translateY(0.2rem);
37-
}
29+
&:hover { background: hsl(345 100% 60%); transform: translateY(-0.2rem) }
30+
&:active { transform: translateY(0.2rem) }
3831
}
3932
</style>
4033
</head>
@@ -60,10 +53,8 @@
6053
padding: 10px 20px;
6154
color: #fff;
6255
margin: 20px;
63-
& ul, ol { /* CSS Nesting works! */
64-
padding: 5px 0;
65-
}
66-
& span { /* CSS Nesting works! */
56+
/* CSS Nesting works! */
57+
& span {
6758
background: hsl(264 90% 90%);
6859
color: hsl(264 30% 40%);
6960
padding: 16px 20px;
@@ -72,25 +63,21 @@
7263
&::before { content:'🔮'; padding: 0 1ch 0 0; }
7364
}
7465
}
75-
.me li{
76-
list-style: disc;
77-
padding: 4px;
78-
border-radius: 12px;
79-
margin: 4px 20px;
80-
}
81-
.this ol li[n1] { /* ✨ .this is an alias! */
82-
background: hsl(264 50% 50%);
83-
}
84-
.self ol li[n2] { /* ✨ .self is an alias! */
85-
background: hsl(264 80% 50%);
86-
}
66+
/* Flat style can be more readable! 1 selector per line. */
67+
.me ol { padding: 5px 0; }
68+
.me ol li{ list-style: disc; padding: 4px; border-radius: 12px; margin: 4px 20px }
69+
/* ✨ .this and .self alias .me ! */
70+
.this ol li[n1] { background: hsl(264 50% 50%) }
71+
.self ol li[n2] { background: hsl(264 80% 50%) }
72+
/* Animations */
73+
.me { animation: \.me 2s ease-in-out infinite }
8774
@keyframes \.me { /* ♻️ Looped animation @keyframes can be scoped using \ */
8875
0% { transform: translateY(0px); }
8976
50% { transform: translateY(20px); }
9077
100% { transform: translateY(0px); }
9178
}
92-
.me { animation: \.me 2s ease-in-out infinite; }
93-
h1, h2, h3 { font-size: 3rem; margin: 20px 0; } /* Plain CSS works untouched! */
79+
/* Plain CSS works untouched! */
80+
h1, h2, h3 { font-size: 3rem; margin: 20px 0; }
9481
</style>
9582
<h1>🛸 Scoped style using .me</h1>
9683
<ol>
@@ -100,17 +87,17 @@ <h1>🛸 Scoped style using .me</h1>
10087
<li>⚡ Use live editing in the browser inspector to speed up your workflow, again!
10188
</ol>
10289
</div>
103-
104-
<button onClick="window.open('https://github.com/gnat/css-scope-inline/blob/main/example.html');" style="font-weight: bold; font-family: sans-serif;">🐱 View code for this page.</button>
90+
<br />
10591

10692
<div>
10793
<style>
10894
.me { --color: hsl(264 80% 50%); font-family: sans-serif; margin: 20px }
10995
.me div { margin: 20px 0 }
110-
.me div div ul { display: inline }
111-
.me div ul li { display: inline-block; width: 140px; text-align: center; background: #444; border-radius: 5px; padding: 10px; margin: 10px 10px }
96+
.me div ul { margin: 0; padding: 0 }
97+
.me div ul li { display: inline-block; width: 110px; text-align: center; background: #444; border-radius: 5px; padding: 10px 2px; margin: 10px 10px }
11298
</style>
11399
<h2>Responsive Design 🔛 Resize the window!</h2>
100+
🟢 = No breakpoint. Default.
114101
<div>
115102
<style>
116103
.me ul li[n1] { background: var(--color); }
@@ -134,7 +121,6 @@ <h2>Responsive Design 🔛 Resize the window!</h2>
134121
</style>
135122
<div>Desktop First (<strong>below</strong> breakpoint)</div>
136123
<ul><li n6>🏁 xs-<li n5>sm-<li n4>md-<li n3>lg-<li n2>xl-<li n1><strong>🟢 None</strong></ul>
137-
<br />🟢 = No breakpoint. Default starting point.
138124
</div>
139125
<br />
140126

@@ -156,5 +142,7 @@ <h2>HTMX Test</h2>
156142
🧛
157143
</button>
158144
</div>
145+
146+
<button onClick="window.open('https://github.com/gnat/css-scope-inline/blob/main/example.html');" style="font-weight: bold; font-family: sans-serif;">🐱 View code for this page.</button>
159147
</body>
160148
</html>

0 commit comments

Comments
 (0)