Modal / 30 グラスカード フルスクリーン|Glass Card Fullscreen
デザイン見本
フルスクリーンのモーダル背景(fullscreen)に美しいCSSグラデーションを指定し、モーダルの中身(modal-content)に
backdrop-filter: blur をかけることで、背景が透けるグラスモーフィズムデザインを強調しました。
実装コード
HTML
<!-- モーダルを開くボタン -->
<button class="modal-button">Glass Card 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 class="modal-title">Glassmorphism</p>
<p>画面全体に美しいカラーグラデーションを敷き、その中央にすりガラスのようなカード(Glassmorphism)を配置するリッチな表現のモーダルです。背景の全画面表示と遅れてカードが浮き上がるアニメーションが特徴です。</p>
<div class="close-btn-container">
<button class="action-btn close-btn">Accept</button>
</div>
</div>
</div>
</div>
CSS
/* 開くボタンのスタイル */
.modal-button {
padding: 15px 30px;
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
color: #ffffff;
border: none;
border-radius: 30px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
}
.modal-button:hover {
background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(245, 87, 108, 0.6);
}
/* 背景マスクのスタイル */
.mask {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0);
z-index: 1000;
opacity: 0;
visibility: hidden;
transition: all 0.4s ease;
}
.mask.appear {
opacity: 1;
visibility: visible;
}
/* フルスクリーンモーダル(背景) */
.modal.fullscreen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #ff9a9e;
background-image:
radial-gradient(at 40% 20%, hsla(28,100%,74%,1) 0px, transparent 50%),
radial-gradient(at 80% 0%, hsla(189,100%,56%,1) 0px, transparent 50%),
radial-gradient(at 0% 50%, hsla(355,100%,93%,1) 0px, transparent 50%),
radial-gradient(at 80% 50%, hsla(340,100%,76%,1) 0px, transparent 50%),
radial-gradient(at 0% 100%, hsla(22,100%,77%,1) 0px, transparent 50%),
radial-gradient(at 80% 100%, hsla(242,100%,70%,1) 0px, transparent 50%),
radial-gradient(at 0% 0%, hsla(343,100%,76%,1) 0px, transparent 50%);
z-index: 1001;
opacity: 0;
visibility: hidden;
transition: opacity 0.5s ease;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.modal.fullscreen.appear {
opacity: 1;
visibility: visible;
}
/* モーダル内部のグラスカード */
.modal-content {
width: 100%;
max-width: 700px;
background: rgba(255, 255, 255, 0.25);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1px solid rgba(255, 255, 255, 0.5);
border-radius: 20px;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.2);
display: flex;
flex-direction: column;
position: relative;
transform: translateY(30px) scale(0.95);
opacity: 0;
transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s;
}
/* appear時のカードの動き */
.modal.fullscreen.appear .modal-content {
transform: translateY(0) scale(1);
opacity: 1;
}
/* 右上が絶対配置で「×」ボタン */
.modal.fullscreen > .modal-content > .close-btn-container {
position: absolute;
top: 15px;
right: 15px;
z-index: 10;
}
.modal.fullscreen > .modal-content > .close-btn-container .close-btn {
width: 40px;
height: 40px;
background: rgba(255, 255, 255, 0.3);
color: #333333;
border: 1px solid rgba(255, 255, 255, 0.5);
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.6);
transform: rotate(90deg);
}
/* コンテンツ中央揃え */
.fullscreen-content {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px 50px;
text-align: center;
}
.fullscreen-content .modal-title {
color: #1f2937;
font-size: 2rem;
margin-top: 0;
margin-bottom: 15px;
font-weight: 700;
text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}
.fullscreen-content p {
color: #4b5563;
font-size: 1.1rem;
line-height: 1.6;
margin-bottom: 25px;
max-width: 600px;
}
/* 下部アクションボタン */
.fullscreen-content .close-btn-container {
margin-top: 20px;
}
.fullscreen-content .action-btn {
padding: 14px 40px;
background: rgba(255, 255, 255, 0.5);
color: #1f2937;
border: 1px solid rgba(255, 255, 255, 0.6);
border-radius: 30px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
backdrop-filter: blur(4px);
transition: all 0.3s ease;
display: inline-flex;
align-items: center;
justify-content: center;
line-height: 1.5;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}
.fullscreen-content .action-btn:hover {
background: rgba(255, 255, 255, 0.8);
transform: translateY(-2px);
box-shadow: 0 6px 12px rgba(0, 0, 0, 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();
}
});
})();