<div foo="bar">1</div>
<div foo="baz">2</div>
div[foo="bar"] {
background: green;
}
<div>1</div>
<div id="foo">2</div>
#foo:before {
content: "♥ "
}
<div class="foo">foo</div>
<div class="bar">bar</div>
<div class="baz">baz</div>
<div class="foo">foo</div>
.bar ~ .foo {
background: green;
}
<input type="text" value="Tim" />
<div id="result"></div>
input[value="Tim"] ~ #result:before {
content: "Tim Carry";
}
<input type="text" value=""/>
<div id="result"></div>
input[value="Tim"] ~ #result:before {
content: "Tim Carry";
}
<input type="text" oninput="this.setAttribute('value', this.value)" />
input[value="tim" i] ~ #result:before {
content: "Tim Carry";
}
input[value="jessica" i] ~ #result:before {
content: "Jessica West";
}
input[value="daniel" i] ~ #result:before {
content: "Daniel Maher";
}
input[value="tim" i] ~ #result:before {
content: "Tim Carry";
}
input[value="jess" i] ~ #result:before {
content: "Jessica West";
}
input[value="daniel" i] ~ #result:before {
content: "Daniel Maher";
}
input[value="t" i] ~ #result:before,
input[value="ti" i] ~ #result:before,
input[value="tim" i] ~ #result:before,
input[value="c" i] ~ #result:before,
input[value="ca" i] ~ #result:before,
input[value="car" i] ~ #result:before,
input[value="carr" i] ~ #result:before,
input[value="carry" i] ~ #result:before {
content: "Tim Carry";
}
<input type="text" id="input"/>
<div id="results">
<div id="result_1"></div>
<div id="result_2"></div>
[…]
<div id="result_98"></div>
<div id="result_99"></div>
</div>
//Pre-fill results
#result_1:before { content: "Jason Harris"; }
#result_2:before { content: "Josh Dzielak"; }
#result_3:before { content: "Jonas Badalic"; }
// […]
// Hide them all
#results div { display: none; }
// Display some on specific queries
#input[value="jo" i] ~ #results #result_2,
#input[value="jo" i] ~ #results #result_3 {
display: block;
}
<div id="result_42"></div>
#result_42 {
&:before {
content: "Gianluca Bargelli Full-Stack Engineer";
}
}
#result_42 {
&:before {
content: "Gianluca Bargelli \A Full-Stack Engineer";
white-space: pre;
}
&:first-line {
font-weight: bold;
}
}
#result_42:before {
content: "Gianluca Bargelli \A Full-Stack Engineer";
}
#result_42:before {
content: "\e647 \e669 \e661 \e66e luca Bargelli \A Full-Stack Engineer";
}
<input type="text" id="input"/>
<div id="results">
<div id="result_1"></div>
<div id="result_2"></div>
[…]
<div id="result_98"></div>
<div id="result_99"></div>
</div>
// Set a flex context
#results div { flex: 1; }
// Change order on specific queries
#input[value="st" i] ~ #result_4 {
order: 1;
}
#input[value="st" i] ~ #result_8 {
order: 2;
}
#input[value="st" i] ~ #result_15 {
order: 3;
}
#result_1 { order: 4; }
#result_2 { order: 8; }
#result_3 { order: 15; }
#result_4 { order: 16; }
#result_5 { order: 23; }
#result_6 { order: 42; }
[…]