简体   繁体   中英

How to move the position of a javascript based HTML element with CSS?

I wanted to move the date and time to some what down from the head. I am not getting how to do that:

  /* the CSS which I am using is */ p { text-align: center; margin-top: 15%; } 
 <p id="demo"></p> <script> document.getElementById("demo").innerHTML = Date(); </script> 

but it is not working.

Made a fiddle by copying and pasting your code... Seems to work just fine for me.

<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = Date();
</script>

Putting that in the html field is all you need, but I can't say why it isn't working in your code. Check for tags you haven't closed, extra or missing ', ", /, etc...

https://jsfiddle.net/of8692m3/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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