Horje
x and y in javascript Code Example
x and y in javascript
<!-- This simple code was written by ProgramerRimon within 10 minutes on 2022-03-20 -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>paly...with x and y....</title>
    <style>
        .x,
        .y {pointer-events: none;width: 2px;height: 100%;position: fixed;border-left:1px dotted red;  }
        .y { width: 100%;height: 2px;border-top:1px dotted red;  }
        .c {pointer-events: none;width: 200px;height: 200px;border-radius: 50%;position: fixed;border: 1px dotted rgb(0, 225, 255);;display: flex;align-items: center;justify-content: center;}
        .showX,
        .showY {pointer-events: none;padding: 5px; color: white;background: rgb(0, 225, 255);
        }
    </style>
</head>

<body>
    <div class="x"></div>
    <div class="c">
        <div class="showX"></div>
        <div class="showY"></div>
    </div>
    <div class="y"></div>

</body>
<script>
    var x = document.querySelector('.x');
    var y = document.querySelector('.y');
    var c = document.querySelector('.c');
    var X = document.querySelector('.showX');
    var Y = document.querySelector('.showY');
    window.onmousemove = function (e) {
        var cx = e.offsetX;
        var cy = e.offsetY;
        X.innerText = cx + 'x';
        Y.innerText = cy + 'y';
        x.style.left = cx + 'px';
        y.style.top = cy + 'px';
        c.style.left = cx - 100 + 'px';
        c.style.top = cy - 100 + 'px';

    }
</script>

</html>





Html

Related
HTML tag to define an internal style sheet Code Example HTML tag to define an internal style sheet Code Example
Html loop Code Example Html loop Code Example
how to check *ngIf with ENUMs in componenet.html Code Example how to check *ngIf with ENUMs in componenet.html Code Example
cast2tv.net not working Code Example cast2tv.net not working Code Example
default php version ubuntu 20.04 Code Example default php version ubuntu 20.04 Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7