各位大神 谁知道DIV+CSS中怎么实现点击 搜索框 自动伸缩。 满意给高分 在线等

html-css014

各位大神 谁知道DIV+CSS中怎么实现点击 搜索框 自动伸缩。 满意给高分 在线等,第1张

是不是像苹果首页顶部导航搜索框的效果?

http://www.apple.com.cn/

如果是,靠div+css可以实现,但不能实现它这么平滑的效果,还有就是IE7以下不支持,因为需要使用:focus伪类

HTML5+CSS3小实例之伸缩式动态搜索框

技术栈:HTML+CSS

字体图标库:font-awesome

效果:

源码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "

<html xmlns="

<head>

<meta http-equiv="Content-Type" content="text/html charset=utf-8" />

<title>无标题文档</title>

<script type="text/javascript" src="jquery.js"></script>

<style>

.{ padding:0 margin:0 list-style:none}

.htmlBox{ width:100% min-width:500px height:500px border:1px solid #A349A4 border-radius:5px}

.sskBox{ width:100% height:35px margin-top:150px border:1px solid #000 border-left:0 border-right:0}

.zc{ width:100px height:35px float:left}

.zj{ width:250px height:35px float:left border-left:1px solid #000 border-right:1px solid #000}

.yc{ height:35px float:right}

</style>

</head>

<body>

<div class="htmlBox">

 <div class="sskBox">

 <div class="zc">左边100</div>

 <div class="zj">中间250</div>

 <div class="yc">右边自适应</div>

</div>

</div>

</body>

<script>

tmntH()//加载的时候执行一次

$(window).resize(function() {tmntH()})//浏览器窗口变化时执行

function tmntH()

{

    var ycw=$(".sskBox").width()-352+'px'//yc的宽度等于sskBox宽度-350-2(边框线)

    //alert(div3)

    $(".yc").css("width",ycw)

    

}

</script>

</body>

</html>