css id选择器阻止所有内容显示在android 10上的xamarin.forms webview中

cmssoen2  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(215)

我有一个 WebView 我将一个html代码段分配给使用 HtmlWebViewSource 分配给 Source .
自从瞄准安卓10以来 WebView 已停止显示所有内容。
我已经缩小了一个字符,使内容显示和不显示内容之间的区别。html包含一个 <style> 节。如果它包含。。。

hello {}

... 然后内容显示出来。好像它包含。。。


# hello {}

... 然后没有内容显示( hello 没有提到任何东西。)
显然,#字符表示id选择器。
那么,为什么针对安卓10会突然让我的html停止显示基于css中如此简单的更改?
我进一步缩小了范围。在 <head> 标签。。。 <style>#</style> ->没有html显示 <style></style> ->html显示。 <style>.</style> ->html显示。
我还在查马林。

z5btuh9x

z5btuh9x1#

下面的代码适用于我。请检查一下。

<!DOCTYPE html>
<html>
<head>
<style>
/* Style the element with the id "hello" */

# hello {

  background-color: lightblue;
  color: black;
  padding: 30px;
  text-align: center;
}

/* Style all elements with the class name "Line" */
.Line {
  background-color: #9815B0;
  color: white;
  padding: 10px;
}
</style>
</head>
<body>

<!-- An element with a unique id -->
<h1 id="hello">Page1</h1>

<!-- Multiple elements with same class -->
<h2 class="Line">Line1</h2>
<p>number 1.</p>

<h2 class="Line">Line2</h2>
<p>number 2.</p>

<h2 class="Line">Line3</h2>
<p>number 3.</p>

</body>
</html>

相关问题