Skip to content

🤖 Cannot save fiddle #2472

Description

@Tunk009

Error code

01.3k.09

Were you logged in?

Yes

Your username (if logged in)

No response

Your HTML

<div class="crosshair">
    <div class="circle"></div>
    <div class="dot"></div>
    <div class="line-top"></div>
    <div class="line-bottom"></div>
    <div class="line-left"></div>
    <div class="line-right"></div>
</div>

<div class="controls">
    <button onclick="changeColor('green')">🟢 Xanh</button>
    <button onclick="changeColor('red')">🔴 Đỏ</button>
    <button onclick="changeColor('blue')">🔵 Xanh dương</button>
</div>

Your JavaScript

body {
    background: black;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    overflow: hidden;
}

.crosshair {
    position: relative;
    width: 100px;
    height: 100px;
}

.circle {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid #00ff00;
    border-radius: 50%;
    box-shadow: 0 0 20px #00ff00;
}

.dot {
    position: absolute;
    width: 10px;
    height: 10px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: red;
    border-radius: 50%;
}

.line-top {
    position: absolute;
    top: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: #00ff00;
    transform: translateX(-50%);
}

.line-bottom {
    position: absolute;
    bottom: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: #00ff00;
    transform: translateX(-50%);
}

.line-left {
    position: absolute;
    left: -20px;
    top: 50%;
    width: 20px;
    height: 2px;
    background: #00ff00;
    transform: translateY(-50%);
}

.line-right {
    position: absolute;
    right: -20px;
    top: 50%;
    width: 20px;
    height: 2px;
    background: #00ff00;
    transform: translateY(-50%);
}

.controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}

button {
    padding: 15px 25px;
    background: #333;
    color: white;
    border: 2px solid #00ff00;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
}

Your CSS

function changeColor(color) {
    const circle = document.querySelector('.circle');
    const lines = document.querySelectorAll('[class^="line-"]');
    
    if (color === 'green') {
        circle.style.borderColor = '#00ff00';
        circle.style.boxShadow = '0 0 20px #00ff00';
        lines.forEach(line => line.style.background = '#00ff00');
    } else if (color === 'red') {
        circle.style.borderColor = '#ff0000';
        circle.style.boxShadow = '0 0 20px #ff0000';
        lines.forEach(line => line.style.background = '#ff0000');
    } else if (color === 'blue') {
        circle.style.borderColor = '#00ffff';
        circle.style.boxShadow = '0 0 20px #00ffff';
        lines.forEach(line => line.style.background = '#00ffff');
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions