Created
January 9, 2018 10:32
-
-
Save pixelastic/562bc8420afbd98cf95e4b0830d6c931 to your computer and use it in GitHub Desktop.
A Search Engine in CSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="search" value="Tim" /> | |
<div id="result"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Show only for matching keywords | |
input[value="alexandre" i] ~ #results #result15, | |
input[value="alexandre" i] ~ #results #result16, | |
input[value="alexandre" i] ~ #results #result17 { | |
display: block | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="search" value="" | |
oninput="this.setAttribute('value', this.value)" | |
/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input[value="tim" i] ~ #result:before { | |
content: "Tim Carry"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- one div per employee --> | |
<div id="results"> | |
<div id="result0"></div> | |
<div id="result1"></div> | |
<div id="result2"></div> | |
[…] | |
<div id="result148"></div> | |
<div id="result149"></div> | |
<div id="result150"></div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pre-fill the content | |
#result0:before { content: "Aurora Pleguezelo" } | |
// […] | |
#result15:before { content: "Alexandre Collin" } | |
#result16:before { content: "Alexandre Meunier" } | |
#result17:before { content: "Alexandre Stanislawski" } | |
// […] | |
#result150:before { content: "Zo Asmail" } | |
// Hide them all | |
#results div { display: none } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment