/    Sign up×
Community /Pin to ProfileBookmark

how to insert a colon in a digital clock?

Hi
I had to insert a colon in the clock, so I wrapped the minutes in the span and then stylized it.
But to me it’s a bit of a weird way. How can this be done in another way?
Thanks!
https://codepen.io/ig20/pen/ExwrbBQ

to post a comment
CSS

6 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumJan 15.2022 — Usually `::before</C> and <C>::after</C> are fine, however in this case the colons can be inserted more easily by adding them to the HTML:
<CODE>getS('.clock').innerHTML = </code></span>${hh&lt;10 ? '0'+hh:hh}:${min&lt;10 ? '0'+min:min}:${ss&lt;10 ? '0'+ss:ss}`
Copy linkTweet thisAlerts:
@ig20authorJan 15.2022 — @Sempervivum#1641573

but how to place colons in the center vertically?
Copy linkTweet thisAlerts:
@SempervivumJan 15.2022 — I don't understand this question. The colons will be part of the text and will be arranged and aligned like any other character in the text.
Copy linkTweet thisAlerts:
@ig20authorJan 15.2022 — @Sempervivum#1641575

I mean, i need the colons to be a little higher and not on the text line
Copy linkTweet thisAlerts:
@SempervivumJan 15.2022 — Then you need to wrap them in span tags and shift them a bit upwards:
getS('.clock').innerHTML = <span><code>${hh&amp;lt;10 ? '0'+hh:hh}&amp;lt;span&amp;gt;:&amp;lt;/span&amp;gt;${min&amp;lt;10 ? '0'+min:min}&amp;lt;span&amp;gt;:&amp;lt;/span&amp;gt;${ss&amp;lt;10 ? '0'+ss:ss}</code></span>
``<i>
</i>.clock span{
position: relative;
bottom: 0.1em;
}<i>
</i>
``
Copy linkTweet thisAlerts:
@ig20authorJan 15.2022 — @Sempervivum#1641577

very nice

Thanks!
×

Success!

Help @ig20 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...