标题:菜单不能实现冒泡事
取消只看楼主
lxb932979339
Rank: 5Rank: 5
等 级:职业侠客
威 望:4
帖 子:84
专家分:313
注 册:2013-4-24
结帖率:100%
已结贴  问题点数:20 回复次数:1 
菜单不能实现冒泡事
<!DOCTYPE html>
<html xmlns="http://www.
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style type="text/css">
        .ulCss
        {
            padding: 0;
            margin: 0;
            position:absolute;
        }

        .liCss
        {
            background-color: #333333;
            list-style-type: none;
            float: left;
            border-right: 1px red;
            border-right-style: solid;
            position: inherit;
            color: #ffffff;
            /*position:relative;*/
            margin-right: 5px;
        }

        .tableCss
        {
            background-color: #ffffff;
            /*display:none;*/
        }

        .tdCss
        {
            font-size: 13px;
            text-align: center;
        }

        #content
        {
            color: red;
            display: none;
            position: inherit;
            margin: 0;
            padding: 0;
            border-bottom: 1px solid #339900;
            border-left: 1px solid #339900;
            border-right: 1px solid #339900;
        }

        .onli
        {
            color: #357d13;
            background-color: #ffffff;
        }

        #ulcontent
        {
            background-color: #333333;
            width: 900px;
            margin: 0 auto;
        }
    </style>
    <script src="js/jquery-1.9.1.js"></script>
    <script type="text/javascript">
        $(function () {

            var arraytd = new Array();

            //alert(array.length);
            var tdString = new Array();

            var liArray = ["商城", "古迹", "中国"];
            var liStr = "";
            for (var i = 0; i < liArray.length; i++) {
                liStr += "<li><a href='#'>" + liArray[i] + "</a></li>";
            }
            var ulStr = "<div id='ulcontent'style='position:absolute'><ul id='uid'>" + liStr + "</ul></div>";
            $("body").append(ulStr);

            $("#uid li").addClass("liCss");



            var tdItemStr_1 = ["one", "two", "three"];//创建第一个td字符串
            var tdItemStr_2 = ["北京", "天津", "湖北"];
            var tdItemStr_3 = ["长城", "天桥", "安化"];
            var tdItemStr_4 = ["长条砖", "石狮子", "杨树"];
            tdString[0] = tdItemStr_1;
            tdString[1] = tdItemStr_2;
            tdString[2] = tdItemStr_3;
            tdString[3] = tdItemStr_4;



            for (var i = 0; i < tdString.length; i++)//创建td对象的字符串
            {
                arraytd[i] = new Array();
                var tdStr = "";
                var tempStr = "";
                for (var h = 0; h < tdString[i].length; h++) {
                    tempStr = "<td>" + tdString[i][h] + "</td>";
                    tdStr = tdStr + tempStr;
                }
                arraytd[i][0] = tdStr;
                //alert(tdStr);
            }
            var trStr = "";
            for (var i = 0; i < arraytd.length; i++) {
                trStr += "<tr>" + arraytd[i][0] + "</tr>";
            }
            var tableStr = "<div id='content'><table id='tb'><tbody>" + trStr + "</tbody></table></div>";
            $(tableStr).appendTo("#ulcontent");
            $("#tb").addClass("tableCss");
            var w = $(document).width();
            var w1 = $("#ulcontent").width();
            $("#ulcontent").css({"left":((w-w1)/2)+"px"});


            $("#uid li").each(function () {
                $("a", this).mouseover(function () {
                    var liY = $(this).offset().top;
                    var liX = $(this).offset().left;
                    var wucha = $("body").offset().left;
                    var newY = liY + $(this).height();
                    $(this).addClass("onli");
                    $("#content").css({
                        "top": (newY - 8  ) + "px",
                        "left": (liX -  ((w - w1) / 2)) + "px"
                    }).show("fast");
                }).mouseout(function () {
                    $("#content").hide();
                    $(this).removeClass("onli");
                });
            });

        });
    </script>

</head>
<body>
   
</body>
</html>

代码有点多,可读性不好,希望高手们能够看下去,看看我的问题所在,我希望的效果是,鼠标能移动到下拉菜单上去,现在却移动不上去

[ 本帖最后由 lxb932979339 于 2013-5-23 17:12 编辑 ]
搜索更多相关主题的帖子: html content absolute position style 
2013-05-23 07:53
lxb932979339
Rank: 5Rank: 5
等 级:职业侠客
威 望:4
帖 子:84
专家分:313
注 册:2013-4-24
得分:0 
回复 2楼 szgg520
能不能帮下忙,告诉我怎么弄
2013-05-25 06:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-407791-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.408668 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved