[TIL 11]Wecolor Picker構成部品の作成


#709f0箱がカラーボックスに置かれている場合にのみ,設定の課題が見られる.:hoverの機能を学習し,css属性にマウスを配置したときの特殊な状況を示した.
不透明度によって、透明度をどのように与えるかを学ぶことができます.
また、:hover機能を利用して、マウスをハートフレームにぶら下げると、色の変化も構成されています.
  • htmlコード
  • <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width">
        <title>repl.it</title>
        <link href="style.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" crossorigin="anonymous">
      </head>
      <body>
        <div class="content">
          <div class="mainBox">
            <div class="colorBox">
              <span class="hex">#709fb0</span>
            </div>
            <div class="inform">
              <button>
                <div class="heartIcon">
                  <i class="fas fa-heart"></i>
                </div>
                <div class="count">
                  <span>451</span>
                </div>
              </button>
              <div class="date">
                <span>3days</span>
              </div>
            </div>
          </div>
        </div>
      </body>
    </html>
  • cssコード
  • * {
      box-sizing: border-box;
      padding: 0;
      margin: 0;
    }
    
    .content {
      display: flex;
      justify-content: center;
    }
    .mainBox {
      width: 60%;
      height: 450px;    /* 높이도 자동으로 변하게 하려면 어떻게 해야하지?? */
      margin: 20px;
      background-color: #ebeff4;
      border-radius: 8px;
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    
    .colorBox {
      width: 90%;
      height: 75%;
      background-color: #709fb0;
      border-radius: 8px;
      margin-top: 5%;
      position: relative;
    }
    
    .inform {
      width: 100%;
      height: 20%;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    
    button {
      display: flex;
      justify-content: space-between;
      position: relative;
      left: 5%;
      border: 1px solid black;
      border-radius: 8px;
      background-color: #ebeff4;
      font-size: 20px;
    }
    
    button:hover {
      display: flex;
      justify-content: space-between;
      position: relative;
      left: 5%;
      border: 1px solid black;
      border-radius: 8px;
      background-color: #ebeff4;
      font-size: 20px;
      opacity: 0.5;
    }
    
    button:hover .heartIcon {
      color: red;
    }
    
    .heartIcon, .count {
      font-weight: bold;
      padding: 10px;
    }
    
    .date {
      position: relative;
      right: 5%;
      font-weight: bold;
      font-size: 20px;
    }
    
    .hex {
      position: absolute;
      bottom: 5%;
      background-color: #578291;
      color: white;
      font-size: 15px;
      padding: 4px 7px;
      opacity: 0;
    }
    
    .colorBox:hover .hex {
      position: absolute;
      bottom: 5%;
      background-color: #578291;
      color: white;
      font-size: 15px;
      padding: 4px 7px;
      opacity: 1;
    }