Home > front end >  CSS multiline line overflow hidden compatible with Internet explorer
CSS multiline line overflow hidden compatible with Internet explorer

Time:12-21



<meta charset="utf-8"/& gt;
<style>
# box {
Padding: 0;
}
# box> Li {
list-style: none;
width: 200px;
word-wrap: break-word;
Word - break: break - all;
Color: darkcyan;
Padding: 10 px 0;
}
# w1 {
Width: 200 px; height:30px; background:red;
}
# w2 {
display:inline-block;
}
</style>


<body>






<script type="text/javascript">
Var w1Sel=$(' # w1);
Var w1=$(' # w1) width ();
Var s2Sel=$(' # w2);
The function getW2 () {
Return s2Sel. Width ();
}
The function mySel (name, num) {
This. The text=name;
This. Num=num;
This. Ht=function () {
Return '& lt; Li> '+ enclosing getText (this text) +' & lt;/li> '
};
Enclosing getText=function (STR) {
for(var i=0; iIf (getW2 () & gt; W1. * this num) {
S2Sel. Text (");
Return the STR. Substr (0, I - 2 - this. Num) + '... ';
}
The console. The log (STR. Substr (0, I + 1));
S2Sel. Text (STR) substr (0, I + 1));
}
}
}

var arr=['111ascDdASFVASDFASFA的水电费a--撒手动阀撒地方撒收到SDFSDFDSAFDSAFADSFASFADSFSDAFFADSFADSFADSFADFASDFASFDSFSADFDFascDdASFVASDFASFA的水电费a--撒手动阀撒地方撒收到SDFSDFDSAFDSAFADSFASFADSFSDAFFADSFADSFADSFADFASDFASFDSFSADFDFascDdASFVASDFASFA的水电费a--撒手动阀撒地方撒收到SDFSDFDSAFDSAFADSFASFADSFSDAFFADSFADSFADSFADFASDFASFDSFSADFDF','222222222ascDdASFVASDFASFA的水电费a--撒手动阀撒地方撒收到SDFascDdASFVASDFASFA的水电费a--撒手动阀撒地方撒收到SDFSDFDSAFDSAFADSFASFADSFSDAFFADSFADSFADSFADFASDFASFDSFSADFDFSDFDSAFDSAFADSFASFADSFSDAFFADSFADSFADSFADFASDFASFDSFSADFDF','33333333ascDdASFVASDFASFA的水电费a--撒手动阀ascDdASFVASDFASFA的水电费a--撒手动阀撒地方撒收到SDFSDFDSAFDSAFADSFASFADSFSDAFFADSFADSFADSFADFASDFASFDSFSADFDF撒地方撒收到SDFSDFDSAFDSAFADSFASFADSFSDAFFADSFADSFADSFADFASDFASFDSFSADFDF',
'444444 ascDdASFVASDFASFA utilities - give up a moving valve and local sa ascDdASFVASDFASFA utilities - give up a moving valve and place and received SDFSDFDSAFDSAFADSFASFADSFSDAFFADSFADSFADSFADFASDFASFDSFSADFDF SDFSDFDSAFDSAFADSFASFADSFSDAFFADSFADSFADSFADFASDFASFDSFSADFDF',
'555555 ascDdASFVASDFASFA utilities - give up a moving valve and the utilities in place and accept ascDdASFVASDFASFA - give up moving valve and a place and receive SDFSDFDSAFDSAFADSFASFADSFSDAFFADSFADSFADSFADFASDFASFDSFSADFDFascDdASFVASDFASFA utilities - give up moving valve and a place and receive SDFSDFDSAFDSAFADSFASFADSFSDAFFADSFADSFADSFADFASDFASFDSFSADFDF to SDFSDFDSAFDSAFADSFASFADSFSDAFFADSFADSFADSFADFASDFASFDSFSADFDF'];

For (var j=0; j<5; J++) {
$(' # box). Append (new mySel (arr [j], 2). The ht ());
}

</script>

  • Related