在 CSS 中显示 None

cssweb developmentfront end technology更新于 2024/11/29 2:20:17

要移除元素,请在 CSS 中使用 display none 属性值。让我们看一个实现 none 属性值 − 的示例。

示例

现在来看一个例子 −

<!DOCTYPE html>
<html>
<head>
<style>
span {
   background-color: orange;
   color: white;
}
p.demo {
   display: none;
}
span.demo1 {
   display: inline;
}
</style>
</head>
<body>
<h1>Match Details</h1>
<div>
Match will begin at <p class="demo">9AM</p> 10AM on 20th December.
</div>
<div>
Match will end at <span class="demo1">5PM</span> on 20th December.
</div>
</body>
</html>

输出

示例

现在让我们看另一个例子 −

<!DOCTYPE html>
<html>
<head>
<style>
span {
   display: none;
}
.demo2 {
   text-decoration: underline;
   text-decoration-style: double;
   text-decoration-color: red;
}
</style>
</head>
<body>
<h1>Details</h1>
<p class="demo">Examination Center near <span>XYZ College</span> ABC College.</p>
<p class="demo2">Exam begins at 11AM.</p>
</body>
</html>

输出


相关文章


有用资源