Modal / 27 ネイチャーオーガニック フルスクリーン|Nature Organic Fullscreen
デザイン見本
森や自然を連想させる深い緑のグラデーション(`linear-gradient`)を背景にしたフルスクリーンモーダルです。角に強い丸み(`border-radius: 25px`)を持たせたボタンなどを用いて、柔らかくオーガニックな印象を与えます。
実装コード
HTML
<!-- モーダルを開くボタン -->
<button class="modal-button">Nature Organic Fullscreen Modal</button>
<!-- モーダルの背景マスク -->
<div class="mask"></div>
<!-- モーダル本体(フルスクリーン対応クラスを追加) -->
<div class="modal fullscreen">
<div class="modal-content">
<div class="close-btn-container">
<button class="close-btn">×</button>
</div>
<div class="fullscreen-content">
<p>【Nature Organic Fullscreen Modal】</p>
<p>自然をモチーフにしたオーガニックなフルスクリーンモーダルです。</p>
<p>ESCキーでも閉じることができます。</p>
<div class="close-btn-container">
<button class="close-btn">CLOSE</button>
</div>
</div>
</div>
</div>
CSS
/* 開くボタンのスタイル */
.modal-button {
padding: 15px 30px;
background: linear-gradient(135deg, #2d5016 0%, #4a7c59 100%);
color: #ffffff;
border: 2px solid #4a7c59;
border-radius: 25px;
font-size: 16px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(74, 124, 89, 0.3);
}
.modal-button:hover {
background: linear-gradient(135deg, #4a7c59 0%, #6b8e6b 100%);
border-color: #6b8e6b;
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(74, 124, 89, 0.4);
}
/* 背景マスクのスタイル */
.mask {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(45, 80, 22, 0.7);
z-index: 1000;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
}
.mask.appear {
opacity: 1;
visibility: visible;
}
/* フルスクリーンモーダル本体のスタイル */
.modal.fullscreen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, #2d5016 0%, #4a7c59 50%, #6b8e6b 100%);
z-index: 1001;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
}
.modal.fullscreen.appear {
opacity: 1;
visibility: visible;
}
.modal-content {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
position: relative;
}
/* 右上が絶対配置で「×」ボタン */
.modal.fullscreen > .modal-content > .close-btn-container {
position: absolute;
top: 20px;
right: 20px;
z-index: 10;
}
.modal.fullscreen > .modal-content > .close-btn-container .close-btn {
width: 40px;
height: 40px;
background: rgba(255, 255, 255, 0.1);
color: #ffffff;
border: 2px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
font-size: 24px;
font-weight: 300;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
line-height: 1;
}
.modal.fullscreen > .modal-content > .close-btn-container .close-btn:hover {
background: rgba(255, 255, 255, 0.2);
border-color: rgba(255, 255, 255, 0.5);
transform: scale(1.1);
}
/* モーダルコンテンツ中央揃え */
.fullscreen-content {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px 40px;
text-align: center;
}
.modal p {
color: rgba(255, 255, 255, 0.9);
font-size: 1.1rem;
line-height: 1.6;
margin-bottom: 20px;
max-width: 600px;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
/* 下部の「CLOSE」ボタンスタイル */
.fullscreen-content .close-btn-container {
margin-top: 30px;
}
.fullscreen-content .close-btn {
padding: 12px 30px;
background: rgba(255, 255, 255, 0.1);
color: #ffffff;
border: 2px solid rgba(255, 255, 255, 0.3);
border-radius: 25px;
font-size: 16px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
display: inline-block;
min-width: 120px;
}
.fullscreen-content .close-btn:hover {
background: rgba(255, 255, 255, 0.2);
border-color: rgba(255, 255, 255, 0.5);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}
JS
(function () {
var btn = document.querySelector('.modal-button');
var mask = document.querySelector('.mask');
var modal = document.querySelector('.modal');
var closeBtns = document.querySelectorAll('.close-btn');
if (!btn || !mask || !modal) return;
function openModal() {
mask.classList.add('appear');
modal.classList.add('appear');
if (modal.classList.contains('fullscreen')) {
document.body.style.overflow = 'hidden';
}
}
function closeModal() {
mask.classList.remove('appear');
modal.classList.remove('appear');
if (modal.classList.contains('fullscreen')) {
document.body.style.overflow = '';
}
}
btn.addEventListener('click', openModal);
mask.addEventListener('click', closeModal);
closeBtns.forEach(function(b) { b.addEventListener('click', closeModal); });
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape' && modal.classList.contains('appear')) {
closeModal();
}
});
})();