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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


                h1 This Pen is use to Explain the Concept of Coordinate System
h3 重要的座標
    li #[span.code offset]: 指游標到"容器"左上角的偏移量,實做上各瀏覽器有些不同(Safari 以邊框外左上為原點;Chrome 和 FireFox 以邊框內左上為起點)。
    li #[span.code client]:指游標到 browser window 左上角的偏移量(不管 HTML document),滾動瀏覽器捲軸時,同樣位置座標相同。又稱 visual viewport。
    li #[span.code page]:指游標到 document 左上角的偏移量,滾動瀏覽器捲軸時,同樣位置座標不同,又稱作 layout viewport。
h3 示意圖
    h5.title-border offset
    p 容器左上角為原點(0, 0),各瀏覽器實做不同。
    h5.title-border client
    p 瀏覽器(browser)左上角為原點(0, 0)。
    h5.title-border page
    p HTML Docuemnt 左上角為原點(0, 0)。

    p.getBoxClient Box info
.info Please Move Your Mouse


    padding: 50px;
    cursor: cell;

h1 {
    font-weight: bold;
    text-align: cross-hair;

.container {
    box-sizing: border-box;
    position: relative;
    // top: 900px;
    width: 350px;
    height: 350px;
    border: 15px solid;
    padding: 30px;

.info {
    position: fixed;
    padding: 10px 5px;
    top: 30px;
    left: 30px;
    border: 1px solid;
    background-color: hsla(160, 100%, 100%, 1);
    white-space: pre;


                const infoElement = document.querySelector('.info')
const getBoxClientElement = document.querySelector('.container')
const refreshBoxInfo = function() {
    const boxClient = getBoxClientElement.getBoundingClientRect()
    let boxInfo = ""
    for (let prop in boxClient) {
        boxInfo += prop + ": " + parseInt(boxClient[prop]) + "<br>"

    getBoxClientElement.innerHTML = boxInfo + 'offsetLeft: ' + getBoxClientElement.offsetLeft

window.document.addEventListener('mousemove', function(e) {
    infoElement.textContent =
    clientXY: (${e.clientX}, ${e.clientY}),
    pageXY: (${e.pageX}, ${e.pageY}),
    offsetXY: (${e.offsetX}, ${e.offsetY})   

document.addEventListener('scroll', refreshBoxInfo)