简体   繁体   English

在HTML页面上放置Javascript标签

[英]Positioning Javascript Tag on HTML Page

I'm growing frustrated in positioning my javascript date in the center of my html page. 我越来越无法将javascript日期定位在html页面的中心。 Everything else is centered but the javascript date. 除JavaScript日期外,其他所有内容均居中。

Here's a screenshot: 这是屏幕截图:

在此处输入图片说明

My HTML: 我的HTML:

<section>
<a href="http://validator.w3.org/check?uri=http%3A%2F%2Fhills.ccsf.edu%2F~avu%2Fhw1.html" target="_blank"><img id="html5logo"src="images/html5_logo.png" alt="html5" height="50" width="50" /></a>

<a href="http://alturl.com/9kv4o" target="_blank"><img id="csslogo" src="images/css_logo.gif" alt="css" height="50" width="50" /></a>
</section>

<br />

<p id="pagelastupdated">Page last updated:</p>
<script type="text/javascript">
  document.write(document.lastModified);
</script>

And here's my CSS: 这是我的CSS:

section  {
    margin-top: 10px;
    margin-left: auto;
    margin-right: auto;
    width: 112px;
}

section img#html5logo  {
    display: inline;
    margin-left: auto;
    margin-right: auto;
}

section img#csslogo  {
    display: inline;
    margin-left: auto;
    margin-right: auto;
}

#pagelastupdated  {
    text-align: center;
}

script  {
    border: 4px solid purple;
}

PLEASE HELP ME! 请帮我!

You might try (adjusted to show two lines) 您可以尝试(调整为显示两行)

<p align="center" id="pagelastupdated">Page last updated:<br/>
<script type="text/javascript">
  document.write(document.lastModified);
</script>
</p>

尝试将结束段落标签移动到结束脚本标签之后,或将日期写入div包裹的文档中,然后将其居中。

您正在p标签之外写日期,这是您正在居中的日期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM