我是HTML和CSS的初学者,我正在尝试推出一个简单的网站,其中包含一个来自第三方网站的iframe和内置的Twitter时间线小部件。
1920x1080版本看起来都很好,但是当我使用媒体查询使其响应时,Twitter时间轴小部件就会溢出到页脚或我在其下面放在html中的任何其他元素上。更重要的是,它没有溢出,更重要的是,当页脚或任何其他元素出现时,时间线就开始出现。
相关的HTML和CSS,以及下面的截图。非常感谢大家!
HTML
<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
.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;
}
}发布于 2022-09-05 08:04:37
使用以下CSS:
.subte-div {
width: 100%;
margin-left: auto;
margin-right: auto;
display: flex;
justify-content: center;
height: auto;
}输出:

发布于 2022-09-05 06:22:46
你的问题如下:
.subte-div设置为600 to高度。iframe占用600px和height="600"tweets div位于.微妙-div内,并具有data-height="500"。所有这些事情都会导致溢出问题,因为您将.subte-div设置为高度的600px。您的iframe和tweets div都在其中,占据了600px + 500px =1100 an高度的高度,这会导致溢出。
我建议尝试将tweets div从.subte-div中取出,并尽量避免px值设置高度/宽度,因为它被认为是一种不好的做法,可能会引起响应问题,在您的情况下也是如此。溢出。
https://stackoverflow.com/questions/73605156
复制相似问题