您可以使用2个伪元素来做到这一点
CSS
.test{ width: 400px; height: 150px; position: relative; border: 1px solid green;}.test:before, .test:after { content: ""; position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; opacity: 1;}.test:before { background-color: red; z-index: 1; transition: opacity 1s;}.test:after { background-color: green;}.test:hover:before { opacity: 0;}(悬停过渡)
为了能够看到div的内容,伪元素必须位于负的z-index中:
看起来IE不会触发此悬停
.test:hover:before { opacity: 0;}但会触发这一
.test:hover {}.test:hover:before { opacity: 0;}


