簡體   English   中英

如何使用 CSS 和 HTML 在圓圈上添加文本?

[英]How to add text onto a circle using CSS and HTML?

現在這是我的計時器

我希望計時器看起來像下面的圖片,帶有“停止”這個詞

以上是我的計時器當前的外觀。 我希望將“停止”一詞添加到我的計時器中,但我不知道怎么做。 請記住,它實際上是一個帶有文本類型的輸入,文本是時間本身。 我想在時間的頂部添加停止一詞。 HTML 代碼:

<input type="text" name="" value="Start" id="">

CSS 代碼:

  input[type=text]:focus {
  height: 150px;
  width: 150px;
  background-color:  white;
  caret-color: transparent;
  border-radius: 50%;
  display: inline-block;
  border: none;
  border-style: none;
  text-align: center;
  font-size: x-large;
  box-shadow: inset 0px 0px 0px 10px #FF8D3A;
}

您可以使用絕對定位:

 input[type=text]:focus { height: 150px; width: 150px; background-color: white; caret-color: transparent; border-radius: 50%; display: inline-block; border: none; border-style: none; text-align: center; font-size: x-large; box-shadow: inset 0px 0px 0px 10px #FF8D3A; } input[type=text]:focus + .notice{ display:block; } .group { position: relative; } .notice { color: #FF8D3A; font-size: 30px; position: absolute; left: 40px; top: 30px; display:none; }
 <div class="group"> <input type="text" name="" value="Start" id=""> <span class="notice">STOP</span> </div>

我可以通過使用 flex css 向您建議這個解決方案,另外,我提供了一個小 JS 來獲取計時器。

 function refresh() { var t = 1000; // rafraîchissement en millisecondes setTimeout('showDate()', t); } function showDate() { var date = new Date(); var h = date.getHours(); var m = date.getMinutes(); var s = date.getSeconds(); if (h < 10) { h = '0' + h; } if (m < 10) { m = '0' + m; } if (s < 10) { s = '0' + s; } document.getElementById('horloge').value = h + ':' + m + ':' + s; refresh(); }
 .circle { display: flex; justify-content: center; height: 150px; width: 150px; border-radius: 100%; border: none; text-align: center; font-size: x-large; box-shadow: inset 0px 0px 0px 10px #FF8D3A; } .circle div { align-self: center; } .circle b { color: #FF8D3A; } .circle input { width:70%; border:none; text-align:center; font-size: x-large; }
 <html> <head> <body onload="showDate()"> <div class="circle"> <div> <b>STOP</b> <input type="text" value="00:39:43" id="horloge" /> </div> </div> </body> </head> </html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM