gpt4 book ai didi

javascript - 为什么 chrome 不为嵌入式 twitter 时间轴呈现 flexbox 定位?

转载 作者:行者123 更新时间:2023-11-27 23:02:17 25 4
gpt4 key购买 nike

谁能阐明为什么 Chrome(版本 78.0.3904.97)不遵守 flexbox css 将 Twitter 时间轴置于网页的中心?

使用 Twitter 生成的代码将 Twitter 时间轴嵌入到网页中,我发现尝试将时间轴居中在 Chrome 中被证明是不可能的。它在 Safari 中运行良好。

Safari screenshot showing the Twitter timeline centered in the twt class div Chrome screenshot showing the Twitter timeline left-aligned in the twt class div

/* html snippet */

<div class="twt">

<a class="twitter-timeline" data-width="640" data-height="860" href="https://twitter.com/PremierLake?ref_src=twsrc%5Etfw">Tweets by PremierLake</a>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

</div>

/* flexbox css */

.twt {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
align-content: stretch;
width: 100%;
height: 860px;
}

注意事项:我试过非flexbox传统定位。我不想使用绝对定位,因为 div 结构需要与页面上的周围元素一起流动。我已经浏览了 Twitter 开发说明,它们没有提供以时间线为中心的方法。这与可以居中的封装的单个推文不同。Twitter 时间线是来自单个 Twitter 提要的推文集合。

最佳答案

我没有得到答案,但我试过你的代码。它对我来说很好用! screenshot for both safari and chrome

尝试检查 chrome 中的元素,看看实际应用了哪些样式。

除了突出显示背景外,我没有更改您的代码。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<style>
/* flexbox css */

.twt {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
align-content: stretch;
width: 100%;
height: 860px;
background: yellow;
}
</style>
</head>
<body>
<h1>blalbalbalb</h1>
<div class="twt">
<a
class="twitter-timeline"
data-width="640"
data-height="860"
href="https://twitter.com/PremierLake?ref_src=twsrc%5Etfw"
>Tweets by PremierLake</a
>
<script
async
src="https://platform.twitter.com/widgets.js"
charset="utf-8"
></script>
</div>
</body>
</html>

] 2 ] 2

关于javascript - 为什么 chrome 不为嵌入式 twitter 时间轴呈现 flexbox 定位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58908435/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com