css - 为不透明度应用的 CSS 规则与计算的样式不同
问题描述
我正在检查https://ionicframework.com/docs/api/alert alert..
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alert</title>
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.esm.js"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core/css/ionic.bundle.css"/>
<style>
:root {
--ion-safe-area-top: 20px;
--ion-safe-area-bottom: 22px;
}
</style>
<script type="module">
import { alertController } from 'https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/index.esm.js';
window.alertController = alertController;
</script>
</head>
<body>
<ion-app>
<ion-header translucent>
<ion-toolbar>
<ion-title>Alert</ion-title>
</ion-toolbar>
</ion-header>,
<ion-content fullscreen class="ion-padding">
<ion-alert-controller></ion-alert-controller>
<ion-button expand="block">Show Alert</ion-button>
</ion-content>
</ion-app>
<script>
const button = document.querySelector('ion-button');
button.addEventListener('click', handleButtonClick);
async function handleButtonClick() {
const alert = await alertController.create({
header: 'Use this lightsaber?',
message: 'Do you agree to use this lightsaber to do good across the galaxy?',
buttons: ['Disagree', 'Agree']
});
await alert.present();
}
</script>
</body>
</html>
那里有一个带有 .alert-wrapper 类的元素。
如果您查看应用的 CSS,它将显示不透明度:0,但计算显示不透明度:1
我尝试从页面中删除所有 CSS 文件、所有 javascript、所有其他元素我试图将此元素移动到正文(在 iframe 之外)并应用 opacity: 0 在样式中,没有任何帮助,计算保持不透明度: 1..
这怎么可能?
解决方案
他们正在使用Web Animations API。
elem.animate([{ opacity: "1" }],{duration: 1, iterations: 1, fill: "forwards"});
#elem {
opacity: 0;
}
<div id="elem">Hello</div>
推荐阅读
- c++ - std::uint8_t(-1) 与 std::uint8_t(0xffu) 的差异和细微差别
- go - 从一组结构中记录单个字段的最简单方法是什么?
- c# - 获取 ASCII 符号的二进制表示 (C#)
- google-apps-script - 如何在 Google 电子表格中获取每张工作表的名称
- sql - SQL Join - 如果没有找到,请尝试其他参数
- reactjs - ReactDataGrid 和 webpack 转译的问题
- java - java - 如何在java中从int重新转换为AScII?
- python - 根据到最近的未服务点的距离选择算法的起点
- image - 如何阻止我的 Printscreen 屏幕抓图被洗掉?
- java - `java.io.EOFException: null` 在 Kafka 中列出主题时