2020_12_26css
源碼html
<div class="container"> ... </div>
<h2>
標識, 每一個進度條用 <skills>
標識, 如圖所示<div class="container"> <h2>前端技能</h2> <div class="skills"> <span class="Name">Html</span> <div class="percent"> <div class="progress" ></div> </div> <span class="Value">95%</span> </div> ... </div>
<div class="skills"> <span class="Name">CSS</span> <div class="percent"> <div class="progress" ></div> </div> <span class="Value">90%</span> </div> <div class="skills"> <span class="Name">JavaScript</span> <div class="percent"> <div class="progress"></div> </div> <span class="Value">72%</span> </div> <div class="skills"> <span class="Name">frame</span> <div class="percent"> <div class="progress"></div> </div> <span class="Value">50%</span> </div>
*{ margin: 0; padding: 0; box-sizing: border-box; } body{ display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #2e2e2e; font-size: 16px; }
.container h2{ color: #fff; }
設置每行的格式, 上下邊距, 左右邊距, 設置過渡效果時間 0.5s .前端
margin 和 padding 有一個值, 有兩個值, 有三個值, 有四個值時賦予四個方向值的方式, 1個值, 上下左右這個值; 2個值, 分別表示上下和左右; 3個值, 分別表示上, 右, 下, 剩下一個左和右保存一致; 4個值, 分別表示, 上, 右, 下, 左佈局
.container .skills{ position: relative; display: flex; /* 只有兩個數值, 分別表示上下和左右, 上下 20px, 左右 0 */ margin: 20px 0; /* 上右下, 缺乏一個左, 左和右保持一致, 左的內邊距爲 10px */ padding: 24px 10px 18px; background: linear-gradient(#616161 0%, #333 10%, #222);; border-radius: 8px; overflow: hidden; border: 2px solid #000; transition: 0.5s; }
.container:hover .skills{ opacity: 0.05; } .container .skills:hover{ opacity: 1; transform: scale(1.1); }
.container .skills:before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 50%; background: rgba(255, 255, 255, .1); z-index: 10; }
width
屬性決定..container .skills .Name{ position: relative; width: 120px; text-align: right; color: #fff; margin-top: -2px; text-transform: uppercase; } .container .skills .Value{ position: relative; width: 40px; text-align: right; color: #fff; margin-top: -2px; text-transform: uppercase; } .container .skills .percent{ position: relative; width: 200px; height: 16px; margin: 0 10px; border-radius: 10px; background: #151515; box-shadow: inset 0 0 10px #000; overflow: hidden; } .container .skills .percent .progress{ position: absolute; top: 0; left: 0; height: 100%; width: 95%; border-radius: 10px; background: #fff; box-shadow: inset 0 0 2px #000; animation: animate 4s ease-in-out forwards; } @keyframes animate { from{ width: 0; } }
.container .skills:nth-child(2) .percent .progress{ background: linear-gradient(45deg, #1fe6ff, #673AB7); width: 95%; } .container .skills:nth-child(3) .percent .progress{ background: linear-gradient(45deg, #3bc0ff, #33ff00); width: 90%; } .container .skills:nth-child(4) .percent .progress{ background: linear-gradient(45deg, #ffee54, #ff00ca); width: 72%; } .container .skills:nth-child(5) .percent .progress{ background: linear-gradient(45deg, #ffee54, #ff00ca); width: 50%; }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="2020_12_26.css"> </head> <body> <div class="container"> <h2>前端技能</h2> <div class="skills"> <span class="Name">Html</span> <div class="percent"> <div class="progress" ></div> </div> <span class="Value">95%</span> </div> <div class="skills"> <span class="Name">CSS</span> <div class="percent"> <div class="progress" ></div> </div> <span class="Value">90%</span> </div> <div class="skills"> <span class="Name">JavaScript</span> <div class="percent"> <div class="progress"></div> </div> <span class="Value">72%</span> </div> <div class="skills"> <span class="Name">frame</span> <div class="percent"> <div class="progress"></div> </div> <span class="Value">50%</span> </div> </div> </body> </html>
*{ margin: 0; padding: 0; box-sizing: border-box; } body{ display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #2e2e2e; font-size: 16px; } .container h2{ color: #fff; } .container .skills{ position: relative; display: flex; margin: 20px 0; padding: 24px 10px 18px; background: linear-gradient(#616161 0%, #333 10%, #222);; border-radius: 8px; overflow: hidden; border: 2px solid #000; transition: 0.5s; } .container:hover .skills{ opacity: 0.05; } .container .skills:hover{ opacity: 1; transform: scale(1.1); } .container .skills:before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 50%; background: rgba(255, 255, 255, .1); z-index: 10; } .container .skills .Name{ position: relative; width: 120px; text-align: right; color: #fff; margin-top: -2px; text-transform: uppercase; } .container .skills .Value{ position: relative; width: 40px; text-align: right; color: #fff; margin-top: -2px; text-transform: uppercase; } .container .skills .percent{ position: relative; width: 200px; height: 16px; margin: 0 10px; border-radius: 10px; background: #151515; box-shadow: inset 0 0 10px #000; overflow: hidden; } .container .skills .percent .progress{ position: absolute; top: 0; left: 0; height: 100%; width: 95%; border-radius: 10px; background: #fff; box-shadow: inset 0 0 2px #000; animation: animate 4s ease-in-out forwards; } @keyframes animate { from{ width: 0; } } .container .skills:nth-child(2) .percent .progress{ background: linear-gradient(45deg, #1fe6ff, #673AB7); width: 95%; } .container .skills:nth-child(3) .percent .progress{ background: linear-gradient(45deg, #3bc0ff, #33ff00); width: 90%; } .container .skills:nth-child(4) .percent .progress{ background: linear-gradient(45deg, #ffee54, #ff00ca); width: 72%; } .container .skills:nth-child(5) .percent .progress{ background: linear-gradient(45deg, #ffee54, #ff00ca); width: 50%; }