parent
b13e1a13d1
commit
af7229c0c4
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Dynamic Border Radius</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Border-radius Previewer</h1>
|
||||
|
||||
<div class="preview-box" id="previewBox"></div>
|
||||
|
||||
<div class="controls">
|
||||
<div class="control_group">
|
||||
<label>T-left: <input type="range" min="0" max="100" value="0" id="topLeft"></label>
|
||||
<label>B-left: <input type="range" min="0" max="100" value="0" id="bottomLeft"></label>
|
||||
</div>
|
||||
<div class="control_group">
|
||||
<label>T-right: <input type="range" min="0" max="100" value="0" id="topRight"></label>
|
||||
<label>B-right: <input type="range" min="0" max="100" value="0" id="bottomRight"></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="css-output">
|
||||
<input type="text" id="cssCode" readonly>
|
||||
<button id="copyBtn">Copy</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="index.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -0,0 +1,34 @@
|
||||
const previewBox = document.getElementById('previewBox');
|
||||
const topLeft = document.getElementById('topLeft');
|
||||
const topRight = document.getElementById('topRight');
|
||||
const bottomRight = document.getElementById('bottomRight');
|
||||
const bottomLeft = document.getElementById('bottomLeft');
|
||||
const cssCode = document.getElementById('cssCode');
|
||||
const copyBtn = document.getElementById('copyBtn');
|
||||
|
||||
function updateBorderRadius() {
|
||||
const tl = topLeft.value + '%';
|
||||
const tr = topRight.value + '%';
|
||||
const br = bottomRight.value + '%';
|
||||
const bl = bottomLeft.value + '%';
|
||||
|
||||
const radius = `${tl} ${tr} ${br} ${bl}`;
|
||||
previewBox.style.borderRadius = radius;
|
||||
cssCode.value = `border-radius: ${radius};`;
|
||||
}
|
||||
|
||||
// Event listeners
|
||||
[topLeft, topRight, bottomRight, bottomLeft].forEach(input => {
|
||||
input.addEventListener('input', updateBorderRadius);
|
||||
});
|
||||
|
||||
// Copy CSS to clipboard
|
||||
copyBtn.addEventListener('click', () => {
|
||||
cssCode.select();
|
||||
cssCode.setSelectionRange(0, 99999);
|
||||
document.execCommand('copy');
|
||||
alert('CSS copied to clipboard!');
|
||||
});
|
||||
|
||||
// Initialize preview
|
||||
updateBorderRadius();
|
||||
@ -0,0 +1,82 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background: #f4f4f4;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
background: white;
|
||||
height: fit-content;
|
||||
padding: 16px 32px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.controls {
|
||||
display: flex;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.control_group {
|
||||
flex: 1;
|
||||
background-color: beige;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
label {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
input[type="range"] {
|
||||
-webkit-appearance: none;
|
||||
width: 100px;
|
||||
height: 5px;
|
||||
background: #ddd;
|
||||
outline: none;
|
||||
border-radius: 5px;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.preview-box {
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
background: #4CAF50;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
.css-output {
|
||||
display: flex;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#cssCode {
|
||||
width: 80%;
|
||||
padding: 5px;
|
||||
font-family: monospace;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
#copyBtn {
|
||||
background-color: black;
|
||||
color: white;
|
||||
outline: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#copyBtn:hover {
|
||||
background-color: #45a049;
|
||||
cursor: pointer;
|
||||
}
|
||||
Loading…
Reference in new issue