使用 CSS 实现内联显示

cssweb developmentfront end technology更新于 2024/11/29 1:48:17

与块元素不同,内联元素本身就位于同一行,并且仅占用分配的宽度。现在让我们看一个在 CSS 中实现 display: inline 属性值 − 的示例。

示例

现在让我们看一个例子 −

<!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#demo {
   background-color:orange;
   color: white;
   display:inline;
}
</style>
</head>
<body>
<h1>Match Details</h1>
<div>
Match will begin at <span id="demo">9AM</span> on 20th December.
</div>
</body>
</html>

输出


相关文章


有用资源