元素的显示与隐藏 display、visibility、overflow

在CSS中有三个显示和隐藏的单词比较常见,我们要区分开,他们分别是 display、visibilityoverflow

display: none;隐藏某个元素 不保留位置

display: block  显示某个元素

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    div {
        width: 200px;
        height: 100px;
        background-color: pink;
        display: none;/* display: none隐藏某个元素,不保留位置;display: block显示某个元素 */
    }
    p {
        width: 200px;
        height: 100px;
        background-color: red;
    }
    </style>
</head>
<body>
    <div></div>
    <p>测试</p>
</body>
</html>
View Code

相关文章:

  • 2022-02-27
猜你喜欢
  • 2021-08-03
  • 2021-10-17
  • 2021-08-18
  • 2021-11-12
  • 2021-11-12
  • 2021-11-12
  • 2021-05-25
相关资源
相似解决方案