Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
<h2>Go to the CSS editor and find .try_out_dimensions. Play with the width value.</h2>
<div class="container breakpoints_1 try_out_dimensions">
  <div class="size show_small">
      Layout is small
    </div>
    <div class="size show_medium">
      Layout is medium
    </div>
    <div class="size show_wide">
      Layout is wide
    </div>
  <hr>
	<div class="item">	
  demo text 1
  </div>
  <div class="item">	
		demo text 2
	</div>
	<div class="item">	
		demo text 3
	</div>
	<div class="item">	
		demo text 4
	</div>
	<div class="item">	
		demo text 5
	</div>
  <div class="item">	
		demo text 6
	</div>
</div>


              
            
!

CSS

              
                :root{
  box-sizing: border-box;
}
.try_out_dimensions{
  /* U can set width to 100% and resize your browser to see the raven switching live 
  Or set width to 500px,501px,1000px and 1001px to see the pixel perfect triggering of the raven*/
  
  width:500px; 
  
  
  height:100%;
  
  /* Set border to 0px, so border width will not influence the value of "100%" */
  border: 0px solid black;

}

.breakpoints_1{
  /* what length should the breakpoints be based on 
  ("100%" for container width in all cases, where 100% evaluates to width ...)
  Setting "100vw" makes this a media query, but you can choose any length you like  
  */
  --base_size:100%;
  
  /* define the Breakpoints   */
  --breakpoint_wide:1000px;
  --breakpoint_medium:500px;
  
  /* set the length for the breakpoint-regions*/
  --length_4_small:calc((100% / 1) - 10px);
  --length_4_medium:calc((100% / 3) - 10px);
  --length_4_wide:calc((100% / 4) - 10px);
}


.container {
  display: inline-block;
  box-sizing: border-box;
  margin:0px;
  padding:0px;
  
  /* this large number is the "hacky" part, since dropping units from vars is not possible, 
  but designates length should not be limited to pixels */
  
  --very_big_int:9999; /* pure number, in px must be bigger than any length appearing elsewhere */
  
  /* This is where the magic happens:
	calculate indicators if  --base_size is bigger then breakpoint.
	returns "0px" if width is smaller, "1px" otherwise via clamp function.
  */
  --is_wide:clamp(0px,(var(--base_size) - var(--breakpoint_wide)),1px);
  --is_medium:calc(clamp(0px,(var(--base_size) - var(--breakpoint_medium)),1px) - var(--is_wide)); 
  /* if it is wide, it is not medium (clamp gives 1px, so subtract --is_wide) */
  --is_small:calc(1px - (var(--is_medium) + var(--is_wide))); 
  /* if it is wide or medium, it is not small */
    
	/* multiply indicator with a very large number .... 
	if indicator is 0px, it stays 0px 
	if indicator is 1px, a very long length is returned.
	minimum with wanted length is 0px (if indicator is 0px) or wanted length (if indicator is 1px).
	summing stuff up gives the one wanted value
	*/

  --dyn_length:calc(
    min(var(--is_wide) *  var(--very_big_int),var(--length_4_wide)) 
    + min(var(--is_medium) *  var(--very_big_int),var(--length_4_medium))
    + min(var(--is_small)*  var(--very_big_int),var(--length_4_small)));
}

.container > .item{
	background-color:green;
  display: inline-block;
  vertical-align:top;
  margin:0px;
  padding:0px;
  border:1px;
  border-color:black;
  border-style:solid;
  height:200px;

	width:var(--dyn_length);
}

.size{
  display: inline-block;
  box-sizing: border-box;
  vertical-align:top;
  overflow:hidden;
  padding:0px;
}

.show_small{
	width:calc(var(--is_small) * 100);
}
 .show_medium{
	width:calc(var(--is_medium) * 100);
}
 .show_wide{
	width:calc(var(--is_wide) * 100);
}


              
            
!

JS

              
                
              
            
!
999px

Console