首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >两个元素(视频和图片)之间的间隙问题- HTML和CSS

两个元素(视频和图片)之间的间隙问题- HTML和CSS
EN

Stack Overflow用户
提问于 2021-07-21 22:38:22
回答 1查看 32关注 0票数 0

我正面临着一个我无法解决的问题。

在HTML和CSS中,我插入了一段视频,然后插入了一张图片作为背景,并对其进行了格式化。但是,视频和图像(两个元素)之间存在差距。我不能把这个弄走。

这里有人有解决方案吗?

多谢你们的支持。

HTML-代码:

代码语言:javascript
运行
复制
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Text</title>
    <link rel="stylesheet" href="Stil.css" />
</head>

<body>
    <div class="Start">

        <h1>TextText</h1>

        <div class="video-player">
            <div class="layer"></div>
            <video autoplay loop muted>
                <source src="video.mp4" type="video/mp4">
            </video>
        </div>

    </div>

    <article class="text">

        
        <section id="highlight">
            <div>
                <header>
                    <p> text,text,text,text.
                    </p>
        </section>
    </article>
</body>

</html>

CSS-代码:

代码语言:javascript
运行
复制
html {
  color:black;
  margin-top: 0;
  margin-bottom: 0;
  margin-left: 0;
  margin-right: 0;
  font-size: 14px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  margin: 0;
  padding: 0;

}

.Start {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow:hidden;
  }
  
  .Start h1 {
    text-align: center;
    color: cornsilk;
    font-size: 10em;
    font-family: "Cookie";
    padding: 0px;
    margin: 0px;
    z-index: 1;
    opacity: 1;
  }
  
  .video-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    margin: 0mm;
  }
  
  .layer{
    position: absolute;
    background-color: rgb(0, 0, 0);
    width: 100%;
    height: 100vh;
    opacity: 0.8;
    margin: 0mm;
  }

  .text{
    background-image: url("picture.png");
    background-position: center;
    background-size:cover;
    margin-bottom:0em;
    padding-bottom: 0em;
    padding-top: 0em;
    margin-top: 0em;
    height: 70em;
  }

  section[id="highlight"]{
    font-size: 2em;
    color:white;
    text-align: center;
    line-height: 3em;
    font-style:italic
}
EN

回答 1

Stack Overflow用户

发布于 2021-07-21 22:46:31

代码语言:javascript
运行
复制
section[id="highlight"] {
   overflow:hidden
}

问题可能出在段落标记上,因此您要么使用上面的标记,要么删除段落的页边距顶部

代码语言:javascript
运行
复制
section[id="highlight"] p {
     margin-top:0;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68471524

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档