-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
24 lines (20 loc) · 944 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function generateGradient() {
var color1 = document.getElementById('color1').value;
var color2 = document.getElementById('color2').value;
var gradientType = document.getElementById('gradient-type').value;
var gradientPreview = document.getElementById('gradient-preview');
var cssCode;
if (gradientType === 'linear') {
cssCode = `background: linear-gradient(to right, ${color1}, ${color2});`;
gradientPreview.style.background = `linear-gradient(to right, ${color1}, ${color2})`;
} else if (gradientType === 'radial') {
cssCode = `background: radial-gradient(circle, ${color1}, ${color2});`;
gradientPreview.style.background = `radial-gradient(circle, ${color1}, ${color2})`;
}
// Display and copy CSS code
var cssCodeContainer = document.getElementById('css-code');
cssCodeContainer.textContent = cssCode;
// Select and copy to clipboard
cssCodeContainer.select();
document.execCommand('copy');
}