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.

            
              <div class="container">
  <h1>Bootstrap 3 <code>@screen-xs-max</code></h1>
  <p class="alert"><code>@screen-xs-max</code> is an important variable for custom breakpoints! In this case, I needed it to avoid a 1px conflict with my <code>col-sm-4</code> columns which was breaking layout in the iPad mini. Sample code, the LESS problem and fix, and an explanation are below.</p>

<h2>Columns</h2>

<div class="row">
    <div class="col-sm-4">
        <h3>col-sm-4</h3>
        <p>Suspendisse et arcu felis, ac gravida turpis. Suspendisse potenti. Ut porta rhoncus ligula, sed fringilla felis feugiat eget. In non purus quis elit iaculis tincidunt. Donec at ultrices est.</p>
        <p><a class="btn btn-primary pull-right" href="#">btn pull-right</a></p>
    </div>
    <div class="col-sm-4">
        <h3>col-sm-4</h3>
        <p>Suspendisse et arcu felis, ac gravida turpis. Suspendisse potenti. Ut porta rhoncus ligula, sed fringilla felis feugiat eget. In non purus quis elit iaculis tincidunt. Donec at ultrices est.</p>
        <p><a class="btn btn-primary pull-right" href="#">btn pull-right</a></p>
    </div>
    <div class="col-sm-4">
        <h3>col-sm-4</h3>
        <p>Suspendisse et arcu felis, ac gravida turpis. Suspendisse potenti. Ut porta rhoncus ligula, sed fringilla felis feugiat eget. In non purus quis elit iaculis tincidunt. Donec at ultrices est.</p>
        <p><a class="btn btn-primary pull-right" href="#">btn pull-right</a></p>
    </div>
</div><!-- /.row -->

<div class="alert">
  <h3>The Goal</h3>
  <p>Below <code>col-sm</code> breakpoint, in single-column layout, set each block of content to clear the floating button above it and add padding.</p>
  
  <h3>LESS: problem and fix</h3>
  <pre><code>// @media (max-width: @screen-sm) { // conflicts 1px with col-sm in markup
  @media (max-width: @screen-xs-max) { // fits within col-sm in markup
  [class^="col"] {
		clear: both;
		padding-bottom: 40px;
	}
  }</code></pre>

  <h3>Explanation</h3>
  <p>When using a <code>max-width: @screen-sm</code> breakpoint (768px) in my custom lines of LESS, the layout broke in iPad mini, which falls exactly at the one pixel of leeway between the class <code>screen-sm</code> on the columns and my custom lines designed to clear floating buttons and add padding for the single-column layout below the <code>@screen-sm</code> breakpoint.</p>
  <p>I fixed this by using the breakpoint <code>@screen-xs-max</code> (767px) for the breakpoint in my LESS.</p>
  <p>You can test it by exchanging the commented and uncommented media queries, and resizing the window to exactly the point where the breakpoint triggers. With the <code>@screen-sm</code> breakpoint, you'll find 1px where the columns stretch out vertically while still constrained to 1/3 width -- which is exactly what happens on the iPad mini.</p>
</div>

</div><!-- /.container -->

            
          
!
            
              // @screen-sm allows 1px of leeway, which triggers this breakpoint too soon -- affects iPad mini layout
// @screens-sm-max fixes the problem
// @media (max-width: 768px /* @screen-sm */) { // not good
@media (max-width: 767px /* @screen-xs-max */) { // works!
  [class^="col"] {
		clear: both;
		padding-bottom: 40px;
	}
}

.container, .row {
  padding-bottom: 20px;
}
pre {
  margin-top: 20px;
}
.alert {
  background-color: #9cc9f0;
}
            
          
!
999px
🕑 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 ..................

Console