2016-04-21 34 views

回答

1

如果我理解你的问题,你想动画元素的边框宽度,可能是边框顶宽,但我不认为这会创建你正在寻找的效果,增加边框会只要按照边框宽度设置的那样推入元素,它不会看起来像是元素被填充,你可以为覆盖外层元素的嵌套元素设置动画效果,你可以查看这个例子,中号说

的HTML:

<style> 
#theBorderDiv, #theTwoDivs { 
display: inline-block; 
background-color: #CCC; 
height: 0px; 
width: 300px; 
border-top-color: red; 
border-top-style: solid; 
border-top-width: 1px; 
height: 200px; 
vertical-align: top; 
} 

#theTwoDivs{ 
    margin-top: 200px; 
    position: relative; 
} 

#theInnerDiv 
{ 
    position: absolute; 
    top:0px; 
    height: 0px; 
    width: 300px; 
    background-color: red; 
}  
</style> 
<div id="theBorderDiv"></div> 

<div id="theTwoDivs">  
<div id="theInnerDiv"></div> 
</div> 

的JavaScript:

<script type="text/javascript">   
    $('#theBorderDiv').animate({borderTopWidth:200},1000) 
    $('#theInnerDiv').animate({height:200},1000) 
</script> 
+0

谢谢,这不会在我的项目中工作,但它是一个工作解决方案。 –

+0

谢谢,希望你能找到适合你情况的东西! :) – Carorus