|
@@ -163,28 +163,28 @@ function addStr(str){
|
|
|
* @param {*} txtdiv 字符串要展示的div
|
|
|
*/
|
|
|
function setFont(str,txtdiv){
|
|
|
- let count =parseInt(20/400*window.innerWidth)-4;
|
|
|
- let strCount=str.length;
|
|
|
- let rows=Math.ceil(strCount/count);
|
|
|
- let endCount=strCount%count;
|
|
|
- let rowCounts=[];
|
|
|
- let innertxt="";
|
|
|
- for(let i=1;i<rows;i++){
|
|
|
- rowCounts.push(count);
|
|
|
- innertxt+=str.substr(count*(i-1),count)+"<br>";
|
|
|
- }
|
|
|
- rowCounts.push(endCount)
|
|
|
- innertxt+=str.substr(count*(rows-1),endCount==0?count:endCount);
|
|
|
- txtdiv.innerHTML=innertxt;
|
|
|
- let width=(window.innerWidth-txtdiv.clientWidth)/2;
|
|
|
- let fontsize=14/1920 *window.innerWidth*(6*400/window.innerWidth);
|
|
|
- let left=(width/window.innerWidth)*100+"%";
|
|
|
- let padding=fontsize/2+"px "+fontsize/2+"px "+fontsize/2+"px "+fontsize/2+"px";
|
|
|
- let styleStr="position: absolute;z-index: 100;bottom: 10%;background-color:rgba(157,96,34,0.5);padding:"+padding+";color:white;left:"+left+";font-size:"+fontsize+"px;";
|
|
|
- //styleStr+="lineHeight:"+5*rows+"px;";
|
|
|
- styleStr+=" line-height:23px;"
|
|
|
- styleStr+="height:"+(25*rows)+"px"
|
|
|
- txtdiv.setAttribute('style',styleStr);
|
|
|
+ let count =parseInt(20/400*window.innerWidth);
|
|
|
+ let strCount=str.length;
|
|
|
+ let rows=Math.ceil(strCount/count);
|
|
|
+ let endCount=strCount%count;
|
|
|
+ let rowCounts=[];
|
|
|
+ let innertxt="";
|
|
|
+ for(let i=1;i<rows;i++){
|
|
|
+ rowCounts.push(count);
|
|
|
+ innertxt+=str.substr(count*(i-1),count)+"<br>";
|
|
|
+ }
|
|
|
+ rowCounts.push(endCount)
|
|
|
+ innertxt+=str.substr(count*(rows-1),endCount==0?count:endCount);
|
|
|
+ txtdiv.innerHTML=innertxt;
|
|
|
+ let width=(window.innerWidth-txtdiv.clientWidth)/2;
|
|
|
+ let fontsize=14/1920 *window.innerWidth*(6*400/window.innerWidth);
|
|
|
+ let left=(width/window.innerWidth)*100+"%";
|
|
|
+ let padding=fontsize/2+"px "+fontsize/2+"px "+fontsize/2+"px "+fontsize/2+"px";
|
|
|
+ let styleStr="position: absolute;z-index: 100;background-color:rgba(157,96,34,0.5);padding:"+padding+";color:white;left:"+left+";font-size:"+fontsize+"px;";
|
|
|
+ //styleStr+="lineHeight:"+5*rows+"px;";
|
|
|
+ styleStr+=" line-height:23px;"
|
|
|
+ styleStr+="height:"+(25*rows)+"px;"
|
|
|
+ txtdiv.setAttribute('style',styleStr);
|
|
|
}
|
|
|
// //字体自动大小适应
|
|
|
// function setFontStyle(){
|
|
@@ -205,7 +205,8 @@ function clear(){
|
|
|
txtdiv.removeChild(txtdiv.firstChild);
|
|
|
}
|
|
|
txtdiv.display="none"
|
|
|
-
|
|
|
+ txtdiv.style.backgroundColor="rgba(157,96,34,0.01);"
|
|
|
+ console.log("clear")
|
|
|
}
|
|
|
|
|
|
//开始播放
|