Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

CSS

Main @media

1
2
3
4
@media (min-width: 1200px) {}
@media (max-width: 767px) {}
@media (min-width: 768px) and (max-width: 979px) {}
@media (max-width: 480px) {}
https://snipt.net/embed/c4cf8d19289a9ed5e29272aa8d3e727a/
https://snipt.net/raw/c4cf8d19289a9ed5e29272aa8d3e727a/
c4cf8d19289a9ed5e29272aa8d3e727a
css
CSS
4
2016-12-04T18:41:21
True
False
False
Jul 09, 2012 at 09:50 AM
/api/public/snipt/43644/
main-media
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">@media</span> <span class="o">(</span><span class="nt">min-width</span><span class="o">:</span> <span class="nt">1200px</span><span class="o">)</span> <span class="p">{}</span> </span><span id="L-2"><a name="L-2"></a><span class="k">@media</span> <span class="o">(</span><span class="nt">max-width</span><span class="o">:</span> <span class="nt">767px</span><span class="o">)</span> <span class="p">{}</span> </span><span id="L-3"><a name="L-3"></a><span class="k">@media</span> <span class="o">(</span><span class="nt">min-width</span><span class="o">:</span> <span class="nt">768px</span><span class="o">)</span> <span class="nt">and</span> <span class="o">(</span><span class="nt">max-width</span><span class="o">:</span> <span class="nt">979px</span><span class="o">)</span> <span class="p">{}</span> </span><span id="L-4"><a name="L-4"></a><span class="k">@media</span> <span class="o">(</span><span class="nt">max-width</span><span class="o">:</span> <span class="nt">480px</span><span class="o">)</span> <span class="p">{}</span> </span></pre></div> </td></tr></table>
css, media, responsive, screen

HTML

Lock the layout's resolution to a 1:1 ratio so that each pixel exactly lines up with the pixels in the iPad's screen.

<meta name="viewport" content="width=768px, minimum-scale=1.0, maximum-scale=1.0" />
https://snipt.net/embed/72b2329ba95806f00012979169d12492/
https://snipt.net/raw/72b2329ba95806f00012979169d12492/
72b2329ba95806f00012979169d12492
html
HTML
1
2016-12-04T18:43:14
True
False
False
/api/public/snipt/42492/
lock-the-layouts-resolution-to-a-11-ratio-so-that-each-pixel-exactly-lines-up-with-the-pixels-in-the-ipads-screen
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">&quot;viewport&quot;</span> <span class="na">content</span><span class="o">=</span><span class="s">&quot;width=768px, minimum-scale=1.0, maximum-scale=1.0&quot;</span> <span class="p">/&gt;</span> </span></pre></div> </td></tr></table>
ipad, layout, meta, screen

JavaScript

Conditional loading JS depending on screen resolution

1
2
3
4
// From http://24ways.org/2011/conditional-loading-for-responsive-designs
if (document.documentElement.clientWidth > 640) {
    searchNews('cats');
}
https://snipt.net/embed/bed73228b419e897aff47581e1ce8da4/
https://snipt.net/raw/bed73228b419e897aff47581e1ce8da4/
bed73228b419e897aff47581e1ce8da4
js
JavaScript
4
2016-12-05T02:45:35
True
False
False
/api/public/snipt/34244/
conditional-js-depending-on-screen-resolution
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">// From http://24ways.org/2011/conditional-loading-for-responsive-designs</span> </span><span id="L-2"><a name="L-2"></a><span class="k">if</span> <span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">documentElement</span><span class="p">.</span><span class="nx">clientWidth</span> <span class="o">&gt;</span> <span class="mi">640</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">searchNews</span><span class="p">(</span><span class="s1">&#39;cats&#39;</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
"conditional loading js", resolution, screen

XML

Ubuntu Add Screen Size

xrandr --newmode "1440x900_60.00"  106.50  1440 1528 1672 1904  900 903 909 934 -hsync +vsync
xrandr --addmode VGA-0 1440x900
https://snipt.net/embed/2d70eb3df64f207a06a5c8880e17f409/
https://snipt.net/raw/2d70eb3df64f207a06a5c8880e17f409/
2d70eb3df64f207a06a5c8880e17f409
xml
XML
2
2016-12-04T18:46:11
True
False
False
/api/public/snipt/32852/
ubuntu-add-screen-size
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>xrandr --newmode &quot;1440x900_60.00&quot; 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync </span><span id="L-2"><a name="L-2"></a>xrandr --addmode VGA-0 1440x900 </span></pre></div> </td></tr></table>
add, screen, size, ubuntu, xrandr

Java

Java get absolute Mouse position on screen

Point location = MouseInfo.getPointerInfo().getLocation();
System.out.println(location.x + ":" + location.y);
https://snipt.net/embed/6454b6562c539e7b0b2c25379eb7e75f/
https://snipt.net/raw/6454b6562c539e7b0b2c25379eb7e75f/
6454b6562c539e7b0b2c25379eb7e75f
java
Java
2
2016-12-05T11:41:03
True
False
False
/api/public/snipt/23243/
java-get-absolute-mouse-position-on-screen
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="n">Point</span> <span class="n">location</span> <span class="o">=</span> <span class="n">MouseInfo</span><span class="o">.</span><span class="na">getPointerInfo</span><span class="o">().</span><span class="na">getLocation</span><span class="o">();</span> </span><span id="L-2"><a name="L-2"></a><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">location</span><span class="o">.</span><span class="na">x</span> <span class="o">+</span> <span class="s">&quot;:&quot;</span> <span class="o">+</span> <span class="n">location</span><span class="o">.</span><span class="na">y</span><span class="o">);</span> </span></pre></div> </td></tr></table>
coordinates, java, mouse, onscreen, pointer, position, screen

Java

Java fullscreen

1
2
3
4
5
    JFrame frame = new JFrame("fullscreen");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setUndecorated(true);
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.setVisible(true);
https://snipt.net/embed/dbaaea6ac90025b5b771b34f1f3dfaee/
https://snipt.net/raw/dbaaea6ac90025b5b771b34f1f3dfaee/
dbaaea6ac90025b5b771b34f1f3dfaee
java
Java
5
2016-12-01T04:48:04
True
False
False
/api/public/snipt/22976/
java-fullscreen
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a> <span class="n">JFrame</span> <span class="n">frame</span> <span class="o">=</span> <span class="k">new</span> <span class="n">JFrame</span><span class="o">(</span><span class="s">&quot;fullscreen&quot;</span><span class="o">);</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">frame</span><span class="o">.</span><span class="na">setDefaultCloseOperation</span><span class="o">(</span><span class="n">JFrame</span><span class="o">.</span><span class="na">EXIT_ON_CLOSE</span><span class="o">);</span> </span><span id="L-3"><a name="L-3"></a> <span class="n">frame</span><span class="o">.</span><span class="na">setUndecorated</span><span class="o">(</span><span class="kc">true</span><span class="o">);</span> </span><span id="L-4"><a name="L-4"></a> <span class="n">frame</span><span class="o">.</span><span class="na">setExtendedState</span><span class="o">(</span><span class="n">JFrame</span><span class="o">.</span><span class="na">MAXIMIZED_BOTH</span><span class="o">);</span> </span><span id="L-5"><a name="L-5"></a> <span class="n">frame</span><span class="o">.</span><span class="na">setVisible</span><span class="o">(</span><span class="kc">true</span><span class="o">);</span> </span></pre></div> </td></tr></table>
fullscreen, java, maximized, screen
Copyrighted, illegal, or inappropriate content? Email [email protected].