پاسخها 18
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Interactive Color Changer</title>
<style>
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
transition: background-color 0.5s ease;
background-color: #f0f0f0;
}
.container {
background-color: rgba(255, 255, 255, 0.8);
padding: 30px;
border-radius: 15px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
text-align: center;
}
h1 {
color: #333;
margin-bottom: 20px;
font-size: 2.5em;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}
select {
padding: 12px;
font-size: 18px;
border: 2px solid #ccc;
border-radius: 8px;
outline: none;
cursor: pointer;
margin-bottom: 20px;
width: 200px;
transition: all 0.3s ease;
}
select:hover {
border-color: #888;
}
select:focus {
border-color: #555;
box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}
.color-preview {
width: 100px;
height: 100px;
border-radius: 50%;
margin: 20px auto;
border: 3px solid #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
.color-name {
font-size: 1.2em;
font-weight: bold;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>Interactive Color Changer</h1>
<select id="colorChange">
<option value="">Choose a color</option>
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
<option value="purple">Purple</option>
<option value="orange">Orange</option>
<option value="pink">Pink</option>
</select>
<div class="color-preview"></div>
<div class="color-name"></div>
</div>
<script>
const color = document.getElementById("colorChange");
const header = document.querySelector("h1");
const container = document.querySelector(".container");
const colorPreview = document.querySelector(".color-preview");
const colorName = document.querySelector(".color-name");
color.addEventListener("change", () => {
const selectColor = color.value;
if (selectColor) {
document.body.style.backgroundColor = selectColor;
colorPreview.style.backgroundColor = selectColor;
colorName.textContent =
selectColor.charAt(0).toUpperCase() + selectColor.slice(1);
const isDark = ["blue", "purple"].includes(selectColor);
header.style.color = isDark ? "white" : "black";
container.style.backgroundColor = isDark
? "rgba(255, 255, 255, 0.9)"
: "rgba(255, 255, 255, 0.8)";
colorName.style.color = isDark ? "white" : "black";
} else {
document.body.style.backgroundColor = "#f0f0f0";
colorPreview.style.backgroundColor = "transparent";
colorName.textContent = "";
header.style.color = "#333";
container.style.backgroundColor = "rgba(255, 255, 255, 0.8)";
}
});
</script>
</body>
</html>
جواب شماره 2194
در حال دریافت نظرها…
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Color Changer</title>
<style>
section{
display: flex;
flex-direction: column-reverse;
width: 380px;
margin: auto;
background: #a09c85;
border-radius: 40px;
border-bottom-left-radius: 5px;
border: 3px dashed #5c5c5c;
box-shadow: inset 2px 2px 0px #e5d267,inset -2px -2px 0px #e5d267;
}
h1{
width: 260px;
color: #5c5c5c;
margin: 5px 5px;
background-color: beige;
border-radius: 20px 20px 20px 5px;
}
#cards {
display: flex;
width: 350px;
height: 120px;
margin: 10px auto;
border-radius: 15px;
overflow: hidden;
}
.child {
flex-basis: 20%;
transition: flex-basis .1s;
}
.child:hover{
flex-basis: 30%;
}
</style>
</head>
<body>
<section>
<h1>Change your background</h1>
<div id="cards">
<div class="child" onclick="changeColor('#344e41')" style="background:#344e41 ;"></div>
<div class="child" onclick="changeColor('#c1121f')" style="background:#c1121f ;"></div>
<div class="child" onclick="changeColor('#1d3557')" style="background:#1d3557 ;"></div>
<div class="child" onclick="changeColor('#f2f4f3')" style="background:#f2f4f3 ;"></div>
<div class="child" onclick="changeColor('#0a0908')" style="background:#0a0908 ;"></div>
</div>
</section>
<script>
function changeColor(color) {
document.body.style.backgroundColor = color;
}
</script>
</body>
</html>
جواب شماره 2451
در حال دریافت نظرها…
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
border: 0;
outline: 0;
}
.wrapper-btn {
width: 60%;
margin: 20px auto;
display: flex;
align-items: center;
justify-content: space-evenly;
height: 200px;
background-color: #efefef;
}
.wrapper-btn button {
padding: 1rem 2rem;
font-weight: 700;
font-size: 20px;
border-radius: 5px;
color: #fff;
}
#blue {
background-color: #2b2bf3;
}
#red {
background-color: #f74c4c;
}
#green {
background-color: #3af046;
}
#white {
color: #000;
background-color: #fff;
}
#black {
background-color: #000;
}
</style>
</head>
<body>
<div class="wrapper-btn">
<button id="blue" data-color="#2b2bf3">blue</button>
<button id="red" data-color="#f74c4c">red</button>
<button id="green" data-color="#3af046">green</button>
<button id="white" data-color="#fff">white</button>
<button id="black" data-color="#000">black</button>
</div>
<script>
const wrapperBtn=document.querySelector('.wrapper-btn')
wrapperBtn.addEventListener('click',e=>{
if(e.target.tagName==='BUTTON'){
const color=e.target.dataset.color
document.body.style.background=color
}
})
</script>
</body>
</html>
جواب شماره 930
در حال دریافت نظرها…
import tkinter
root = tkinter.Tk()
root.geometry("1280x1024")
root.title("Change_Background")
root.configure(bg = "#FFFFFF")
def change_bg(color) :
root.config(bg=color)
label.config(bg=color)
label = tkinter.Label(root , text='Click a Button for change background :' , font= ("Verdana", 18, "italic") , bg = "#FFFFFF" , fg = "#FFD900")
label.pack()
btn1 = tkinter.Button(root , text='Green', font= ("Verdana", 10, "italic") , command = lambda : change_bg(color = "#00FF40") , fg = "#000000" , bg = "#00FF40" , width=10 , height=1)
btn1.pack(pady=5)
btn2 = tkinter.Button(root , text='Red' , font= ("Verdana", 10, "italic") , command = lambda : change_bg(color = "red") , fg = "#000000" , bg = "#FF0000" , width=10 , height=1)
btn2.pack(pady=5)
btn3 = tkinter.Button(root , text='Blue' , font= ("Verdana", 10, "italic") , command = lambda : change_bg(color = "blue") ,fg="#000000" , bg = "#0080FF" , width=10 , height=1)
btn3.pack(pady=5)
btn4 = tkinter.Button(root , text='White' , font= ("Verdana", 10, "italic") , command = lambda : change_bg(color = "white") , fg="#000000" , bg = "#FFFFFF" , width=10 , height=1)
btn4.pack(pady=5)
btn5 = tkinter.Button(root , text='Black' , font= ("Verdana", 10, "italic") , command = lambda : change_bg(color="black") , fg="#FFFFFF" , bg = "#000000" , width=10 , height=1)
btn5.pack(pady=5)
root.mainloop()
جواب شماره 4776
در حال دریافت نظرها…
package Tax.App;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class Star extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
Pane root = new Pane();
Button buttonB = createButton("Blue", "#0034ff", 20,root);
Button buttonG = createButton("Green", "#0ee847", 150,root);
Button buttonP = createButton("Pink", "#e80ee4", 250,root);
root.getChildren().addAll(buttonB, buttonG, buttonP);
Scene scene = new Scene(root, 500, 500);
stage.setScene(scene);
stage.setTitle("Star");
stage.show();
root.requestFocus();
scene.setOnMouseClicked(mouseEvent -> root.requestFocus());
}
private Button createButton(String text, String color, double layoutY,Pane pane) {
Button button = new Button(text);
button.setStyle("-fx-background-color: " + color);
button.setPrefHeight(50);
button.setPrefWidth(100);
button.setLayoutX(200);
button.setLayoutY(layoutY);
button.setOnAction(event -> pane.setStyle("-fx-background-color: " + color));
return button;
}
}
جواب شماره 2774
در حال دریافت نظرها…
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Background Color</title>
<style>
* {
text-align: center;
}
select {
display: block;
width: 300px;
height: 50px;
margin: 20px auto;
padding: 0 10px;
font-size: 18px;
border: 2px solid #ccc;
border-radius: 8px;
background-color: white;
}
select:hover {
border-color: #666;
}
option {
background-color: white;
color: black;
font-size: 16px;
}
</style>
</head>
<body>
<select id="colorSelect">
<option value="">background color</option>
<option value="rgb(66, 234, 66)">green</option>
<option value="rgb(239, 59, 59)">red</option>
<option value="rgb(128, 182, 253)">blue</option>
<option value="white">white</option>
<option value="rgb(66, 65, 65)">black</option>
</select>
<script>
const select = document.getElementById('colorSelect');
select.addEventListener('change', function() {
const color = this.value;
if (color) {
document.body.style.backgroundColor = color;
} else {
document.body.style.backgroundColor = '#ffffff';
}
});
</script>
</body>
</html>
جواب شماره 8676
در حال دریافت نظرها…
<!DOCTYPE html>
<html lang="fa">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>تغییر رنگ پس زمینه</title>
</head>
<body>
<select id="colorSelect">
<option value="green">سبز</option>
<option value="red">قرمز</option>
<option value="blue">آبی</option>
<option value="white">سفید</option>
<option value="black">مشکی</option>
</select>
<script>
document.getElementById('colorSelect').addEventListener('change', function() {
document.body.style.backgroundColor = this.value;
});
</script>
</body>
</html>
جواب شماره 5102
در حال دریافت نظرها…
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
html {
font-size: 1.5em;
transition: all 1s;
}
#select-color {
display: block;
margin: 30px auto;
font-size: 1.2em;
}
#bu-select-color {
font-size: 1.2em;
margin-top: 100px;
margin: 100px auto;
display: block;
align-items: center;
}
</style>
</head>
<body>
<select id="select-color">
<option value="">رنگی را انتخاب کنید</option>
<option value="#008000">سبز</option>
<option value="#ff0000">قرمز</option>
<option value="#0000ff">آبی</option>
<option value="#ffffff">سفید</option>
<option value="#000000">مشکی</option>
</select>
<button id="bu-select-color" onclick="change_color()">تغییر رنگ</button>
<script>
const change_color = () => {
let color = document.querySelector("select").value;
if (color != "") {
document.querySelector("html").style.backgroundColor = color;
}
};
</script>
</body>
</html>
جواب شماره 7421
در حال دریافت نظرها…
ارسال جواب
جوابت را با Markdown بنویس و ثبت کن
×
حساب کاربری
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام
بستن
دانلود