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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <div class="info">Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati a deserunt distinctio vitae!
      Dolores officiis animi ab ut officia consequuntur fuga, possimus et eligendi, facilis libero nulla repellat modi
      magnam!
    </div>
<div id="map"></div>
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0
}

html {
  height: 100%
}

body,
html,
#map {
  height: 100%;
  margin: 0;
  padding: 0
}

.info {
  position: absolute;
  z-index: 999;
  border: 2px solid #0084ff;
  top: 10px;
  left: 10px;
  bottom: 10px;
  width: 30%;
  background: #fff;
  padding: 20px;
  border-radius: 5px;
  box-shadow: 0 0 10px 10px rgba(0, 140, 255, 0.2);
  overflow: hidden;
}
              
            
!

JS

              
                /**
 * fitBounds with padding
 */

// config map
let config = {
  minZoom: 7,
  maxZomm: 18,
  zoomControl: false // zoom control off
};
// magnification with which the map will start
const zoom = 18;
// co-ordinates
const lat = 52.2297700;
const lon = 21.0117800;

// calling map
const map = L.map('map', config).setView([lat, lon], zoom);

// Used to load and display tile layers on the map
// Most tile servers require attribution, which you can set under `Layer`
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

// reactivate zoom at the desired location
// [topleft, topright, bottomleft, bottomright]
L.control.zoom({ position: 'topright' }).addTo(map);

// one marker
const marker = L.marker([lat, lon]).bindPopup('Center Warsaw');

// create a feature group, optionally given an initial set of layers
const featureGroup = L.featureGroup([marker]).addTo(map);

function fitBoundsPadding() {
  // get with info div
  const boxInfoWith = document.querySelector('.info').offsetWidth; 

  // sets a map view that contains the given geographical bounds
  // with the maximum zoom level possible
  map.fitBounds(featureGroup.getBounds(), {
    // https://leafletjs.com/reference-1.6.0.html#fitbounds-options-paddingtopleft
    'paddingTopLeft': [boxInfoWith + 10, 10]
  });
}

// trigger function on dom content loaded
window.addEventListener('DOMContentLoaded', fitBoundsPadding);

// trigger function resize window with performant on resize
let timeout;
window.addEventListener('resize', () => {
  clearTimeout(timeout);
  timeout = setTimeout(() => {
    fitBoundsPadding();
  }, 75);
}, false);
              
            
!
999px

Console