css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <h1>How many ways can you put a box to the right</h1>
<p>Html used is as follows: <code>&lt;div class=&quot;wrap wrap1&quot;&gt;<br>
  &nbsp;  &lt;div class=&quot;box&quot;&gt;1&lt;/div&gt;<br>
<p>Example 1: <code>.wrap1 .box{margin:0 0 0 auto;}</code></p>
<div class="wrap wrap1">
  <div class="box">1</div>
<p>Example 2: <code>.wrap2 .box{float:right;}</code></p>
<div class="wrap wrap2">
  <div class="box">2</div>
<p>Example 3: <code>.wrap3 .box{margin-left:calc(100% - 50px)}</code></p>
<div class="wrap wrap3">
  <div class="box">3</div>
<p>Example 4: <code>.wrap4{text-align:right}<br>
  .wrap4 .box{display:inline-block}<br>
<div class="wrap wrap4">
  <div class="box">4</div>
<p>Example 5: <code>.wrap5{position:relative;height:70px;}<br>
  .wrap5 .box{position:absolute;right:10px;top:10px}<br>
<div class="wrap wrap5">
  <div class="box">5</div>
<p>Example 6: <code>.wrap6 .box{position:relative;left:calc(100% - 50px);}<br>
<div class="wrap wrap6">
  <div class="box">6</div>
<p>Example 7: <code>.wrap7 .box{margin:0 0 0 100%;transform:translateX(-100%);}<br>
<div class="wrap wrap7">
  <div class="box">7</div>
<p>Example 8: <code>.wrap8 {transform:rotate(180deg);}<br>
  .wrap8 .box {transform:rotate(180deg);}<br>
<div class="wrap wrap8">
  <div class="box">8</div>
<p>Example 9: <code>.wrap9{text-align:right}<br>
  .wrap9 .box{display:inline-table}<br>
<div class="wrap wrap9">
  <div class="box">9</div>
<p>Example 10: <code>.wrap10{display:table;width:100%}<br>
  .wrap10 .box{display:table-cell}<br>
<div class="wrap wrap10">
  <div class="box">10</div>
<p>Example 11: <code>.wrap11{display:flex;justify-content:flex-end}<br>
<div class="wrap wrap11">
  <div class="box">11</div>
<p>Example 12: <code>.wrap12{display:flex;flex-direction:column}<br>
  .wrap12 .box{align-self:flex-end}<br>
<div class="wrap wrap12">
  <div class="box">12</div>
<p>Example 13: <code>.wrap13{direction:rtl}<br>
<div class="wrap wrap13">
  <div class="box">13</div>
<p>Example 14 (Not working in IE and buggy in Chrome):<br> <code>.wrap14{text-indent:calc(100% - 50px);display:table;width:100%}<br>
  .wrap14 .box{display:inline-block;text-indent:0;}<br>
<div class="wrap wrap14">
  <div class="box">14</div>
<p>Example 15: <code>.wrap15:before {content: &quot;&quot;;float: left;height: 50px;margin: 0 -50px 0 100%;}<br>
  .wrap15 .box{overflow:hidden}<br>
<div class="wrap wrap15">
  <div class="box">15</div>

<p>Example 16:<br>(Erik.J) <code>.wrap16{ display:table; width:100%; text-align:justify; line-height:0}<br>
.wrap16:before{ content:"\a0"}<br>
.wrap16:after{ display:inline-block; margin-right:100%; content:"\a0"}<br>
.wrap16 .box{ display:inline-block}
<div class="wrap wrap16">
  <div class="box">16</div>

<p>Example 17:<br>(Erik.J) <code>.wrap17{ display:table; width:100%; text-align:center; word-spacing:-.5em}<br>
.wrap17:after{ display:inline-block; margin-right:-100%; content:"\a0"}<br>
.wrap17 .box{ display:inline-block; margin-right:50px}

<div class="wrap wrap17">
  <div class="box">17</div>

<p>Example 18:<br>(Erik.J) <code>.wrap18{ display:table; width:100%; word-spacing:-.5em}<br>
.wrap18:before{ display:inline-block; margin-right:-50px; width:100%; content:""}<br>
.wrap18 .box{ display:inline-block}
<div class="wrap wrap18">
  <div class="box">18</div>

<p>Example 19: Not working in IE11<br> <code>
.wrap19 .box{position:absolute;display:inline;}
<div class="wrap wrap19">
  <div class="box">19</div>

<p>Example 20: Rain Lover<br> <code>
  .wrap20 {display:flex; flex-direction:row-reverse;}
<div class="wrap wrap20">
  <div class="box">20</div>

<p>Example 21: Rain Lover (only works at viewport widths)<br> <code>
.wrap21 {padding-left:calc(100% - 60px);max-width:none;}
<div class="wrap wrap21">
  <div class="box">21</div>

<p>Example 22: Rain Lover<br> <code>
.wrap22 {text-align:right;}<br>
.wrap22 .box {display:inline-flex;justify-content:center;}
<div class="wrap wrap22">
  <div class="box">22</div>

<p>Example 23: Erik J<br> <code>
  .wrap23{ direction:rtl; white-space:nowrap}<br>
.wrap23:before{ float:left; margin-right:999em; content:"\a0"}<br>
.wrap23 .box{ display:inline-block}
<div class="wrap wrap23">
  <div class="box">23</div>

<p>Example 24: Rain Lover<br> <code>
.wrap24 {display:flex;}<br>
.wrap24:before {content:""; flex:1;}
<div class="wrap wrap24">
  <div class="box">24</div>

<p>Example 25: Grid layout (Chrome and Firefox only)<br> <code>
<div class="wrap wrap25">
  <div class="box">25</div>

<p>Example 26: Rain Lover<br> <code>
.wrap26:before {content:" "; margin: 0 -50px 0 100%;}<br>
.wrap26 .box {display:inline-block;}<br>
<div class="wrap wrap26">
  <div class="box">26</div>

<p>Example 27: Rain Lover<br> <code>
.wrap27 {display:flex; justify-content:space-between;}<br>
.wrap27:before {content:"";}<br>
<div class="wrap wrap27">
  <div class="box">27</div>

<p>Example 28: Rain Lover<br> <code>
.wrap28 {display:flex;}<br>
.wrap28:after {content:""; flex:1; order:-1;}<br>
<div class="wrap wrap28">
  <div class="box">28</div>

<p>Example 29: Rain Lover (Not working in EDGE)<br> <code>
.wrap29 .box {position:-webkit-sticky; position:sticky; left:100%;}<br>
<div class="wrap wrap29">
  <div class="box">29</div>
<p>Example 30: (Erik.J) <br><code>
  .wrap30{ font-size:0}<br>
.wrap30:first-letter{ margin:0 -50px 0 100%}<br>
.wrap30:before{ content:"x"}<br>
.wrap30 .box{ display:inline-block}<br>
<div class="wrap wrap30">
  <div class="box">30</div>

<p>Example 31: Rain Lover (viewport width only - 50px will need to increase to accommodate padding)<br> <code>
.wrap31 {border-left:calc(100vw - 50px) solid transparent;}
<div class="wrap wrap31">
  <div class="box">31</div>

<p>Example 32: Rain Lover <br> <code>
.wrap32 {display:flex; flex-flow:column wrap-reverse;}
<div class="wrap wrap32">
  <div class="box">32</div>

<p>Example 33: Erik_J <br> <code>
.wrap33{ columns:2 50vw; text-align:right;}<br>
.wrap33:before{ display:inline-block; content:"\a0"}<br>
.wrap33 .box{ display:inline-block}<br>
<div class="wrap wrap33">
  <div class="box">33</div>

<p>Example 34: Rain Lover <br> <code>
.wrap34 {height:50px; display:flex; flex-flow:column wrap; align-content:flex-end;}<br>
.wrap34:before {content:"\00A0";}<br>
<div class="wrap wrap34">
  <div class="box">34</div>

<p>Example 35: Rain Lover <br> <code>
.wrap35 {display:table;}<br>
  .wrap35:before {content:""; display:table-cell; width:100%;}</br>
<div class="wrap wrap35">
  <div class="box">35</div>

<p>Example 36: Erik_J <br> <code>
.wrap36{ text-align:center}<br>
.wrap36 .box{ margin-right:calc(-100% + 50px); display:inline-block}<br>
<div class="wrap wrap36">
  <div class="box">36</div>

<p>Example 37: Erik_J <br> <code>
.wrap37:after{ float:left; margin:0 -50px 0 calc(100% - 1em); width:1em; content:"\a0"}<br>
.wrap37 .box{ display:inline-block}<br>
<div class="wrap wrap37">
  <div class="box">37</div>

<p>Example 38: Rain Lover <br> <code>
.wrap38:after {content:"\00A0"; float:left; width:calc(100% - 50px);}<br>
.wrap38 .box {display:inline-block;}<br>
<div class="wrap wrap38">
  <div class="box">38</div>

<p>Example 39: Rain Lover <br> <code>
.wrap39 {display:flex;}<br>
.wrap39:before {content:""; margin-right:auto;}<br>
<div class="wrap wrap39">
  <div class="box">39</div>

<p>Example 40: Rain Lover (Not working in IE11) <br> <code>
.wrap40 {height:70px; text-align:right;}<br>
.wrap40 .box {position:absolute; display:inline;margin-left:-50px;}<br>
<div class="wrap wrap40">
  <div class="box">40</div>

<p>Example 41: Rain Lover <br> <code>
.wrap41 {text-align:justify; text-align-last:right;}<br>
.wrap41 .box {display:inline-block;}<br>
<div class="wrap wrap41">
  <div class="box">41</div>

<p>Example 42: Rain Lover <br> <code>
.wrap42 {display:flex;}<br>
.wrap42:before {content:""; margin: 0 -50px 0 100%;}<br>
<div class="wrap wrap42">
  <div class="box">42</div>

<p>Example 43: Rain Lover <br> <code>
.wrap43 {display:flex;}<br>
.wrap43:before {content:""; width:100%;}<br>
.wrap43 .box {flex-shrink:0;}<br>
<div class="wrap wrap43">
  <div class="box">43</div>

<p>Example 44: Rain Lover <br> <code>
.wrap44 {text-align:justify; text-align-last:justify;}<br>
.wrap44:before {content:"\00A0";}<br>
.wrap44 .box {display:inline-block;}<br>
<div class="wrap wrap44">
  <div class="box">44</div>

<p>Example 45: Rain Lover (similar to #43) <br> <code>
.wrap45 {display:flex;}<br>
.wrap45:before {content:""; flex-basis:100%;}<br>
.wrap45 .box {flex-shrink:0;}<br>
<div class="wrap wrap45">
  <div class="box">45</div>

<p>Example 46: Rain Lover (Not working MS Edge) <br> <code>
.wrap46 {text-align:end;}<br>
.wrap46 .box {display:inline-block;}<br>
<div class="wrap wrap46">
  <div class="box">46</div>

<p>Example 47: ME (Just for fun) <br> <code>
.wrap47 .box {display:none}<br>
.wrap47:after {	content:"47";display:block;	width:50px;	height:50px; line-height:50px; background:red; text-align:center; font-size:20px; font-weight:bold;color:#fff; margin-left:auto;}<br>

<div class="wrap wrap47">
  <div class="box">47</div>

<p>Example 48: Erik_J (Just for fun) <br> <code>
.wrap48{ max-width:none}<br>
  .wrap48 .box{ visibility:hidden; position:relative}<br>
.wrap48 .box:after{ visibility:visible; position:absolute; top:0; bottom:0; left:calc(100vw - 100% - 37px); width:100%; background:inherit; content:"48"}<br>

<div class="wrap wrap48">
  <div class="box">48</div>

<p>Example 49: Erik_J ( Chrome 42 and Firefox 53) <br> <code>
.wrap49{ display:table; width:100%; max-width:none; white-space:nowrap; tab-size:calc(100vw - 87px);}<br>
.wrap49:before{ white-space:pre; content:"\09"}<br>
  .wrap49 .box{ display:inline-block}</br>

<div class="wrap wrap49">
  <div class="box">49</div>

<p>Example 50: Erik_J (Just because he can) <br> <code>
.wrap50{ max-width:none; word-spacing:calc(100vw - 87px); font-size:0}<br>
.wrap50:before{ display:inline-block; content:""}<br<
.wrap50 .box{ display:inline-block}<br>
<div class="wrap wrap50">
  <div class="box">50</div>

<p>Example 51: Rain Lover <br> <code>
  .wrap51 {display:flex;}<br>
.wrap51:before {content:"\00A0"; text-indent:99999ch; overflow:hidden;}<br>
.wrap51 .box {min-width:50px;}
<div class="wrap wrap51">
  <div class="box">51</div>

<p>Example 52: Rain Lover (Just for fun) <br> <code>
 .wrap52 .box {visibility:hidden; width:inherit;}<br>
.wrap52 .box:after {visibility:visible; content:"52"; float:right; width:50px; height:inherit; background:inherit;}
<div class="wrap wrap52">
  <div class="box">52</div>

<p>Can you think of any more? </p>
html {
  box-sizing: border-box;
*, *:before, *:after {
  box-sizing: inherit;
p,h1{margin:20px auto 0;max-width:940px;font-weight:bold;}
hr{max-width:980px;margin:20px auto;border:none;border-top:1px dotted #000;background:transparent;}
/* demo begins */
.wrap {
	margin:10px auto;
.box {

/* magic happens here */
.wrap1 .box{margin:0 0 0 auto;}
.wrap2 .box{float:right;}
.wrap3 .box{margin-left:calc(100% - 50px)}
.wrap4 .box{display:inline-block}
.wrap5 .box{position:absolute;right:10px;top:10px}
.wrap6 .box{position:relative;left:calc(100% - 50px);}
.wrap7 .box{margin:0 0 0 100%;transform:translateX(-100%);}
.wrap8 {transform:rotate(180deg);}
.wrap8 .box {transform:rotate(180deg);}
.wrap9 .box{display:inline-table}
.wrap10 .box{display:table-cell}
.wrap12 .box{align-self:flex-end}
.wrap14{text-indent:calc(100% - 50px);display:table;width:100%}
.wrap14 .box{display:inline-block;text-indent:0;}
.wrap15:before {content: "";float: left;height: 50px;margin: 0 -50px 0 100%;}
.wrap15 .box{overflow:hidden}

/* Erik.J examples 16 - 18 */
.wrap16{ display:table; width:100%; text-align:justify; line-height:0}
.wrap16:before{ content:"\a0"}
.wrap16:after{ display:inline-block; margin-right:100%; content:"\a0"}
.wrap16 .box{ display:inline-block}

.wrap17{ display:table; width:100%; text-align:center; word-spacing:-.5em}
.wrap17:after{ display:inline-block; margin-right:-100%; content:"\a0"}
.wrap17 .box{ display:inline-block; margin-right:50px}

.wrap18{ display:table; width:100%; word-spacing:-.5em}
.wrap18:before{ display:inline-block; margin-right:-50px; width:100%; content:""}
.wrap18 .box{ display:inline-block}

/* extra one from me */
.wrap19 .box{position:absolute;display:inline;}
/* end magic */

/* from rain lover */
.wrap20 {display:flex; flex-direction:row-reverse;}
.wrap21 {padding-left:calc(100% - 60px);max-width:none;}
.wrap22 {text-align:right;}
.wrap22 .box {display:inline-flex;justify-content:center;}

/* from Erik J again */
/* reversed CSS Quiz solution */
.wrap23{ direction:rtl; white-space:nowrap}
.wrap23:before{ float:left; margin-right:999em; content:"\a0"}
.wrap23 .box{ display:inline-block}

.wrap24 {display:flex;}
.wrap24:before {content:""; flex:1;}
/* from rain lover */

/* CSS grid layout */

/* Rain lover */
.wrap26:before {content:" "; margin: 0 -50px 0 100%;}
.wrap26 .box {display:inline-block;}

.wrap27 {display:flex; justify-content:space-between;}
.wrap27:before {content:"";}

.wrap28 {display:flex;}
.wrap28:after {content:""; flex:1; order:-1;}

.wrap29 {overflow:visible;}
.wrap29 .box {position:-webkit-sticky; position:sticky; left:100%;}

/* Erik J */
.wrap30{ font-size:0}
.wrap30:first-letter{ margin:0 -50px 0 100%}
.wrap30:before{ content:"x"}
.wrap30 .box{ display:inline-block}

/* Rain Lover */
.wrap31 {border-left:calc(100vw - 87px) solid transparent;max-width:none;}
.wrap32 {display:flex; flex-flow:column wrap-reverse;}

/* Erik J */
.wrap33{ columns:2 50vw; text-align:right;}
.wrap33:before{ display:inline-block; content:"\a0"}
.wrap33 .box{ display:inline-block}

/* rain lover */
.wrap34 {height:70px; display:flex; flex-flow:column wrap; align-content:flex-end;}
.wrap34:before {content:"\00A0";}

.wrap35 {display:table;}
.wrap35:before {content:""; display:table-cell; width:100%;}

/* erik_J  */
.wrap36{ text-align:center}
.wrap36 .box{ margin-right:calc(-100% + 50px); display:inline-block}

.wrap37:after{ float:left; margin:0 -50px 0 calc(100% - 1em); width:1em; content:"\a0"}
.wrap37 .box{ display:inline-block}

/* rain lover */
.wrap38:after {content:"\00A0"; float:left; width:calc(100% - 50px);}
.wrap38 .box {display:inline-block;}

.wrap39 {display:flex;}
.wrap39:before {content:""; margin-right:auto;}

.wrap40 {height:70px; text-align:right;}
.wrap40 .box {position:absolute; display:inline;margin-left:-50px;}

.wrap41 {text-align:justify; text-align-last:right;}
.wrap41 .box {display:inline-block;text-align-last:center;}

.wrap42 {display:flex;}
.wrap42:before {content:""; margin: 0 -50px 0 100%;}

.wrap43 {display:flex;}
.wrap43:before {content:""; width:100%;}
.wrap43 .box {flex-shrink:0;}

.wrap44 {text-align:justify; text-align-last:justify;}
.wrap44:before {content:"\00A0";}
.wrap44 .box {display:inline-block;text-align-last:center;}

.wrap45 {display:flex;}
.wrap45:before {content:""; flex-basis:100%;}
.wrap45 .box {flex-shrink:0;}

.wrap46 {text-align:end;}
.wrap46 .box {display:inline-block;}

/* me */
.wrap47 .box {display:none}
.wrap47:after {

/* Erik J */
.wrap48{ max-width:none}
.wrap48 .box{ visibility:hidden; position:relative}
.wrap48 .box:after{ visibility:visible; position:absolute; top:0; bottom:0; left:calc(100vw - 100% - 37px); width:100%; background:inherit; content:"48"}

/* Chrome 42 and Firefox 53 */
.wrap49{ display:table; width:100%; max-width:none; white-space:nowrap; tab-size:calc(100vw - 87px);}
.wrap49:before{ white-space:pre; content:"\09"}
.wrap49 .box{ display:inline-block}

.wrap50{ max-width:none; word-spacing:calc(100vw - 87px); font-size:0}
.wrap50:before{ display:inline-block; content:""}
.wrap50 .box{ display:inline-block}

/* Rain Lover */
.wrap51 {display:flex;}
.wrap51:before {content:"\00A0"; text-indent:99999ch; overflow:hidden;}
.wrap51 .box {min-width:50px;}

.wrap52 .box {visibility:hidden; width:inherit;}
.wrap52 .box:after {visibility:visible; content:"52"; float:right; width:50px; height:inherit; background:inherit;}
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................