如何在子元素中使用真实的100%?

时间:2018-12-20 14:55:03

标签: html css

我尝试在父元素中使用不透明度值0.5,在子元素中使用不透明度值1

现在我要面对的事实是,父级值为孩子的100%净值。

如何在子元素中使用真实的100%?

<!DOCTYPE html>
<html>
<head>
<style>
img {
  opacity: 0.5;
  filter: alpha(opacity=50); /* For IE8 and earlier */
}

.parent {opacity: 0.5 }
.child {opacity: 1 }
</style>
</head>
<body>

<h1>Image Transparency</h1>

<div class="parent">
    <p>element 1 with opacity</p>
    <p class="child">element 2 without opacity</p>
</div>
<img src="img_forest.jpg" alt="Forest" width="170" height="100">

</body>
</html>

0 个答案:

没有答案