内容的展开与收起效果

大幅广告的展开与收起:

<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>展开与收起效果</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            width: 730px;
            margin: auto;
        }
        #banner{
            height: 336px;
            overflow: hidden;
        }

        p{
            line-height: 30px;
            text-align: center;
        }
    </style>

    <script>
        var h=0;
        function addH(){
            var banner=document.getElementById(‘banner‘)
            if(h<336){
                h+=10
                banner.style.height=h+‘px‘
            }else{
                return
            }
            setTimeout(addH,50)
        }
        window.onload=function(){
            addH();
        }
        function removeH(){
            var banner=document.getElementById(‘banner‘)
            if(h>0){
                h-=10
                banner.style.height=h+‘px‘
            }else{
                // banner.style.display=‘none‘
                return
            }
            setTimeout(removeH,50)
        }
        window.onload=function(){
            addH();
            setTimeout(removeH,5000)
        }
    </script>
</head>
    <div id=‘banner‘><img src=‘images/1.jpg‘></div>
    <p>正文</p>

<body>

</body>

</html>

商品信息展示的展开与收起

<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>展开与收起效果</title>

    <style>
    *{
        margin: 0;
        padding: 0;
    }
    #content{
        width: 400px;
        height: auto;
        margin: 0 auto;
        border:1px solid #666;
    }

    #hdn{
        height: 50px;
        width: 400px;
        background: red;
    }
    a{
        display: block;
        height: 30px;
        background: #ccc;
        margin: 0 auto;
        width: 50px;
        line-height: 30px;
        text-align: center;
        text-decoration: none;
    }
    </style>

    <script>
        function showDiv(){
            var hrf=document.getElementById(‘hrf‘)
            var hdn=document.getElementById(‘hdn‘)
            hdn.style.display=‘block‘;
            hrf.innerHTML=‘收起-‘;
            hrf.href=‘javascript:hiddenDiv()‘
        }
        function hiddenDiv(){
            var hdn=document.getElementById(‘hdn‘)         //这个变量申明不能放于外部
            var hrf=document.getElementById(‘hrf‘)
            hdn.style.display=‘none‘;
            hrf.innerHTML=‘展开+‘;
            hrf.href=‘javascript:showDiv()‘

        }
    </script>
</head>
<body>

        <div id=‘content‘>
            <p>展开与收起效果展开与收起效果展开与收起效果展开与收起效果展开与收起效果</p>
            <div id=‘hdn‘ style=‘display:none‘>
                <p>展开与收起效果展开与收起效果展开与收起效果展开与收起效果展开与收起效果</p>
            </div>
        </div>
        <p><a id=‘hrf‘ href=‘javascript:showDiv()‘>展开+</a></p>                 //可以通过这样引用函数

</body>
</html>

阅读文章的展开与收起

<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>展开与收起效果</title>

    <style>
    *{
        margin: 0;
        padding: 0;
    }
    #content{
        width: 400px;
        height: auto;
        margin: 0 auto;
        border:1px solid #666;
    }

    #hdn{
        height: 50px;
        width: 400px;
        background: red;
    }
    a{
        display: block;
        height: 30px;
        background: #ccc;
        margin: 0 auto;
        width: 50px;
        line-height: 30px;
        text-align: center;
        text-decoration: none;
    }
    </style>

    <script>
        function showDiv(){
            var hrf=document.getElementById(‘hrf‘)
            var hdn=document.getElementById(‘hdn‘)
            hdn.style.display=‘block‘;
            hrf.innerHTML=‘收起-‘;
            hrf.href=‘javascript:hiddenDiv()‘
        }
        function hiddenDiv(){
            var hdn=document.getElementById(‘hdn‘)         //这个变量申明不能放于外部
            var hrf=document.getElementById(‘hrf‘)
            hdn.style.display=‘none‘;
            hrf.innerHTML=‘展开+‘;
            hrf.href=‘javascript:showDiv()‘

        }
    </script>
</head>
<body>

        <div id=‘content‘>
            <p>展开与收起效果展开与收起效果展开与收起效果展开与收起效果展开与收起效果</p>
            <div id=‘hdn‘ style=‘display:none‘>
                <p>展开与收起效果展开与收起效果展开与收起效果展开与收起效果展开与收起效果</p>
            </div>
        </div>
        <p><a id=‘hrf‘ href=‘javascript:showDiv()‘>展开+</a></p>                 //可以通过这样引用函数

</body>
</html>

时间: 2024-08-29 12:14:27

内容的展开与收起效果的相关文章

菜单栏展开和收起效果(纯js)

2014年6月25日 15:36:29 需要关注的是: 1.用cookie保存用户当前点击的菜单项,不打扰后端代码 2.通过数学计算得到要显示和隐藏的div 3.点击事件是动态绑定到a标签上的,因此当dom加载完后,再执行js,也就是写在onload里 HTML如下: 1 <h3 class="titleH3" id="101">aaaa</h3> 2 <div class="subNav" id="1&q

js之展开与收起效果

1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="

实现简单展开与收起效果

body { margin: 0 auto; padding: 0; font-size: 9pt; line-height: 180%; } #pn { background: #f8f8f8; height: auto; width: 750px; display: block; margin: 0 auto; padding: 5px; } .btn { width: 80px; height: 20px; padding: 5px 3px 5px 3px; text-align: cen

javascript特效——展开选项和收起效果

1.简单的展开和收起效果: 1.1 静态结构HTML代码分析 body包含最外层的div id="pn"和按钮 a id="btn" ,而包含div id="pn"包含一个p标签和div id="hpn"(展开和收起部分) <body> <div id="pn" class="pn"> <p>分类:全部 电影 电视剧 综艺</p> <

div展开与收起(鼠标点击)

效果图: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>展开与收起</title> <style type="text/css"> body{ margin: 0 auto; padding: 0; } #pn{ background: #e8e8e8; width: 6

展现与收起效果(鼠标移入移出)

效果图: 移入: 移出: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>鼠标移入移出展现与收起效果</title> <style type="text/css"> body{ margin: 0 auto; padding: 0; } #pn{ background: #

实现一个与内容合二为一的ActionBar动画效果

实现一个与内容合二为一的ActionBar动画效果,让你的actionbar更生动.以下是效果图: 这样的效果的优点是让actionbar也成为了内容的一部分,实际应用的效果比图片展示的效果要好,除了actionbar渐渐出现的效果外.背景图片另一种称之为Ken Burns effect 的动态效果. 以下解说实现过程. 设置actionbar的样式.我们须要例如以下两点: 1.actionbar是透明的. 2.开启overlay mode模式 <resources> <style na

【Android】键盘的展开和收起

键盘的展开和收起主要使用到类InputMethodManager:http://developer.android.com/reference/android/view/inputmethod/InputMethodManager.html 其大致方法如下: 1 public void hide_keyboard_from(Context context, View view) { 2 InputMethodManager inputMethodManager = (InputMethodMan

鼠标移动链接上,滑动展开/隐藏图片效果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ