<button id="play" data-source="https://www.youtube.com/embed/dQw4w9WgXcQ">Play</button>
<div id="modal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<iframe id="youtube-video" width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<style>
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
}
.modal.show {
display: flex;
justify-content: center;
align-items: center;
}
.modal-content {
position: relative;
background-color: #fefefe;
padding: 20px;
border-radius: 8px;
max-width: 800px;
width: 90%;
}
.close {
position: absolute;
top: 10px;
right: 20px;
font-size: 28px;
font-weight: bold;
color: #aaa;
cursor: pointer;
}
.close:hover {
color: #000;
}
iframe {
width: 100%;
aspect-ratio: 16/9;
}
</style>
<script>
const playButton = document.getElementById('play');
const modal = document.getElementById('modal');
const closeButton = document.querySelector('.close');
const iframe = document.getElementById('youtube-video');
playButton.addEventListener('click', () => {
const videoUrl = playButton.getAttribute('data-source');
iframe.src = videoUrl + '?autoplay=1';
modal.classList.add('show');
});
closeButton.addEventListener('click', () => {
modal.classList.remove('show');
iframe.src = '';
});
// Закрытие модального окна при клике вне его
window.addEventListener('click', (event) => {
if (event.target === modal) {
modal.classList.remove('show');
iframe.src = '';
}
});
</script>
<button class="btn-chapter" data-chapter="1">Глава 1</button>
<button class="btn-chapter" data-chapter="2">Глава 2</button>
<button class="btn-chapter" data-chapter="3">Глава 3</button>
<button class="btn-chapter" data-chapter="4">Глава 4</button>
<button class="btn-chapter" data-chapter="5">Глава 5</button>
<div class="chapter" id="chapter-1"><h2>Глава 1: Основы Фотошопа - Растровая графика</h2></div>
<div class="chapter" id="chapter-2"><h2>Глава 2: Основы Фотошопа - Растровая графика</h2></div>
<div class="chapter" id="chapter-3"><h2>Глава 3: Основы Фотошопа - Растровая графика</h2></div>
<div class="chapter" id="chapter-4"><h2>Глава 4: Основы Фотошопа - Растровая графика</h2></div>
<div class="chapter" id="chapter-5"><h2>Глава 5: Основы Фотошопа - Растровая графика</h2></div>
.chapter {
display: none;
}
.chapter.is-open {
display: block;
}
document.addEventListener('DOMContentLoaded', function() {
const allChapters = document.querySelectorAll('.chapter');
const closeAllChapters = () => allChapters.forEach(el => el.classList.remove('is-open'));
const openChapterById = id => document.getElementById(id).classList.add('is-open');;
document.querySelectorAll('.btn-chapter').forEach(btn => {
btn.addEventListener('click', () => {
closeAllChapters();
openChapterById(`chapter-${btn.dataset.chapter}`);
});
});
});
$query = mysqli_query($link,"UPDATE tovars SET img = '$names$name' WHERE id = '$id'");
<form method="post" enctype="multipart/form-data">
<label for="tovar_full">Изображение товара</label>
<input type="hidden" name="id" value=" тут айди товара, к которому нужно прикрепить картинку " />
<input type="file" name="filename" size="10" />
<input type="submit" value="Загрузить" />
</form>
$names = "https://smm-services.ru/admin/";
$id = $_POST['id']; // получить ID из формы
$query = mysqli_query($link,"UPDATE tovars SET img = '$names$name' WHERE id = '$id'");
Поэтому и попросил какой-нибудь хороший визуализатор, если кто часто пользуется, где можно будет реализовать такое и потом CTR+C, CTR+V.
<head>
<script>
const theme = localStorage.getItem('color-theme') === 'dark' ? 'dark' : 'light';
document.documentElement.setAttribute('data-color-theme', theme);
</script>
document.querySelectorAll('.theme-toggle').forEach(el => {
el.addEventListener('click', () => {
const theme = document.documentElement.getAttribute('data-color-theme') === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-color-theme', theme);
localStorage.setItem('color-theme', theme);
});
});
:root {
--body-bg: white;
}
[data-color-theme="dark"] {
-body-bg: black;
}
document.documentElement.classList.add('dark-theme');
:root {
--body-bg: white;
}
html.dark-theme {
-body-bg: black;
}