Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,300&subset=latin,latin-ext' rel='stylesheet' type='text/css'>

<h1>CSS pozicioniranje</h1>

<h2>Primer 1 (absolutna postavitev)</h2>

<div class="container primer-1">
 
  <div class="box">
    Živjo
  </div>
  
</div>

<h2>Primer 2 (text-align:center)</h2>

<div class="container primer-2">
 
  <div class="box">
    Živjo
  </div>
  
 </div>

<h2>Primer 3 (margin: 0 auto)</h2>

<div class="container primer-3">
 
  <div class="box">
    Živjo
  </div>
  
 </div>

<h2>Primer 4 (translate)<h2>

<div class="container primer-4">
 
  <div class="box">
    Živjo
  </div>
  
 </div>
              
            
!

CSS

              
                body {
  background: rgba(0, 0, 0, 0.08);
  font-family: 'Open Sans';
}

h1 {
  text-align: center;
  font-size: 50px;
  color: rgba(0, 0, 0, 0.7);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding-bottom: 30px;
}

h2 {
  text-align: center;
  font-weight: 300;
  margin-top: 50px;
}

.container {
  width: 100%; /* Zavzame celo širino strani */
  height: 400px; 
  background-color: #fff;
  padding: 20px;
}

.box {
  width: 300px;
  background-color: rgb(150, 30, 30);
  text-align: center;
  color: #fff;
  padding-top: 150px;
  padding-bottom: 150px;
  transition: 1s all ease-in-out;
}

/*
/* PRIMER 1
*/

.container.primer-1 {
  position: relative;
}
.container.primer-1 .box {
  position: absolute; /* Postavi div absolutno glede na svojega starša */
  left: 50%; /* Postavi element 50% širine diva .container desno */
  margin-left: -150px; /* Polovica širine diva (Primer: če bi bla širina diva .box 600px, bi uporabili margin-left: -300px;) */

}

/*
/* PRIMER 2
*/

.container.primer-2 {
  text-align: center; /* Centriramo text */
}

.container.primer-2 .box  {
  display: inline-block; /* Prikažemo div kot običajen text */
}

/*
/* PRIMER 3
*/

.container.primer-3 .box  {
  margin: 0 auto;
  /* Možnost 2, ki naredi enako je:
     margin-left: auto;
     margin-right: auto;
  */
}


/*
/* PRIMER 4
*/

.container.primer-4 {
  position: relative;
}

.container.primer-4 .box  {
  position: absolute; /* Div absolutno glede na starša */
  left: 50%; /* Odmik od leve strani 50% */
  top: 50%; /* Odmik od zgornjega roba 50% */
  transform: translate(-50%, -50%); /* z CSS3 premaknemo za 50% levo in gor */
  -webkit-transform: translate(-50%, -50%); /* z CSS3 premaknemo za 50% levo in gor */
  -moz-transform: translate(-50%, -50%); /* z CSS3 premaknemo za 50% levo in gor */
}
              
            
!

JS

              
                
              
            
!
999px

Console