zoukankan      html  css  js  c++  java
  • 一个简单的提示效果

    一个简单的效果,修改了三次才能达到如意的效果。看来,细节真的是决定成败。

    <!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-Type" content="text/html; charset=utf-8">
    <title>Document</title>
    <style>
    .b
    { width:200px; margin:10px auto; height:200px; border:1px solid #ccc; background:#eee;}
    .l
    { width:50px; height:50px; border:1px solid #ccc; margin:10px; float:right; display:none;}
    </style>
    <script>
    window.onload
    = function(){

    }
    </script>
    </head>
    <body>
    <div class="b" id="b0" onmouseover="c(0)">
    春江潮水连海平
    <div class="l" id="c0"><a href="#">收藏</a> <a href="#">删除</a></div>
    </div>
    <div class="b" id="b1" onmouseover="c(1)">
    春江潮水连海平
    <div class="l" id="c1"><a href="#">收藏</a> <a href="#">删除</a></div>
    </div>
    <div class="b" id="b2" onmouseover="c(2)">
    春江潮水连海平
    <div class="l" id="c2"><a href="#">收藏</a> <a href="#">删除</a></div>
    </div>
    <script>
    function $(id) {
    return document.getElementById(id);
    }
    function c(n){
    for(var i=0; i<3; i++){
    $(
    'b' + i).style.background = "#eee";
    $(
    'c' + i).style.display = 'none';
    }
    $(
    'b' + n).style.background = "#eff";
    $(
    'c' + n).style.display = 'block';
    }
    </script>
    </body>
    </html>

    原理:

    先利用for循环初始化页面内待隐藏的div,然后根据循环外传来的参数对未隐藏div的进行样式改变。

    基本上控制隐藏显示的灵魂人物是:“display:none | block | inline" 。css 属性如不多述。

  • 相关阅读:
    ionic开发遇到的问题总结
    promise和Rxjs的一点区别
    angular2组件通信
    神奇的函数作用域
    vue模板的几种写法及变化
    在安卓上,微信公众号无法分享到QQ的解决办法之一
    mysql忘记密码
    无法远程连接服务器上的mysql
    gitHub 基础命令
    linux安装Node(Centos)
  • 原文地址:https://www.cnblogs.com/jikey/p/1621677.html
Copyright © 2011-2022 走看看