需求
最近工作遇到要实现纯的背景色的长度要按百分比算。 如图:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Task item</title>
<style>
.task {
width: 100%;
height: 50px;
background: linear-gradient(90deg, #e7791e 90%, transparent 0%);
border: 1px solid #000;
display: flex;
justify-content: space-between;
align-items: center;
padding: 2px 4px;
box-sizing: border-box;
}
.l1 {
color: #fff;
}
</style>
</head>
<body>
<div class="task">
<div>
<h3 class="l1">
<span>4306</span>
<span>VD</span>
<span>Arr</span>
</h3>
</div>
<div>actions</div>
</div>
</body>
</html>
关键的点是
background: linear-gradient(90deg, #e7791e 90%, transparent 0%);