JS向上拉伸的DIV层

JavaScript011

JS向上拉伸的DIV层,第1张

HTML 结构

<div id="footerSlideContainer">

<div id="footerSlideNav"></div>

<div id="footerSlideContent"></div>

</div>

原理︰

1. 一开始 #footerSlideContent 拿取自身高度、然後 Dom ready 之後就把 height 设成 0 隐藏掉

2. 在 #footerSlideNav 是一个控制台,内容随便,没有特别,就是在里面设置一个 <a id="showFooter">的开关

3. 点击 #showFooter,#footerSlideContent 就会把高度用 animate 表现出来,做成 slide up 的效果

#footerSlideContainer {

position: fixed

bottom: 0

left: 0

width: 100%

}

JS 重点

var original_h = $('#footerSlideContent').height()// 先拿取高度

$('#footerSlideContent').height(0)// 隐藏整个 Content

$('#showFooter').click(function(){

$('#footerSlideContent').animate({

'height' : original_h // 回复 footerSlideContent 的高度,用 animate 效果

})

})

其它的你应该懂的吧

楼主,这个我接触多了你试试我的.可以的话求采纳。

css:

.div1{width:100px}//这个随意设置

.div1 img{width:100%}

html:

<div class="div1"><img src="我的图片" /></div>

接到了一个开发任务,需要能够拉伸缩放图片,以及图片上缩放边框。

简单来说,就是个宽度不超过范围,高度自由拉伸图片的效果,以及一个有底图,宽高都要在操作对象内的缩放。

具体的处理细节,将上传到我的zjj-components中。组件名为PictureResize