Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Калькулятор - Лабораторная работа 4</title>
<link rel="stylesheet" href="calc-style.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="calc-container">
<h1>Калькулятор</h1>
<p>Простой и надёжный инструмент для вычислений</p>

<div class="calc-form">
<input type="number" id="num1" placeholder="Первое число" step="any" required>

<select id="operation">
<option value="+" selected>+ Сложение</option>
<option value="-">- Вычитание</option>
<option value="*">× Умножение</option>
<option value="/">÷ Деление</option>
</select>

<input type="number" id="num2" placeholder="Второе число" step="any" required>

<button id="calculate">Вычислить</button>
</div>

<div class="result" id="result">
Результат появится здесь
</div>

<a href="index.html" class="back-link">← Вернуться к резюме</a>
</div>

<script>
const num1Input = document.getElementById('num1');
const num2Input = document.getElementById('num2');
const operationSelect = document.getElementById('operation');
const calculateBtn = document.getElementById('calculate');
const resultDiv = document.getElementById('result');

calculateBtn.addEventListener('click', () => {
const num1 = parseFloat(num1Input.value);
const num2 = parseFloat(num2Input.value);
const operation = operationSelect.value;

resultDiv.className = 'result';

if (isNaN(num1) || isNaN(num2)) {
resultDiv.textContent = 'Ошибка: введите корректные числа в оба поля';
resultDiv.classList.add('error');
return;
}

let result;
switch (operation) {
case '+':
result = num1 + num2;
break;
case '-':
result = num1 - num2;
break;
case '*':
result = num1 * num2;
break;
case '/':
if (num2 === 0) {
resultDiv.textContent = 'Ошибка: деление на ноль невозможно';
resultDiv.classList.add('error');
return;
}
result = num1 / num2;
break;
}

resultDiv.textContent = `Результат: ${result}`;
resultDiv.classList.add('success');
});
</script>
</body>
</html>
116 changes: 116 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
body {
font-family: Arial, Helvetica, sans-serif;
background-color: #f4f4f4;
padding: 20px;
line-height: 1.6;
}

.header {
text-align: center;
margin-bottom: 40px;
}

.header h1 {
margin-bottom: 10px;
color: #333;
}

.header p {
font-size: 1.4em;
font-weight: bold;
color: #222;
margin: 8px 0;
}

h2 {
text-align: center;
color: #444;
padding: 20px 0 50px;
}

.text-container {
max-width: 800px;
margin: 40px auto;
padding: 30px;
background-color: #6F4700;
color: #3D5D93;
text-align: left;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.image-overlay {
position: relative;
width: 300px;
height: 400px;
margin: 50px auto;
border: 3px solid #333;
}

.image-overlay__img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 250px;
height: auto;
}

.image-overlay__img--front {
z-index: 10;
}

.traffic-light {
width: 120px;
height: 300px;
background-color: #222;
margin: 60px auto;
padding: 15px;
border-radius: 20px;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}

.traffic-light__light {
width: 90px;
height: 90px;
border-radius: 50%;
}

.traffic-light__light--red { background-color: #c0392b; }
.traffic-light__light--yellow { background-color: #f1c40f; }
.traffic-light__light--green { background-color: #27ae60; }

.maze {
display: grid;
grid-template-columns: repeat(3, 120px);
grid-template-rows: repeat(3, 120px);
gap: 0;
margin: 60px auto;
width: fit-content;
background-color: #ffffff;
padding: 15px;
border: 5px solid #000;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.maze__cell {
box-sizing: border-box;
background-color: #f8f8f8;
}

.maze__cell--wall-top { border-top: 5px solid #000; }
.maze__cell--wall-right { border-right: 5px solid #000; }
.maze__cell--wall-bottom { border-bottom: 5px solid #000; }
.maze__cell--wall-left { border-left: 5px solid #000; }

.maze__cell--start,
.maze__cell--end {
background-color: #d0f0d0;
}
background-color: #dff0d8;

}
102 changes: 102 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: 'Roboto', sans-serif;
background-color: #f5f5f5;
color: #333;
}

.calc-container {
max-width: 500px;
margin: 60px auto;
padding: 40px;
background-color: #fff;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0,0,0,0.15);
text-align: center;
}

.calc-container h1 {
font-size: 32px;
margin-bottom: 10px;
color: #2c3e50;
}

.calc-container p {
color: #7f8c8d;
margin-bottom: 40px;
}

.calc-form {
display: flex;
flex-direction: column;
gap: 20px;
margin-bottom: 30px;
}

.calc-form input, .calc-form select {
padding: 15px;
font-size: 18px;
border: 2px solid #ddd;
border-radius: 8px;
transition: border 0.3s;
}

.calc-form input:focus, .calc-form select:focus {
outline: none;
border-color: #3498db;
}

#calculate {
padding: 15px;
font-size: 20px;
background-color: #3498db;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
transition: background 0.3s;
}

#calculate:hover {
background-color: #2980b9;
}

.result {
padding: 20px;
font-size: 24px;
border-radius: 8px;
background-color: #ecf0f1;
min-height: 70px;
display: flex;
align-items: center;
justify-content: center;
}

.result.success {
background-color: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}

.result.error {
background-color: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}

.back-link {
display: inline-block;
margin-top: 40px;
color: #3498db;
text-decoration: none;
font-size: 18px;
}

.back-link:hover {
text-decoration: underline;
}