". ||The second step is to write an image size modification tool using javascript code. ||The third step is to drag the slider to adjust the layui image size."/> ". ||The second step is to write an image size modification tool using javascript code. ||The third step is to drag the slider to adjust the layui image size.">

Home  >  Article  >  Web Front-end  >  How to enlarge layui pictures

How to enlarge layui pictures

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-07-17 09:26:533132browse

How to enlarge layui pictures

Look at the renderings first

How to enlarge layui pictures

How to enlarge layui pictures

##Step one:

HTML code: Create slider

<div id="slideys" class="demo-slider"></div>

Related recommendations: "

layui framework tutorial"

Part 2: javascript code

var ysw = 0;   //记录图片原始宽度
var ysh = 0;   //记录图片原始高度
layui.use(&#39;slider&#39;, function(){     
var $ = layui.$      
,slider = layui.slider;     
slider.render({            
elem: &#39;#slideys&#39;             
,value: 0 //初始值             
,theme: &#39;#1E9FFF&#39;            
,step: 1 //步长            
,min: -10 //最小值            
,max: 10 //最大值            
,showstep: true //开启间隔点            
,change: function(value){                
if(ysw ==0 || ysh == 0){                    
return;                
}                
var pjw = ysw/20;                
var pjh = ysh/20;                
var img =  $("#dximg");  //图片ID                
if(img!=null){                    
var w = Math.round(ysw+(pjw*value));                    
var h = Math.round(ysh+(pjh*value));                    
$(img).css("width", w );                      
$(img).css("height", h );                 
}              
}          
});    
});

Log in to the tool network to proceed Online image size conversion.

How to enlarge layui pictures

The above is the detailed content of How to enlarge layui pictures. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn