gpt4 book ai didi

css - 如何将工作时钟转换为文本?

转载 作者:太空宇宙 更新时间:2023-11-04 12:04:57 26 4
gpt4 key购买 nike

我正在尝试将实时时钟放入文本正文中。我需要它像文本的一部分一样流动,但仍然对本地设备有效。在 Adob​​e Muse 中玩转我已经能够在文本中找到时钟,但它把自己隔离在自己的行中,而不是像段落的一部分那样流动。

以下是 Muse 生成的代码。我假设我需要对 actAsInlineDiv normal_textactAsDiv excludeFromNormalFlow 或两者进行更改,但如何更改?

 <p id="u3202-10"><span class="Character-Style">You look at the clock on this device and it reads </span><span class="Character-Style"><span class="actAsInlineDiv normal_text" id="u13390"><!-- content --><span class="actAsDiv excludeFromNormalFlow" id="u13388"><!-- custom html --><html>
<head>
<script type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
// add a zero in front of numbers<10
m=checkTime(m);

document.getElementById('txt').innerHTML=h+":"+m;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
</span></span></span><span class="Character-Style">As a result you believe that this is the time. As it happens this is the time but unknown to you your device's clock has stopped functioning and is stuck. Does your true belief that this is the time count as knowledge?</span></p>

最佳答案

我不知道 Muse,但如果你想要的只是一个当前时间的时钟与一些文本内联运行,你可以这样做:

window.onload = displayTime;
function displayTime() {
var element = document.getElementById("clock");
var now = new Date();
var options = {hour: '2-digit', minute:'2-digit'};
element.innerHTML = now.toLocaleTimeString(navigator.language, options);
setTimeout(displayTime, 1000);
}
The current time is <span id="clock"></span> and it's inline with text.

编辑

我添加了这两行以按照您在评论中的要求从显示中删除秒数。

var options = {hour: '2-digit', minute:'2-digit'};
element.innerHTML = now.toLocaleTimeString(navigator.language, options);

关于css - 如何将工作时钟转换为文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29453796/

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