div之间的小差距

时间:2021-01-25 01:16:28

标签: html css

我已经尝试将字体大小设置为 0 没有边距或仅填充内容框,但它在 div 之间仍然有小间隙 知道为什么会发生这种情况吗?是否有任何解决方案可以解决此问题,因为我希望它没有间隙,因为没有边距填充

我用来包含 iframe 的 .video 内部也有间隙,我将 iframe 设置为 100% 高度,因此它采用 .video 容器的全高,但问题是当我查看 .video 的元素框时。视频的高度是 158 像素,当我查看 iframe 时,它​​是 154 像素,为什么会这样?

Small White gaps

 .video-section-wrapper {
        width: 100%;
        height: 300px;
        background-color: whitesmoke;
        position: absolute;
        top: 180px;
        border-radius: 4px;
        border-top: orange 5px solid;
        border-bottom: orange 5px solid;
        box-sizing: border-box;
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    .video-section-box {
        height: 90%;
        width: 27%;
        border: solid black 5px;
        box-sizing: border-box;
        box-shadow: 1px 1px 2px 2px rgba(0,0,0,0.5),-1px -1px 2px 2px rgba(0,0,0,0.5);
        transition: ease-in-out 0.5s;
        overflow: hidden;
    }

    .video-section-box:hover {
        height: 93%;
        width: 30%;
    }

    .video-section-box > .video {
        width: 100%;
    }

    .video-section-box > .video > iframe {
        width: inherit;
        box-sizing: content-box;
        border: none;
        height: 100%;
    }

    .video-section-box > .subtitle-wrapper {
        border-top: rgba(0,0,0,0.5) solid 5px;
        height: 92px;
        width: 100%;
        position: relative;
    }

    .video-section-box > .subtitle-wrapper > .subtitle-header {
        padding-left: 5px;
        background-color: white;
        box-sizing: border-box;
        padding-bottom: 0px;
        margin-bottom: 0px;
        border-bottom: 0px;
    }

    .video-section-box > .subtitle-wrapper > .subtitle-header > h {
        background-color: black;
        color: wheat;
        font-weight: bold;
        background-size: 300px 300px;
        border-top-left-radius: 4px;
        border-top-right-radius: 4px;
        padding-left: 30px;
        padding-right: 30px;
    }

    .video-section-box > .subtitle-wrapper > .subtitle-content {
        background-color: black;
        margin: 0px;
        outline: 0px;
        height: 84px;
        color: wheat;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    .capo-wrap {
        font-size: 17px;
        position: absolute;
        color: wheat;
        display: flex;
        align-items: flex-end;
        height: 78px;
    }

    .capo-wrap > p{
        margin: 0px;
    }

    .video-section-box > .subtitle-wrapper > .subtitle-content > .p {
        margin: 0px;
        padding-top: 0px;
        justify-content: center;
        align-items: center;
        text-align: center;
        font-weight: bolder;
        font-size: 30px;
    }
    <div class="video-section-box">
      <div class="video">
          <iframe>

          </iframe>
      </div>

      <div class="subtitle-wrapper">
          <div class="subtitle-header">
              <h>TUNING</h>                    
          </div>

          <div class="capo-wrap"><p>Capo Fret :</p></div>

          <div class="subtitle-content">
              <div class="p">E A D G B E</div>
          </div>                    
      </div>
   </div>

2 个答案:

答案 0 :(得分:1)

display: inline-block 添加到 .video-section-box > .subtitle-wrapper > .subtitle-header > h 选择器。像这样:

.video-section-box > .subtitle-wrapper > .subtitle-header > h {
    ...
    display: inline-block;
}

答案 1 :(得分:0)

.video-section-box > .subtitle-wrapper > .subtitle 中将 ma​​rgin-bottom: 0px; 更改为 ma​​rgin-bottom: -1px; -header {

.video-section-wrapper {
        width: 100%;
        height: 300px;
        background-color: whitesmoke;
        position: absolute;
        top: 180px;
        border-radius: 4px;
        border-top: orange 5px solid;
        border-bottom: orange 5px solid;
        box-sizing: border-box;
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    .video-section-box {
        height: 90%;
        width: 27%;
        border: solid black 5px;
        box-sizing: border-box;
        box-shadow: 1px 1px 2px 2px rgba(0,0,0,0.5),-1px -1px 2px 2px rgba(0,0,0,0.5);
        transition: ease-in-out 0.5s;
        overflow: hidden;
    }

    .video-section-box:hover {
        height: 93%;
        width: 30%;
    }

    .video-section-box > .video {
        width: 100%;
    }

    .video-section-box > .video > iframe {
        width: inherit;
        box-sizing: content-box;
        border: none;
        height: 100%;
    }

    .video-section-box > .subtitle-wrapper {
        border-top: rgba(0,0,0,0.5) solid 5px;
        height: 92px;
        width: 100%;
        position: relative;
    }

    .video-section-box > .subtitle-wrapper > .subtitle-header {
        padding-left: 5px;
        background-color: white;
        box-sizing: border-box;
        padding-bottom: 0px;
        margin-bottom: -1px;
        border-bottom: 0px;
    }

    .video-section-box > .subtitle-wrapper > .subtitle-header > h {
        background-color: black;
        color: wheat;
        font-weight: bold;
        background-size: 300px 300px;
        border-top-left-radius: 4px;
        border-top-right-radius: 4px;
        padding-left: 30px;
        padding-right: 30px;
    }

    .video-section-box > .subtitle-wrapper > .subtitle-content {
        background-color: black;
        margin: 0px;
        outline: 0px;
        height: 84px;
        color: wheat;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    .capo-wrap {
        font-size: 17px;
        position: absolute;
        color: wheat;
        display: flex;
        align-items: flex-end;
        height: 78px;
    }

    .capo-wrap > p{
        margin: 0px;
    }

    .video-section-box > .subtitle-wrapper > .subtitle-content > .p {
        margin: 0px;
        padding-top: 0px;
        justify-content: center;
        align-items: center;
        text-align: center;
        font-weight: bolder;
        font-size: 30px;
        display: inline-block;
    }
 <div class="video-section-box">
      <div class="video">
          <iframe>

          </iframe>
      </div>

      <div class="subtitle-wrapper">
          <div class="subtitle-header">
              <h>TUNING</h>                    
          </div>

          <div class="capo-wrap"><p>Capo Fret :</p></div>

          <div class="subtitle-content">
              <div class="p">E A D G B E</div>
          </div>                    
      </div>
   </div>

相关问题