๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Lect & Tip/html, css, scss

์„ฑ๋ณ„ ํ†ต๊ณ„ CSS ๋””์ž์ธ ๋ฐ SASS

by ๋‚ฏ์„ ๊ณต๊ฐ„2019 2019. 12. 9.

โœˆ ์„ฑ๋ณ„ ํ†ต๊ณ„ CSS ๋””์ž์ธ ๋ฐ SASS

์„ฑ๋ณ„ ํ†ต๊ณ„ CSS ๋””์ž์ธ ๋ฐ SASS

์„ฑ๋ณ„ ์ฐจํŠธ ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ๋”ฑ ๋””์ž์ธ์— ๋งž๋Š”๊ฒŒ ์—†์–ด์„œ ์•„๋ž˜์™€ ๊ฐ™์ด ๋งŒ๋“ค์–ด๋ดค๋‹ค.

์›๋ฆฌ ์ž์ฒด๋Š” ๊ฐ„๋‹จํ•˜๋‹ค.

๊ทธ๋ƒฅ ๋ง‰๋Œ€๊ทธ๋ž˜ํ”„์—์„œ ํผ์„ผํŠธ ํ†ต๊ณ„ ๊ทธ๋ ค์ฃผ๋Š” ๊ฒƒ๊ณผ ๊ฐ™๋‹ค.

๋‹ค๋งŒ ๋‹ค๋ฅธ ์ ์€ BG๊ฐ€ ํ•„์š”ํ•œ ๊ฒƒ ๋ฟ์ด๋‹ค.

๊ธฐ๋ณธ์ ์œผ๋กœ ์ฑ„์›Œ์ ธ ์žˆ์ง€ ์•Š์€ ํ…Œ๋‘๋ฆฌ๋งŒ ์žˆ๋Š” ์„ฑ๋ณ„ BG๋ฅผ ๋ถ€๋ชจ ๊ฐ์ฒด์— background๋กœ ์ค€๋‹ค.

์ดํ›„ ๋ฐ์ดํ„ฐ๋ฅผ ํ‘œ์‹œํ•˜๋Š” ์—˜๋ ˆ๋จผํŠธ๋Š” ์ƒ‰์„ ๊ฐ€์ง„ BG๋ฅผ background๋กœ ๋ฐ›๋Š”๋‹ค.

์ƒ‰์ด ๋จธ๋ฆฌ์—์„œ๋ถ€ํ„ฐ ์น ํ•ด์ง„๋‹ค๋ฉด background position์€ top์ด๊ฒ ์ง€๋งŒ ๋ณดํ†ต ์ด๋Ÿฐ ์ฐจํŠธ๋Š” ๋‹ค๋ฆฌ๋ถ€ํ„ฐ ์ƒ‰์ด ์น ํ•ด์ ธ ์˜ฌ๋ผ๊ฐ€์•ผ ํ•˜๋ฏ€๋กœ bottom์„ ์ค€๋‹ค. ๊ด€๋ จ BG๋Š” ์•„๋ž˜์— ์ฒจ๋ถ€ํ•ด ๋‘๋„๋ก ํ•˜๊ฒ ๋‹ค.

bg.zip
0.01MB

์†Œ์Šค์ฝ”๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

html

              <ul class="chartSex">
                <li>
                  <dl>
                    <dt>์—ฌ์„ฑ</dt>
                    <dd class="stat-cs-data1 female">
                      <div class="data-bar" style="height:73%"></div>
                    </dd>
                    <dd class="stat-cs-percent">73%</dd>
                    <dd class="stat-cs-count">7300</dd>
                  </dl>
                </li>
                <li>
                  <dl>
                    <dt>๋‚จ์„ฑ</dt>
                    <dd class="stat-cs-data1 male">
                      <div class="data-bar" style="height:27%"></div>
                    </dd>
                    <dd class="stat-cs-percent">27%</dd>
                    <dd class="stat-cs-count">2300</dd>
                  </dl>
                </li>
              </ul>

SASS

.chartSex {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: space-around;

  &>li {
    flex: 0 1 50%;

    &:nth-child(1) {
      padding-left: 50px;
    }

    &:nth-child(2) {
      padding-right: 50px;
    }

    dl {
      dt {
        position: absolute;
        width: 0;
        height: 0;
        overflow: hidden;
      }

      dd {
        &.stat-cs-data1 {
          width: 68px;
          height: 136px;
          margin: 0 auto 20px auto;
          display: flex;
          flex-direction: column;
          justify-content: flex-end;

          .data-bar {
            display: block;
            margin-bottom: 0;
            width: 100%;
          }

          &.female {
            background: url(/assets/images/bg/stat_female.png) center bottom no-repeat;

            .data-bar {
              background: url(/assets/images/bg/stat_female_on.png) center bottom no-repeat;
            }
          }

          &.male {
            background: url(/assets/images/bg/stat_male.png) center bottom no-repeat;

            .data-bar {
              background: url(/assets/images/bg/stat_male_on.png) center bottom no-repeat;
            }
          }
        }

        &.stat-cs-percent {
          font-size: 14px;
          font-weight: 500;
          color: $color-blk;
          margin-bottom: 5px;
        }

        &.stat-cs-count {
          font-size: 11px;
        }
      }
    }
  }
}

์Šฌ๋žœ๋” ๋‹ˆํŠธ์›ํ”ผ์Šค ํ”ผํŒ…๋ชจ๋ธ

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€