{"id":10158909,"date":"2018-04-08T15:19:27","date_gmt":"2018-04-08T15:19:27","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/tips-shortcode-for-css\/"},"modified":"2018-04-08T15:23:48","modified_gmt":"2018-04-08T15:23:48","slug":"tips-shortcode-for-css","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/tips-shortcode-for-css\/","title":{"rendered":"[TIPS] Shortcode for CSS"},"content":{"rendered":"<p>Hello!<\/p>\n<p>I&#8217;ve used Shortcoder for a couple of CSS tricks, and I thought I share them.<\/p>\n<p><strong>Tip 1: arbitary coloured superscipt<\/strong><\/p>\n<p>You want to indicate certain words or phrases. For instance you want to put a blue superscript B to indicate the phrase has biblical origin.<\/p>\n<p>1. Create a shortcode,say &#8220;be&#8221; for biblical expression.<br \/>\n2. Put into the content<\/p>\n<pre><code>&lt;style type=&quot;text\/css&quot;&gt;\nbe::before\n{\n  content: &quot;\\00a0B&quot;;\n  vertical-align: super;\n  font-size: smaller;\n  font-weight: bold;\n  color: #003f87;\n}\n&lt;\/style&gt;\n&lt;be\/&gt;<\/code><\/pre>\n<p>Now you can write<br \/>\n<code>Lorem ipsum[sc name=&quot;be&quot;]<\/code><\/p>\n<p>which will put after the word ipsum a space (&#8220;\\00a0&#8221; in the content property) and a &#8220;B&#8221;, that is a small (font-size), blue (color) bold superscript (vertical-align).<\/p>\n<p>Note, the chosen html element (&#8220;&lt;be\/&gt;&#8221; above) may not be a reserved one (thus &#8220;&lt;b\/&gt;&#8221; will not do).<\/p>\n<p>A second note: since the superscript is produced by CSS content property it is <strong>not<\/strong> selectable.<\/p>\n<p><strong>Tip 2: show word-break in a compound string but copy non-word-break string<\/strong><\/p>\n<p>You want show, where the word break is in a compound word. This is not an issue in English, so let&#8217;s take a German word for high-way &#8220;Auto\/\/bahn&#8221;, where you use \/\/ to show the word break.<\/p>\n<p>1. Reuse the tip 1 above, create a shortcode &#8220;wb&#8221; for word-break with the content:<\/p>\n<pre><code>&lt;style type=&quot;text\/css&quot;&gt;\nwb::before\n{\n  content: &#039;\\002F\\002F&#039;;\n}\n&lt;\/style&gt;&lt;wb\/&gt;<\/code><\/pre>\n<p>where the code &#8220;\\002f&#8221; stands for forward-slash. Note, that the end of style element and the wb element must be on the same line or you will get an additional space.<\/p>\n<p>2. There is a less-known CSS property called &#8220;user-select&#8221;. You might want to take a look at a <a href=\"https:\/\/css-tricks.com\/almanac\/properties\/u\/user-select\/\">post<\/a> at CSS-tricks.com. Combine these<\/p>\n<p><code>&lt;span style=&quot;user-select: all;&quot;&gt;Auto[sc name=&quot;wb&quot;]bahn&lt;\/span&gt;<\/code><\/p>\n<p>What the user sees is &#8220;Auto\/\/bahn&#8221;, but when s\/he clicks on either Auto or bahn the word Autobahn without the double slash gets selected, thus copyable into a search field or into user&#8217;s notes.<\/p>\n<p>See CSS-tricks.com for browser differences.<\/p>\n<p>I hope you get the idea and find these tips useful.<\/p>\n","protected":false},"template":"","class_list":["post-10158909","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/10158909","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":4,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/10158909\/revisions"}],"predecessor-version":[{"id":10158935,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/10158909\/revisions\/10158935"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=10158909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}