Html div内的中心元素(圆)

Html div内的中心元素(圆),html,css,Html,Css,如何使元素在圆内居中。下面是一个例子。我需要做什么,以中心内分区。我正在尝试与保证金:0自动;但没什么:(。你们知道怎么做吗。我需要把计数器放在圆圈的中心 Html JS “严格使用”; 函数更新程序(截止日期){ var时间=截止日期-新日期(); 返回{ 小时数:数学楼层(时间/(1000*60*60)%24), 分钟:数学地板(时间/1000/60%60), 秒:数学地板(时间/1000%60), 总计:时间 }; } 函数animateClock(span){ span.classNam

如何使元素在圆内居中。下面是一个例子。我需要做什么,以中心内分区。我正在尝试与保证金:0自动;但没什么:(。你们知道怎么做吗。我需要把计数器放在圆圈的中心

Html

JS

“严格使用”;
函数更新程序(截止日期){
var时间=截止日期-新日期();
返回{
小时数:数学楼层(时间/(1000*60*60)%24),
分钟:数学地板(时间/1000/60%60),
秒:数学地板(时间/1000%60),
总计:时间
};
}
函数animateClock(span){
span.className=“转身”;
setTimeout(函数(){
span.className=“”;
}, 700);
}
函数startTimer(id、截止日期){
var timerInterval=setInterval(函数(){
var clock=document.getElementById(id);
var定时器=更新定时器(截止日期);
clock.innerHTML=“”+timer.hours+“”+timer.minutes+“”+timer.seconds+“”;
var span=clock.getElementsByTagName(“span”);
AnimateLock(跨度[2]);
如果(timer.seconds==59){
AnimateLock(跨度[1]);
}
如果(timer.minutes==59&&timer.seconds==59){
animateClock(跨度[0]);
}
如果(计时器总数<1){
clearInterval(timerInterval);
clock.innerHTML=“000”;
}
}, 1000);
}
window.onload=函数(){
var截止日期=新日期(“2018年1月1日12:00:00”);
startTimer(“时钟”,截止日期);
};
您可以使用flexbox

“严格使用”;
函数更新程序(截止日期){
var时间=截止日期-新日期();
返回{
小时数:数学楼层(时间/(1000*60*60)%24),
分钟:数学地板(时间/1000/60%60),
秒:数学地板(时间/1000%60),
总计:时间
};
}
函数animateClock(span){
span.className=“转身”;
setTimeout(函数(){
span.className=“”;
}, 700);
}
函数startTimer(id、截止日期){
var timerInterval=setInterval(函数(){
var clock=document.getElementById(id);
var定时器=更新定时器(截止日期);
clock.innerHTML=“”+timer.hours+“”+timer.minutes+“”+timer.seconds+“”;
var span=clock.getElementsByTagName(“span”);
AnimateLock(跨度[2]);
如果(timer.seconds==59){
AnimateLock(跨度[1]);
}
如果(timer.minutes==59&&timer.seconds==59){
animateClock(跨度[0]);
}
如果(计时器总数<1){
clearInterval(timerInterval);
clock.innerHTML=“000”;
}
}, 1000);
}
window.onload=函数(){
var截止日期=新日期(“2018年1月1日12:00:00”);
startTimer(“时钟”,截止日期);
};
*{margin:0;padding:0;框大小:border-box;}
身体{
字体系列:Ubuntu,无衬线;
}
h1{
颜色:#fff;
文本对齐:居中;
字体大小:74px;
字母间距:10px;
边缘底部:70像素;
}
#德尔倒数{
宽度:600px;
高度:600px;
利润率:15%;
背景色:rgba(255,0,0,0.3);
边界半径:50%;
边框样式:实心;
边框颜色:#0000ff;
位置:相对位置;
显示器:flex;
对齐项目:居中;
证明内容:中心;
弯曲方向:立柱;
}
#时钟,#单位{
宽度:100%;
显示器:flex;
证明内容:中心;
}
#时钟跨度{
文本对齐:居中;
字号:84px;
利润率:0.2.5%;
颜色:#fff;
填充:20px;
宽度:20%;
边界半径:20px;
框大小:边框框;
}
#时钟跨度:第n个孩子(1){
背景#fa5559;
}
#时钟跨度:第n个孩子(2){
背景#26c2b9;
}
#时钟跨度:第n个孩子(3){
背景:#f6bc58;
}
#钟:以后{
内容:'';
显示:块;
明确:两者皆有;
}
#单位跨度{
宽度:25%;
文本对齐:居中;
边缘顶部:30px;
颜色:#ddd;
文本转换:大写;
字体大小:13px;
字母间距:2px;
文本阴影:1px1px1pRGBA(10,10,10,0.7);
}
转弯{
动画:向前旋转0.7秒;
}
@关键帧旋转{
0% {
变换:旋转(0度);
}
100% {
变换:旋转(0度);
}
}

小时
会议记录
秒
<body>
     <div id="del-countdown"> 
      <div id="clock"></div>
      <div id="units">
        <span>Hours</span>
        <span>Minutes</span>
        <span>Seconds</span>
      </div>
    </div>

  </body>
* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: Ubuntu, sans-serif;
}

h1 {
  color: #fff;
  text-align: center;
  font-size: 74px;
  letter-spacing: 10px;
  margin-bottom: 70px;
}

#del-countdown {
  width: 600px;
  height: 600px;
  margin: 15% auto;
  background-color: rgba(255, 0, 0, 0.3);
  border-radius: 50%;
  border-style: solid;
  border-color: #0000ff;
}


#clock span {
  float: left;
  text-align: center;
  font-size: 84px;
  margin: 0 2.5%;
  color: #fff;
  padding: 20px;
  width: 20%;
  border-radius: 20px;
  box-sizing: border-box;
}
#clock span:nth-child(1) {
  background: #fa5559;
}
#clock span:nth-child(2) {
  background: #26c2b9;
}
#clock span:nth-child(3) {
  background: #f6bc58;
}

#clock:after {
  content: '';
  display: block;
  clear: both;
}

#units span {
  float: left;
  width: 25%;
  text-align: center;
  margin-top: 30px;
  color: #ddd;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 2px;
  text-shadow: 1px 1px 1px rgba(10, 10, 10, 0.7);
}


span.turn {
  animation: turn 0.7s ease forwards;
}

@keyframes turn {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(0deg);
  }
}
"use strict";

function updateTimer(deadline) {
  var time = deadline - new Date();
  return {
    hours: Math.floor(time / (1000 * 60 * 60) % 24),
    minutes: Math.floor(time / 1000 / 60 % 60),
    seconds: Math.floor(time / 1000 % 60),
    total: time
  };
}

function animateClock(span) {
  span.className = "turn";
  setTimeout(function () {
    span.className = "";
  }, 700);
}

function startTimer(id, deadline) {
  var timerInterval = setInterval(function () {
    var clock = document.getElementById(id);
    var timer = updateTimer(deadline);

    clock.innerHTML = "<span>" + timer.hours + "</span><span>" + timer.minutes + "</span><span>" + timer.seconds + "</span>";

    var spans = clock.getElementsByTagName("span");
    animateClock(spans[2]);

    if (timer.seconds == 59){
        animateClock(spans[1]);
    }

    if (timer.minutes == 59 && timer.seconds == 59){
        animateClock(spans[0]);
    }

    if (timer.total < 1) {
      clearInterval(timerInterval);
      clock.innerHTML = "<span>0</span><span>0</span><span>0</span>";
    }

  }, 1000);
}

window.onload = function () {
  var deadline = new Date("Jan 1, 2018 12:00:00");
  startTimer("clock", deadline);
};