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

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

              
                <!-- 
  http://www.pibook.gr/
  Κεφάλαιο: Αρχέτυπα
  Παράδειγμα διαδραστικού κώδικα που χρησιμοποιεί το ποντίκι ως συσκευή εισόδου και δίνει ως έξοδο το ανάλογο αποτέλεσμα στην οθόνη. Για να αλλάξει η συσκευή εισόδου πρέπει ο χρήστης να κυλίσει δεξιά ή αριστερά το πορτοκαλί "κουμπί ώστε να αλλάξει η τιμή εισόδου"
-->
<!-- Αρχικοποίηση της τιμής εισόδου -->
<div class="inputvalue">0</div> 
<!-- Αρχικοποίηση ελάχιστης και μέγιστης τιμής που μπορεί να δοθεί σαν είσοδος από το χρήστη. Ορίζεται επίσης το βήμα ανάμεσα στις τιμές. -->
<input type="range" min="-10" max="10" step="1" value="0">

              
            
!

CSS

              
                
/* Standard body pibook.gr */
body {
  background-color: #fff; /* Χρώμα background λευκό */
  color: #000; /* Χρώμα background μαύρο */    
  padding-top: 5%;
}
/* Χαρακτηριστικά της κλάσης inputvalue */
.inputvalue {
  text-align: center;
  font-weight: bold;
  font-size: 10em;
  width: 300px; 
  height: 100px;
  line-height: 60px;
  margin: 40px auto;
}
/* Χαρακτηριστικά της "φόρμας" εισόδου input  */
input[type="range"] {
  display: block;
  -webkit-appearance: none;
  background-color: #000;
  width: 300px;
  height: 5px;
  border-radius: 5px;
  margin: 0 auto;
  outline: 0;
}
/* Χαρακτηριστικά του "κουμπιού" εισόδου */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  background-color: #97e466;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
  transition: .3s ease-in-out;
}
/* Χαρακτηριστικά του "κουμπιού" εισόδου input όταν ο δείκτης του ποντικιού βρίσκεται πάνω από αυτό*/
input[type="range"]::-webkit-slider-thumb:hover {
    background-color: #ce7e44;
    border: 2px solid #fff;
}
/* Χαρακτηριστικά του "κουμπιού" εισόδου input όταν ο χρήστης έχει πατημένο το αριστερό πλήκτρο του ποντικιού */
  input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.6);
}
              
            
!

JS

              
                var element = document.querySelector('input[type="range"]');
// Συνάρτηση εύρους τιμών. Αλλάζει τιμές στην κλάση inputvalue.
var rangeValue = function(){
  var newValue = element.value;
  var target = document.querySelector('.inputvalue');
  target.innerHTML = newValue;
}
// Η συνάρτηση addEventListener καλέιται κάθε φορά που υπάρχει μια αλλαγή στην τιμή της εισόδου.
element.addEventListener("input", rangeValue);
              
            
!
999px

Console