Skip to content

Instantly share code, notes, and snippets.

@ZiTAL
Created January 21, 2016 09:58
Show Gist options
  • Save ZiTAL/e091df0270468c1017dc to your computer and use it in GitHub Desktop.
Save ZiTAL/e091df0270468c1017dc to your computer and use it in GitHub Desktop.
css: regex
<!DOCTYPE html>
<html>
<head>
<title>css regex</title>
<style type="text/css">
div
{
width: 120px;
height: 20px;
}
div[id$='0'],
div[id$='2'],
div[id$='4'],
div[id$='6'],
div[id$='8']
{
background-color: green;
}
div[id$='1'],
div[id$='3'],
div[id$='5'],
div[id$='7'],
div[id$='9']
{
background-color: red;
}
</style>
</head>
<body>
<div id="a_1">
</div>
<div id="a_2">
</div>
<div id="a_3">
</div>
<div id="a_4">
</div>
<div id="a_5">
</div>
<div id="a_6">
</div>
<div id="a_7">
</div>
<div id="a_8">
</div>
<div id="a_9">
</div>
<div id="a_10">
</div>
<div id="a_11">
</div>
<div id="a_12">
</div>
<div id="a_13">
</div>
<div id="a_14">
</div>
<div id="a_15">
</div>
<div id="a_16">
</div>
<div id="a_17">
</div>
<div id="a_18">
</div>
<div id="a_19">
</div>
<div id="a_20">
</div>
live example at:
<a href="https://jsfiddle.net/m0ynmdbg/"
title="https://jsfiddle.net/m0ynmdbg/">https://jsfiddle.net/m0ynmdbg/</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment