<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.home{
width: 800px;
height: 300px;
}
textarea{
width: 500px;
height: 30px;
resize: none;
box-sizing: border-box;
}
.father{
width: 500px;
height: 35px;
border-radius: 5px;
border: 1px solid rgb(6, 6, 112);
}
.son{
/* float: left; */
border-radius:5px 0px 0px 5px ;
width: 50px;
height:35px ;
background-color: rgb(87, 87, 250);
text-align: center;
}
.home .father .son span{
line-height: 35px;
color: white;
}
</style>
</head>
<body>
<div class="home">
<textarea name="" id="" cols="30" rows="10"></textarea>
<div class="father">
<div class="son">
<span>10%</span>
</div>
</div>
</div>
<script>
let ip = document.querySelector('textarea')
father = document.querySelector('.father')
son = document.querySelector('.son')
tex = document.querySelector('span')
ip.addEventListener('input',function(){
son.style.transition = '0.6s'
son.style.width = `${ip.value*5}px`
son.innerText = `${ip.value}%`
})
</script>
</body>
</html>