给定一个基本的 HTML 模板和 CSS 样式,我看到两个不同的元素反应完全不同。
setTimeout(function() {
document.body.id = 'animate';
}, 100);
#animate input[type="checkbox"]{
width: 100px;
height: 100px;
transition: 2s all;
-moz-appearance: none;
}
#animate div{
width: 100px;
height: 100px;
background:blue;
transition: 2s all;
}
<input type="checkbox"/>
<div></div>
如果你在浏览器中打开它,你会看到,在加载时,div 已经有 100px 的高度/宽度,但复选框在 2 秒内从 0px 增长到 100px 的高度/宽度。
为什么 的input行为与 的不同div?是因为输入具有默认值-webkit-appearance,因此可以在它们之间进行转换吗?
