1234567891011121314151617181920212223242526272829303132333435 |
- let imgSizeAuto = function(){
- let viewHeight = document.body.offsetHeight;
- let viewWidth = document.body.offsetWidth;
- let imgEles = document.getElementsByClassName('img');
- let fontsize,ratefont = 0.259;
- if(viewWidth <= 1450){
- let rateHs = [0.047,0.113,0.069,0.089,0.089,0.089];
- let rateWs = [0.297,0.263,0.391,0.139,0.139,0.139]
-
- for(let i = 0; i < imgEles.length; i++){
- if(i <= rateHs.length){
- let newWidth = viewWidth * rateWs[i];
- imgEles[i].width = newWidth;
- // console.log(imgEles[i].width);
- }
- if(i == 3){
- fontsize = ratefont * imgEles[i].height;
- console.log(fontsize);
- }
- }
-
- let buttons = document.getElementsByClassName('buttons');
- for(let b of buttons){
- b.style.fontSize = fontsize + 'px';
- }
- }else{
- let buttons = document.getElementsByClassName('buttons');
- for(let b of buttons){
- b.style.fontSize = '22px';
- }
- }
- }
- imgSizeAuto();
- window.onresize = imgSizeAuto;
|