关键点
- offsetWidth 获取当前节点的宽度 (width + border + padding)
- offsetLeft 获取的是相对于父对象的左边距
- clientX 事件属性返回当事件被触发时鼠标指针向对于浏览器页面(或客户区)的水平坐标。
html
<div class="content">
<p>0%</p>
<div class="bar">
<div class="progress"></div>
<div class="dot"></div>
</div>
</div>
css
.content {
width: 500px;
height: 80px;
margin: 100px auto;
position: relative;
}
.bar {
width: 500px;
height: 12px;
border-radius: 10px;
background: #e4e7ed;
position: absolute;
top: