2017-10-17 8 views
0

<span id="milliseconds">00</span>を正しく揃えるにはどうすればよいですか?div内のCSSでコンテンツを右揃えにしますか?

以下の作業のコードを参照してください:インライン要素で

@font-face { 
 
    font-family: "Digi"; 
 
    src: url("fonts/ds-digib.ttf"); 
 
} 
 

 
body { 
 
    font-family: Arial; 
 
    font-size: 80px; 
 
    font-weight: bold; 
 
    padding: 40px 0; 
 
} 
 

 
#container { 
 
    display: flex; 
 
    flex-direction: row; 
 
    justify-content: space-around; 
 
} 
 

 
#splits { 
 
    font-size: 40px; 
 
    padding: 0px; 
 
    font-weight: normal; 
 
} 
 

 
#clock { 
 
    border: 2px solid #000; 
 
    border-radius: 20px; 
 
    box-sizing: border-box; 
 
    height: 250px; 
 
    margin: 0 auto; 
 
    padding: 18px 0; 
 
    width: 245px; 
 
} 
 

 
#sphere { 
 
    border: 2px solid #000; 
 
    border-radius: 20px; 
 
    box-sizing: border-box; 
 
    font-family: "Digi"; 
 
    font-size: 80px; 
 
    height: 210px; 
 
    margin: 0 auto; 
 
    padding: 35px 0 0 5px; 
 
    position: relative; 
 
    width: 220px; 
 
} 
 

 
#digits { 
 
    display: flex; 
 
    flex-direction: column; 
 
} 
 
#digits-milliseconds { 
 
    font-size: 35px; 
 
} 
 
.leash { 
 
    background: rgb(204, 84, 87); 
 
    border: 2px solid rgb(134, 59, 61); 
 
    height: 50px; 
 
    margin: 0 auto; 
 
    width: 120px; 
 
} 
 

 
.leash-top { 
 
    border-bottom: 0; 
 
    border-top-left-radius: 10px; 
 
    border-top-right-radius: 10px; 
 
} 
 

 
.leash-bottom { 
 
    border-bottom-left-radius: 10px; 
 
    border-bottom-right-radius: 10px; 
 
    border-top: 0; 
 
    height: 270px; 
 
    padding-top: 50px; 
 
} 
 

 
.hole { 
 
    background: #fff; 
 
    border: 2px solid rgb(134, 59, 61); 
 
    border-radius: 100%; 
 
    height: 20px; 
 
    margin: 0 auto 50px; 
 
    width: 20px; 
 
} 
 

 
.number { 
 
    display: inline-block; 
 
    width: 16px; 
 
    margin-right: 8px; 
 
} 
 

 
.btn { 
 
    border: 0; 
 
    border-radius: 100%; 
 
    bottom: 10px; 
 
    color: #fff; 
 
    cursor: pointer; 
 
    height: 50px; 
 
    outline: 0; 
 
    position: absolute; 
 
    width: 50px; 
 
} 
 

 
.btn.start, 
 
.btn.stop { 
 
    left: 10px; 
 
} 
 

 
.btn.reset, 
 
.btn.split { 
 
    right: 10px; 
 
} 
 

 
.btn.start { 
 
    background: #5fca5f; 
 
} 
 
.btn.stop { 
 
    background: #f14949; 
 
} 
 
.btn.reset { 
 
    background: #908e8e; 
 
} 
 
.btn.split { 
 
    background: #0851ab; 
 
}
<!DOCTYPE html> 
 
<html lang="en"> 
 

 
<head> 
 
    <meta charset="UTF-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 
    <meta http-equiv="X-UA-Compatible" content="ie=edge"> 
 
    <title>Chronometer</title> 
 
    <link rel="stylesheet" href="styles.css"> 
 
</head> 
 

 
<body> 
 
    <div id="container"> 
 
    <div id="splits"> 
 
     <strong>Splits</strong> 
 
     <ol id="split-times"> 
 
     </ol> 
 
    </div> 
 
    <div class="watch"> 
 
     <div class="leash leash-top"></div> 
 
     <section id="clock"> 
 
     <div id="sphere"> 
 
      <div id="digits"> 
 
      <div> 
 
       <span id="minDec" class="number">0</span> 
 
       <span id="minCen" class="number">0</span> 
 
       <span>:</span> 
 
       <span id="secDec" class="number">0</span> 
 
       <span id="secCen" class="number">0</span> 
 
      </div> 
 
      <div id="digits-milliseconds"> 
 
       <span id="milliseconds">00</span> 
 
      </div> 
 
      </div> 
 
      <button id="btnLeft" class="btn start">START</button> 
 
      <button id="btnRight" class="btn reset">RESET</button> 
 
     </div> 
 
     </section> 
 
     <div class="leash leash-bottom"> 
 
     <div class="hole"></div> 
 
     <div class="hole"></div> 
 
     <div class="hole"></div> 
 
     </div> 
 
    </div> 
 
    </div> 
 

 
    <script src="chronometer.js" type="text/javascript"></script> 
 
    <script src="main.js" type="text/javascript"></script> 
 

 
</body> 
 

 
</html>

+1

セット 'テキスト整列:右;'親要素 '#桁-milliseconds'に。 – Krusader

答えて

1
#milliseconds{ 
    display: block; 
    text-align: right; 
} 
0

<span>をし、整列することになっていません。 親divを整列させるだけです。

私はより広い画像を見ることはできませんが、他のスパンと一緒にミリ秒のスパンを配置しないのはなぜですか?あなたが書いた構造の目的は何ですか?フォントサイズについてのみですか?そしてなぜミリ秒がフレックスになっていないのでしょうか?

0

はちょうどこの操作を行います。

#digits-milliseconds { 
text-align: right; 
} 
関連する問題