簡體   English   中英

在HTML頁面上放置Javascript標簽

[英]Positioning Javascript Tag on HTML Page

我越來越無法將javascript日期定位在html頁面的中心。 除JavaScript日期外,其他所有內容均居中。

這是屏幕截圖:

在此處輸入圖片說明

我的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>

這是我的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;
}

請幫我!

您可以嘗試(調整為顯示兩行)

<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