CSS - overflow-block 属性



CSS overflow-block 属性决定了元素内容超出其盒子左右边界时的行为。

属性 overflow-block 仅在 Firefox 浏览器中受支持。

可能的值

  • visible − 内容允许溢出元素的盒子。

  • hidden − 溢出的内容被隐藏。

  • clip − clip 溢出值裁剪溢出的内容并使其不可见。

  • scroll − 通过添加滚动条使元素可滚动。

  • auto − 添加滚动条到元素,以便用户可以查看其溢出的内容。

应用于

所有 HTML 元素。

DOM 语法

object.style.overflowBlock = "visible|hidden|clip|scroll|auto";
属性 overflow-block 仅在 Firefox 浏览器中受支持。因此,所有示例仅在 Firefox 浏览器中有效。

CSS overflow-block - 使用 visible 和 hidden 值

overflow-block 属性控制元素的内容是否可以溢出其边界。visible 值允许内容溢出,而 hidden 值隐藏任何溢出的内容。

<html>
<head>
<style>
   .container {
      display:flex;
   }
   div.overflow-block-visible {
      background-color: #2fe262;
      border: 2px solid #000000;
      width: 170px;
      height: 160px;
      overflow-block: visible;
      margin-right: 100px;
   }
   h4 {
      text-align: center;
      color: #D90F0F;
   }
   div.overflow-block-hidden {
      background-color: #2fe262;
      border: 2px solid #000000;
      width: 170px;
      height: 160px;
      overflow-block: hidden;
   }
</style>
</head>
<body>
   <div class="container">
      <div class="overflow-block-visible">
         <h4>Tutorialspoint CSS Overflow-block Visible</h4>
         Lorem Ipsum is simply dummy text of the printing and typesetting industry. omnis dolor repellendus. non-characteristic words, Temporibus autem quibusdam et
      </div>
      <div class="overflow-block-hidden">
         <h4>Tutorialspoint CSS Overflow-block Hidden</h4>
         Lorem Ipsum is simply dummy text of the printing and typesetting industry. omnis dolor repellendus. non-characteristic words, Temporibus autem quibusdam et
      </div>
   </div>
</body>
</html>

CSS overflow-block - clip 值

overflow-block: clip 属性隐藏元素的任何溢出内容。不添加滚动条。

<html>
<head>
<style>
   div.overflow-block-clip {
      background-color: #2fe262;
      border: 2px solid #000000;
      width: 170px;
      height: 160px;
      overflow-block: clip;
   }
   h4 {
      text-align: center;
      color: #D90F0F;
   }
</style>
</head>
<body>
   <div class="overflow-block-clip">
      <h4<Tutorialspoint CSS Overflow-block Clip</h4>
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. omnis dolor repellendus. non-characteristic words, Temporibus autem quibusdam et
   </div>
</body>
</html>

CSS overflow-block - 使用 scroll 和 auto 值

overflow-block 属性设置为 scrollauto 时。scroll 始终添加滚动条,而 auto 仅在需要时添加滚动条。

<html>
<head>
<style>
   .container {
      display:flex;
   }
   div.overflow-block-scroll {
      background-color: #2fe262;
      border: 2px solid #000000;
      width: 170px;
      height: 160px;
      overflow-block: scroll;
      margin-right: 100px;
   }
   h4 {
      text-align: center;
      color: #D90F0F;
   }
   div.overflow-block-auto {
      background-color: #2fe262;
      border: 2px solid #000000;
      width: 170px;
      height: 160px;
      overflow-block: auto;
   }
</style>
</head>
<body>
   <div class="container">
      <div class="overflow-block-scroll">
         <h4>Tutorialspoint CSS Overflow-block Scroll</h4>
         Lorem Ipsum is simply dummy text of the printing and typesetting industry. omnis dolor repellendus. non-characteristic words, Temporibus autem quibusdam et
      </div>
      <div class="overflow-block-auto">
         <h4>Tutorialspoint CSS Overflow-block Auto</h4>
         Lorem Ipsum is simply dummy text of the printing and typesetting industry. omnis dolor repellendus. non-characteristic words, Temporibus autem quibusdam et
      </div>
   </div>
</body>
</html>
广告

© . All rights reserved.