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

              
                <h1>Tables with sticky rows and cols</h1>
<h2>Table with a sticky row</h2>
<div style="height: 480px; ">
<div class="scrollable sticky-rows">
<table lang="en">
 <thead class="sticky row">
 <tr><th>Name<th>Description<th>Legacy code exception field value (if any)
 <tbody>
 <tr>
  <td>"IndexSizeError"
  <td>The index is not in the allowed range.
  <td><code>INDEX_SIZE_ERR (1)
 <tr>
  <td>"HierarchyRequestError"
  <td>The operation would yield an incorrect node tree.
  <td><code>HIERARCHY_REQUEST_ERR (3)
 <tr>
  <td>"WrongDocumentError"
  <td>The object is in the wrong document.
  <td><code>WRONG_DOCUMENT_ERR (4)
 <tr>
  <td>"InvalidCharacterError"
  <td>The string contains invalid characters.
  <td><code>INVALID_CHARACTER_ERR (5)
 <tr>
  <td>"NoModificationAllowedError"
  <td>The object can not be modified.
  <td><code>NO_MODIFICATION_ALLOWED_ERR (7)
 <tr>
  <td>"NotFoundError"
  <td>The object can not be found here.
  <td><code>NOT_FOUND_ERR (8)
 <tr>
  <td>"NotSupportedError"
  <td>The operation is not supported.
  <td><code>NOT_SUPPORTED_ERR (9)
 <tr>
  <td>"InvalidStateError"
  <td>The object is in an invalid state.
  <td><code>INVALID_STATE_ERR (11)
 <tr>
  <td>"SyntaxError"
  <td>The string did not match the expected pattern.
  <td><code>SYNTAX_ERR (12)
 <tr>
  <td>"InvalidModificationError"
  <td>The object can not be modified in this way.
  <td><code>INVALID_MODIFICATION_ERR (13)
 <tr>
  <td>"NamespaceError"
  <td>The operation is not allowed by <cite>Namespaces in XML</cite>. [XMLNS]
  <td><code>NAMESPACE_ERR (14)
 <tr>
  <td>"InvalidAccessError"
  <td>The object does not support the operation or argument.
  <td><code>INVALID_ACCESS_ERR (15)
 <tr>
  <!-- XHR -->
  <td>"SecurityError"
  <td>The operation is insecure.
  <td><code>SECURITY_ERR (18)
 <tr>
  <!-- XHR -->
  <td>"NetworkError"
  <td>A network error occurred.
  <td><code>NETWORK_ERR (19)
 <tr>
  <!-- XHR -->
  <td>"AbortError"
  <td>The operation was aborted.
  <td><code>ABORT_ERR (20)
 <tr>
  <!-- Workers -->
  <td>"URLMismatchError"
  <td>The given URL does not match another URL.
  <td><code>URL_MISMATCH_ERR (21)
 <tr>
  <!-- HTML -->
  <td>"QuotaExceededError"
  <td>The quota has been exceeded.
  <td><code>QUOTA_EXCEEDED_ERR (22)
 <tr>
  <!-- XHR -->
  <td>"TimeoutError"
  <td>The operation timed out.
  <td><code>TIMEOUT_ERR (23)
 <tr>
  <td>"InvalidNodeTypeError"
  <td>The supplied node is incorrect or has an incorrect ancestor for this operation.
  <td><code>INVALID_NODE_TYPE_ERR (24)
 <tr>
  <!-- HTML -->
  <td>"DataCloneError"
  <td>The object can not be cloned.
  <td><code>DATA_CLONE_ERR (25)
 <tr>
  <td>"EncodingError"
  <td>The encoding operation (either encoded or decoding) failed.
  <td>—
</table>
</div>
</div>

<h2>Tabls with a sticky col</h2>
<div style="width: 640px;">
<div class="scrollable sticky-cols">
<table lang="en">
 <thead>
 <tr><th class="sticky col">Name<th>Description<th>Legacy code exception field value (if any)
 <tbody>
 <tr>
  <td class="sticky col">"IndexSizeError"
  <td>The index is not in the allowed range.
  <td><code>INDEX_SIZE_ERR (1)
 <tr>
  <td class="sticky col">"HierarchyRequestError"
  <td>The operation would yield an incorrect node tree.
  <td><code>HIERARCHY_REQUEST_ERR (3)
 <tr>
  <td class="sticky col">"WrongDocumentError"
  <td>The object is in the wrong document.
  <td><code>WRONG_DOCUMENT_ERR (4)
 <tr>
  <td class="sticky col">"InvalidCharacterError"
  <td>The string contains invalid characters.
  <td><code>INVALID_CHARACTER_ERR (5)
 <tr>
  <td class="sticky col">"NoModificationAllowedError"
  <td>The object can not be modified.
  <td><code>NO_MODIFICATION_ALLOWED_ERR (7)
 <tr>
  <td class="sticky col">"NotFoundError"
  <td>The object can not be found here.
  <td><code>NOT_FOUND_ERR (8)
 <tr>
  <td class="sticky col">"NotSupportedError"
  <td>The operation is not supported.
  <td><code>NOT_SUPPORTED_ERR (9)
 <tr>
  <td class="sticky col">"InvalidStateError"
  <td>The object is in an invalid state.
  <td><code>INVALID_STATE_ERR (11)
 <tr>
  <td class="sticky col">"SyntaxError"
  <td>The string did not match the expected pattern.
  <td><code>SYNTAX_ERR (12)
 <tr>
  <td class="sticky col">"InvalidModificationError"
  <td>The object can not be modified in this way.
  <td><code>INVALID_MODIFICATION_ERR (13)
 <tr>
  <td class="sticky col">"NamespaceError"
  <td>The operation is not allowed by <cite>Namespaces in XML</cite>. [XMLNS]
  <td><code>NAMESPACE_ERR (14)
 <tr>
  <td class="sticky col">"InvalidAccessError"
  <td>The object does not support the operation or argument.
  <td><code>INVALID_ACCESS_ERR (15)
 <tr>
  <!-- XHR -->
  <td class="sticky col">"SecurityError"
  <td>The operation is insecure.
  <td><code>SECURITY_ERR (18)
 <tr>
  <!-- XHR -->
  <td class="sticky col">"NetworkError"
  <td>A network error occurred.
  <td><code>NETWORK_ERR (19)
 <tr>
  <!-- XHR -->
  <td class="sticky col">"AbortError"
  <td>The operation was aborted.
  <td><code>ABORT_ERR (20)
 <tr>
  <!-- Workers -->
  <td class="sticky col">"URLMismatchError"
  <td>The given URL does not match another URL.
  <td><code>URL_MISMATCH_ERR (21)
 <tr>
  <!-- HTML -->
  <td class="sticky col">"QuotaExceededError"
  <td>The quota has been exceeded.
  <td><code>QUOTA_EXCEEDED_ERR (22)
 <tr>
  <!-- XHR -->
  <td class="sticky col">"TimeoutError"
  <td>The operation timed out.
  <td><code>TIMEOUT_ERR (23)
 <tr>
  <td class="sticky col">"InvalidNodeTypeError"
  <td>The supplied node is incorrect or has an incorrect ancestor for this operation.
  <td><code>INVALID_NODE_TYPE_ERR (24)
 <tr>
  <!-- HTML -->
  <td class="sticky col">"DataCloneError"
  <td>The object can not be cloned.
  <td><code>DATA_CLONE_ERR (25)
 <tr>
  <td class="sticky col">"EncodingError"
  <td>The encoding operation (either encoded or decoding) failed.
  <td>—
</table>
</div>
</div>

</div>
</div>

<h2>Table with sticky row and col</h2>
<div style="width: 640px; height: 480px;">
<div class="scrollable sticky-rows sticky-cols">
<table lang="en">
 <thead class="sticky row">
 <tr><th class="sticky col">Name<th>Description<th>Legacy code exception field value (if any)
 <tbody>
 <tr>
  <td class="sticky col">"IndexSizeError"
  <td>The index is not in the allowed range.
  <td><code>INDEX_SIZE_ERR (1)
 <tr>
  <td class="sticky col">"HierarchyRequestError"
  <td>The operation would yield an incorrect node tree.
  <td><code>HIERARCHY_REQUEST_ERR (3)
 <tr>
  <td class="sticky col">"WrongDocumentError"
  <td>The object is in the wrong document.
  <td><code>WRONG_DOCUMENT_ERR (4)
 <tr>
  <td class="sticky col">"InvalidCharacterError"
  <td>The string contains invalid characters.
  <td><code>INVALID_CHARACTER_ERR (5)
 <tr>
  <td class="sticky col">"NoModificationAllowedError"
  <td>The object can not be modified.
  <td><code>NO_MODIFICATION_ALLOWED_ERR (7)
 <tr>
  <td class="sticky col">"NotFoundError"
  <td>The object can not be found here.
  <td><code>NOT_FOUND_ERR (8)
 <tr>
  <td class="sticky col">"NotSupportedError"
  <td>The operation is not supported.
  <td><code>NOT_SUPPORTED_ERR (9)
 <tr>
  <td class="sticky col">"InvalidStateError"
  <td>The object is in an invalid state.
  <td><code>INVALID_STATE_ERR (11)
 <tr>
  <td class="sticky col">"SyntaxError"
  <td>The string did not match the expected pattern.
  <td><code>SYNTAX_ERR (12)
 <tr>
  <td class="sticky col">"InvalidModificationError"
  <td>The object can not be modified in this way.
  <td><code>INVALID_MODIFICATION_ERR (13)
 <tr>
  <td class="sticky col">"NamespaceError"
  <td>The operation is not allowed by <cite>Namespaces in XML</cite>. [XMLNS]
  <td><code>NAMESPACE_ERR (14)
 <tr>
  <td class="sticky col">"InvalidAccessError"
  <td>The object does not support the operation or argument.
  <td><code>INVALID_ACCESS_ERR (15)
 <tr>
  <!-- XHR -->
  <td class="sticky col">"SecurityError"
  <td>The operation is insecure.
  <td><code>SECURITY_ERR (18)
 <tr>
  <!-- XHR -->
  <td class="sticky col">"NetworkError"
  <td>A network error occurred.
  <td><code>NETWORK_ERR (19)
 <tr>
  <!-- XHR -->
  <td class="sticky col">"AbortError"
  <td>The operation was aborted.
  <td><code>ABORT_ERR (20)
 <tr>
  <!-- Workers -->
  <td class="sticky col">"URLMismatchError"
  <td>The given URL does not match another URL.
  <td><code>URL_MISMATCH_ERR (21)
 <tr>
  <!-- HTML -->
  <td class="sticky col">"QuotaExceededError"
  <td>The quota has been exceeded.
  <td><code>QUOTA_EXCEEDED_ERR (22)
 <tr>
  <!-- XHR -->
  <td class="sticky col">"TimeoutError"
  <td>The operation timed out.
  <td><code>TIMEOUT_ERR (23)
 <tr>
  <td class="sticky col">"InvalidNodeTypeError"
  <td>The supplied node is incorrect or has an incorrect ancestor for this operation.
  <td><code>INVALID_NODE_TYPE_ERR (24)
 <tr>
  <!-- HTML -->
  <td class="sticky col">"DataCloneError"
  <td>The object can not be cloned.
  <td><code>DATA_CLONE_ERR (25)
 <tr>
  <td class="sticky col">"EncodingError"
  <td>The encoding operation (either encoded or decoding) failed.
  <td>—
</table>
</div>
</div>
<address>The table data originates from <a href="http://www.w3.org/TR/2014/WD-dom-20140204/">W3C DOM4 (Last Call Working Draft 04 February 2014)</a> licensed by <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY</a>. Copyright © 2014 <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a>.</address>
              
            
!

CSS

              
                .scrollable {
    width:-moz-fit-content;
    width:-ms-fit-content;
    width:-webkit-fit-content;
    width:fit-content;
}

.scrollable.sticky-rows {
    overflow-y: scroll;
    max-height: 100%;
}

.scrollable.sticky-cols {
    overflow-x: scroll;
    max-width: 100%;
}

.scrollable.sticky-cols > table {
    width: -moz-max-content;
    width: -ms-max-content;
    width: -webkit-max-content;
    width: max-content;
}


.scrollable .sticky {
    position: sticky;
}

.scrollable .sticky.row {
    top: 0;
    z-index: 1;
}
.scrollable .sticky.col {
    left: 0;
}


.scrollable {
   border: thin solid silver;
}
.scrollable > table {
	border-spacing: 0;
}
.scrollable td,
.scrollable th {
	border-right: thin solid silver;
	border-bottom: thin solid silver;
	padding: 1em;
}
.scrollable td.sticky,
.scrollable th.sticky,
.scrollable .sticky td,
.scrollable .sticky th {
	background:#ffa;
}

              
            
!

JS

              
                
              
            
!
999px

Console