首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >嵌入式Twitter小部件溢出页脚和其他元素

嵌入式Twitter小部件溢出页脚和其他元素
EN

Stack Overflow用户
提问于 2022-09-05 06:11:43
回答 2查看 39关注 0票数 0

我是HTML和CSS的初学者,我正在尝试推出一个简单的网站,其中包含一个来自第三方网站的iframe和内置的Twitter时间线小部件。

1920x1080版本看起来都很好,但是当我使用媒体查询使其响应时,Twitter时间轴小部件就会溢出到页脚或我在其下面放在html中的任何其他元素上。更重要的是,它没有溢出,更重要的是,当页脚或任何其他元素出现时,时间线就开始出现。

相关的HTML和CSS,以及下面的截图。非常感谢大家!

HTML

代码语言:javascript
运行
复制
    <main>    
    <h1>ESTADO DE RED DE SUBTE</h1>
    <div class="subte-div">
      <div class="tabla">
        <iframe class="frame" height="600" src="https://aplicacioneswp.metrovias.com.ar/estadolineas/desktop.html"></iframe>
      </div>
      <div class="tweets">
        <a class="twitter-timeline" data-lang="es" data-width="280" data-height="500" href="https://twitter.com/basubte?ref_src=twsrc%5Etfw">Tweets by basubte</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
      </div>
    </div>  
  <footer>
    <p class="footer-text">transporte.capital, 2022</p>
  </footer>
  </main>

CSS

代码语言:javascript
运行
复制
    .subte-div {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  justify-content: center;
  height: 600px;
}

.frame {
  border-width: 0px;
  border-style: solid;
  width: 350px;
  padding: 0;
  margin-right: 50px;
  display: flex;
}

footer {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  background-color: rgb(208, 206, 206);
}

.footer-text {
  font-size: 10px;
  font-weight: 700;
  padding: 0;
  color: rgb(57, 57, 57);
}

@media (max-width: 700px) {

  header {
    flex-direction: column;
    padding: 0;
  }

  .menu {
    display: flex;
    margin: 0;
    justify-content: space-around;
    width: 90%;
    gap: 5%;
    padding-bottom: 1em;
  }

  .subte-div{
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
  }
  
  .tabla, .tweets {
    margin: 0px;
    padding: 0px;
  }

  .footer-text {
    display: none;
  }

  .h1 {
    margin-bottom: 0px;
    padding-bottom: 0;
  }

}

屏幕截图

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-09-05 08:04:37

使用以下CSS:

代码语言:javascript
运行
复制
.subte-div {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  justify-content: center;
  height: auto;
}

输出:

票数 0
EN

Stack Overflow用户

发布于 2022-09-05 06:22:46

你的问题如下:

  • 在您的css中,.subte-div设置为600 to高度。
  • 您的iframe占用600pxheight="600"
  • 您的tweets div位于.微妙-div内,并具有data-height="500"

所有这些事情都会导致溢出问题,因为您将.subte-div设置为高度的600px。您的iframetweets div都在其中,占据了600px + 500px =1100 an高度的高度,这会导致溢出。

我建议尝试将tweets div从.subte-div中取出,并尽量避免px值设置高度/宽度,因为它被认为是一种不好的做法,可能会引起响应问题,在您的情况下也是如此。溢出。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73605156

复制
相关文章

相似问题

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