<!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>
<script>
function setlh(el) {
if(el.value>50){
el.value = 50;
}
else if(el.value<=20){
el.value = 20;
}
var a = el.value;
var abc = document.getElementsByClassName('mytxt');
Array.prototype.forEach.call(abc,function(ele){
ele.style.lineHeight=a+'px';
}
)
}
</script>
<style>
.mytxt{ line-height:30px;}
</style>
</head>
<body>
<input id="lh" onchange="setlh(this)" type="text" value="30"/>
<div class="mytxt">我是测试文本<br />我是测试文本<br />我是测试文本</div>
<div class="mytxt">我是测试文本2<br />我是测试文本2<br />我是测试文本2</div>
</body>
</html>
07-07
592
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交