html - 无论 css 如何,都无法调整网页上的数据馈送位置

标签 html css feed

我正在尝试实现 Box Office Mojo 从他们的网站提供的数据提要,他们说添加这行代码应该会显示提要:

<script type="text/javascript" language="javascript" src="http://www.boxofficemojo.com/data/js/wknd5.php">

这行得通,但我的问题是它默认位于页面的最左侧,看起来很奇怪(警告,大图)。

Box Office Mojo feed

我将所述脚本包装在 p 中标签,像这样:

<p id="boxOffice"><script type="text/javascript" language="javascript" src="http://www.boxofficemojo.com/data/js/wknd5.php"></script></p>

和带有 position 的样式标签,但我尝试过的所有选项都没有移动它。你们有没有想过要搬家的?我被困在这里。

最佳答案

你想要它在中心吗?有多种方法可以做到这一点。

方法 1. 使用 <center>标签

<center><script type="text/javascript" language="javascript" src="http://www.boxofficemojo.com/data/js/wknd5.php"></script></center>

你的表格应该像这样居中: enter image description here







方法二<head>后面添加如下代码标签:

<style type="text/css">
    table {
        margin: 0px auto;
    }
</style>

它会做同样的事情。





方法 3. 使用 <div>标签:

<div class="mytable"><script type="text/javascript" language="javascript" src="http://www.boxofficemojo.com/data/js/wknd5.php"></script></div>

而且您可以使用 css 将表格放在您想要的任何位置:

.mytable {
    text-align: center;
}





这是方法 1 的完整代码:

<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<center><script type="text/javascript" language="javascript" src="http://www.boxofficemojo.com/data/js/wknd5.php"></script></center>
</body>
</html>

关于html - 无论 css 如何,都无法调整网页上的数据馈送位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49824210/

相关文章:

javascript - 使用 bootstrap collapse 切换 glyphicon

html - 如何使边框在一部分透明?

html - 自定义 twitter bootstrap 的宽度

html - 如何在使用 css 自动分页后创建上边距?

css - 如何将字体添加到基于 create-react-app 的元素?

youtube - 如何获取YouTube中不切实际的 clown 的RSS?

javascript - 本地从canvas元素获取三个.js场景进行操作

javascript - 使用 jQuery 更改 <html> 的背景图像不起作用

rss - DZone 首页RSS 提要坏了?

android - 从 Facebook 公共(public)页面 Android 获取页面提要