gpt4 book ai didi

css - 边界半径在 CSS 转换期间不起作用

转载 作者:行者123 更新时间:2023-12-04 09:10:15 25 4
gpt4 key购买 nike

尝试制作圆形菜单背景。但是关闭时边界半径不起作用

var menuButton = document.querySelector('.btn-menu');
menuButton.addEventListener('click', function(e){
e.preventDefault();
document.body.classList.toggle('menu-open');
});
.btn-menu{
width: 30px;
height: 30px;
border: 2px solid red;
position: relative;
z-index: 5;
float: right;
}
.menu-bg {
position: fixed;
left: 0;
top: 0;
bottom: 0;
width: 100%;
z-index: 40;
pointer-events: none;
z-index: 1;
}
.menu-bg:before {
content: '';
height: 1px;
width: 1px;
background: #000;
position: fixed;
right: 30px;
top: 30px;
transition: all ease .8s;
border-radius: 50%;
transform: scale(1);
overflow:hidden;
}
.menu-open .menu-bg:before {
transform: scale(500);
}
<div class="btn-menu"><a href=""><span>Menu</span></a></div>
<div class="menu-bg"></div>

JSFiddle - https://jsfiddle.net/afelixj/ew7b065h/

最佳答案

1px由于宽度/高度不是一个好主意,我会采取不同的方式并从 scale(0) 开始:

var menuButton = document.querySelector('.btn-menu');
menuButton.addEventListener('click', function(e) {
e.preventDefault();
document.body.classList.toggle('menu-open');
});
.btn-menu {
width: 30px;
height: 30px;
border: 2px solid red;
position: relative;
z-index: 5;
float: right;
}

.menu-bg {
position: fixed;
left: 0;
top: 0;
bottom: 0;
width: 100%;
z-index: 40;
pointer-events: none;
z-index: 1;
}

.menu-bg:before {
content: '';
height: 100px;
width: 100px;
background: #000;
position: fixed;
right: -20px;
top: -20px;
transition: all ease .8s;
border-radius: 50%;
transform: scale(0);
overflow: hidden;
}

.menu-open .menu-bg:before {
transform: scale(5);
}
<div class="btn-menu"><a href=""><span>Menu</span></a></div>
<div class="menu-bg"></div>

关于css - 边界半径在 CSS 转换期间不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63363922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com