京东商城的商品分类代码

京东商城的商品分类–代码

效果图:
京东商城的商品分类代码_第1张图片

  1. 该效果CSS可以拼接出来,但是出于CSS样式方法运用“hover”属性过多;产生浏览器不兼容问题。所以,该方法不值得提倡!
  2. JS方法实现,原理:点击div分类,激活触发div(#show_div{display:none;})–>(#show_div{display:block;})

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>title>
    <style type="text/css">
       <style type="text/css">
        body
        {
            padding: 0;
            font-size: 10pt;
            behavior:url(css/csshover.htc);
        }
        .topmenu
        {
            display: block;
            width: 220px;
            border: 2px solid #e4393c;
            margin: 0;
            padding: 0;
        }
        .toptitle
        {
            height: 40px;
            line-height: 40px;
            text-align: left;
            font-size: 11pt;
            font-weight: bold;
            color: White;
            background: #e4393c;
            padding-left: 20px;
        }
        .topmenu li
        {
            height: 30px;
            line-height: 30px;
            font-size: 11pt;
            list-style-type: none;
            text-align: left;
            padding-left: 8px;
            z-index: 3;
            background-image: url(1.png);
            background-repeat: no-repeat;
            background-position: right;
        }
        .topmenu li a
        {
            text-decoration: none;
            color: #313131;
        }
        .topmenu li a:hover
        {
            text-decoration: underline;
            font-weight: bold;
            color: #e4393c;
        }
        .topmenu .lihover /*鼠标移动到上面时,应用的样式*/
        {
            border: 1px solid #DDD;
            border-right: 0;
            box-shadow: 0 0 8px #DDD;
            -moz-box-shadow: 0 0 8px #DDD;
            -webkit-box-shadow: 0 0 8px #DDD;
            background-image: none;
            height:60px;
            border-left:4px solid #e4393c;


        }
         .topmenu .lihover .submenu /*悬浮层*/
        {
            display: block;
        }

        .topmenu .lihover span /*白色小方框*/
        {
            background: white;
            display: inline-block;
            z-index: 20;
            width: 20px;
            height: 60px;
            float: right;
            position: relative;
        }


      .topmenu li b
       {
           display:none;

        }

        .topmenu .lihover b
        {
            display:block;
            height:30px;
            line-height:30px;
            font-weight:normal;
            font-size:10pt;
        }

        .submenu
        {
            display: none;
            width: 715px;
            left: 220px;
            position: absolute;
            top: 40px;
            border: 1px solid #DDD;
            z-index: 4;
            background: white;
            box-shadow: 0 0 8px #DDD;
            -moz-box-shadow: 0 0 8px #DDD;
            -webkit-box-shadow: 0 0 8px #DDD;
        }
        .leftdiv
        {
            float: left;
            width: 490px;
            margin: 5px;
        }
        .rightdiv
        {
            float: left;
            width: 200px;
            margin: 5px;
        }

        .leftdiv dl
        {
            display: block;
            border-bottom: 1px solid #EEE;
            padding-bottom: 6px;
            overflow: hidden;
        }
        .leftdiv dl dt
        {
            display: block;
            float: left;
            width: 60px;
            text-align: right;
            height: 22px;
            line-height: 22px;
            padding-right: 6px;
        }

        .leftdiv dl dt a
        {
            color: #e4393c;
            font-weight: bold;
            text-decoration: underline;
            font-size: 10pt;
        }
        .leftdiv dl dd
        {
            display: block;
            overflow: hidden;
        }
        .leftdiv dl dd a
        {
            display: block;
            float: left;
            border-left: 1px solid #CCC;
            color: #737373;
            font-size: 9pt;
            padding: 0 8px;
            height: 14px;
            line-height: 14px;
            margin: 4px 0;
        }

        .rightdiv dl dd
        {
            margin: 3px 0;
        }

        .rightdiv dl dt
        {
            color: #e4393c;
            font-weight: bold;
            font-size: 10pt;
        }

        .rightdiv dl dd a
        {
            font-size: 9pt;
            color: #737373;
            line-height: 22px;
        }
        .rightdiv dl dd a:hover
        {
            color: #737373;
            font-weight: normal;
        }

      .rightPic
      {
          position:relative;
          right:-35px;
          bottom:-30px;

          }
    style>
head>
<body>
    <script type="text/javascript">
        window.onload = function () {
    
            var Lis = document.getElementsByTagName("li");
            for (i = 0; i < Lis.length; i++) {
                Lis[i].i = i;
                Lis[i].onmouseover = function () {
    
                    this.className = "lihover";

                    var h0 = (this.i - 1) * 30 + 42;
                    var y = this.getElementsByTagName("div")[0].offsetHeight;
                    var h = this.getElementsByTagName("div")[0].style.top + y;

                    if (h < h0) {
                        this.getElementsByTagName("div")[0].style.top = h0 + "px";
                    }

                    if (y > 550) {
                        this.getElementsByTagName("div")[0].style.top = "3px";
                    }
                }

                Lis[i].onmouseout = function () {
    
                    this.className = "";
                }
            }

        }
    script>
    <ul class="topmenu">
        <div class="toptitle">
            全部商品分类
        div>
        <li><a href="#">图书、音像、数字商品a><span>span> <b><a href="#">文学a> <a href="#">经管a>
            <a href="#">畅读VIPa>b>
            <div class="submenu">
                <div class="leftdiv">
                    <dl>
                        <dt><a href="#">电子书a>dt>
                        <dd>
                            <a href="#">免费a> <a href="#">小说a> <a href="#">励志与成功a> <a href="#">婚恋/两性a>
                            <a href="#">文学a> <a href="#">经管a> <a href="#">畅读VIPa>
                        dd>
                    dl>
                    <dl>
                        <dt><a href="#">数字音乐a>dt>
                        <dd>
                            <a href="#">通俗流行a> <a href="#">古典音乐a> <a href="#">摇滚说唱a> <a href="#">爵士蓝调a>
                            <a href="#">乡村民谣a> <a href="#">有声读物a>
                        dd>
                    dl>
                    <dl>
                        <dt><a href="#">音像a>dt>
                        <dd>
                            <a href="#">音乐a> <a href="#">影视a> <a href="#">教育音像a> <a href="#">游戏a>
                        dd>
                    dl>
                    <dl>
                        <dt><a href="#">文艺a>dt>
                        <dd>
                            <a href="#">小说a> <a href="#">文学a> <a href="#">青春文学a> <a href="#">传记a> <a
                                href="#">艺术a>
                        dd>
                    dl>
                    <dl>
                        <dt><a href="#">人文社科a>dt>
                        <dd>
                            <a href="#">历史a> <a href="#">心理学a> <a href="#">政治/军事a> <a href="#">国学/古籍a>
                            <a href="#">哲学/宗教a> <a href="#">社会科学a>
                        dd>
                    dl>
                    <dl>
                        <dt><a href="#">经管励志a>dt>
                        <dd>
                            <a href="#">经济a> <a href="#">金融与投资a> <a href="#">管理a> <a href="#">励志与成功a>
                        dd>
                    dl>
                    <dl class="fore7">
                        <dt><a href="#">生活a>dt>
                        <dd>
                            <a href="#">家教与育儿a> <a href="#">旅游/地图a> <a href="#">烹饪/美食a> <a href="#">时尚/美妆a>
                            <a href="#">家居a> <a href="#">婚恋与两性a> <a href="#">娱乐/休闲a> <a href="#">健身与保健a>
                            <a href="#">动漫/幽默a> <a href="#">体育/运动a>
                        dd>
                    dl>
                    <dl>
                        <dt><a href="#">科技a>dt>
                        <dd>
                            <a href="#">科普a> <a href="#">ITa> <a href="#">建筑a> <a href="#">医学a> <a href="#">
                                工业技术a> <a href="#">电子/通信a> <a href="#">农林a> <a href="#">科学与自然a>
                        dd>
                    dl>
                    <dl>
                        <dt><a href="#">少儿a>dt>
                        <dd>
                            <a href="#">少儿a> <a href="#">0-2岁a> <a href="#">3-6岁a> <a href="#">7-10岁a>
                            <a href="#">11-14岁a>
                        dd>
                    dl>
                    <dl>
                        <dt><a href="#">教育a>dt>
                        <dd>
                            <a href="#">教材a> <a href="#">中小学教辅a> <a href="#">考试a> <a href="#">外语学习a>
                        dd>
                    dl>
                    <dl>
                        <dt><a href="#">其它a>dt>
                        <dd>
                            <a href="#">英文原版书a> <a href="#">港台图书a> <a href="#">工具书a> <a href="#">套装书a>
                            <a href="#">杂志/期刊a>
                        dd>
                    dl>
                div>
                <div class="rightdiv">
                    <dl>
                        <dd>
                            <a href="http://sale.jd.com/act/1XDZ6ShE5M7tTrl.html">
                                <img src="http://img30.360buyimg.com/erpVCAare/g16/M00/0B/1B/rBEbRlOCFcoIAAAAAAArMNB2tlkAACTlwDgVG8AACtI514.jpg"
                                    width="194" height="70" title="\家电">
                            a>
                        dd>
                        <dd>
                            <a href="http://sale.jd.com/act/v8kJIaPmsMGuebpH.html">
                                <img src="http://img30.360buyimg.com/erpVCAare/g16/M00/0B/19/rBEbRlOAiHUIAAAAAAAx8X2c6oIAACTCAP56A4AADIJ112.jpg"
                                    width="194" height="70" title="小家电--三请聚宝盆">
                            a>
                        dd>
                    dl>
                    <dl>
                        <dt>推荐品牌dt>
                        <dd>
                            <a href="#">美的官方旗舰店a>
                        dd>
                        <dd>
                            <a href="#">苏泊尔旗舰店a>
                        dd>
                        <dd>
                            <a href="#">九阳旗舰店a>
                        dd>
                        <dd>
                            <a href="#">东菱旗舰店a>
                        dd>
                        <dd>
                            <a href="#">海尔统帅旗舰店a>
                        dd>
                        <dd>
                            <a href="#">小熊旗舰店a>
                        dd>
                    dl>
                    <img src="wii.png" class="rightPic" />
                div>
            div>
        li>
        <li><a href="#">家用电器a> <span>span>
            <div class="submenu">
                <div class="leftdiv">
                    <dl>
                        <dt><a href="#">大 家 电a>dt>
                        <dd>
                            <a href="#">平板电视a> <a href="#">空调a> <a href="#">冰箱a> <a href="#">洗衣机a> <a
                                href="#">家庭影院a> <a href="#">DVDa> <a href="#">迷你音响a> <a href="#">烟机/灶具a>
                            <a href="#">热水器a> <a href="#">消毒柜/洗碗机a> <a href="#">酒柜/冷柜a> <a href="#">家电配件a>
                        dd>
                    dl>
                    <dl>
                        <dt><a href="#">生活电器a>dt>
                        <dd>
                            <a href="#">电风扇a> <a href="#">冷风扇a> <a href="#">净化器a> <a href="#">饮水机a>
                            <a href="#">净水设备a> <a href="#">挂烫机/熨斗a> <a href="#">吸尘器a> <a href="#">电话机a>
                            <a href="#">插座a> <a href="#">收录/音机a> <a href="#">清洁机a> <a href="#">加湿器a>
                            <a href="#">除湿/干衣机a> <a href="#">取暖电器a> <a href="#">其它生活电器a>
                        dd>
                    dl>
                    <dl>
                        <dt><a href="#">厨房电器a>dt>
                        <dd>
                            <a href="#">电压力锅a> <a href="#">电饭煲a> <a href="#">豆浆机a> <a href="#">面包机a>
                            <a href="#">咖啡机a> <a href="#">微波炉a> <a href="#">料理/榨汁机a> <a href="#">电烤箱a>
                            <a href="#">电磁炉a> <a href="#">电饼铛/烧烤盘

你可能感兴趣的:(商城分类样式制作,商品分类,display属性,JS实现商城分类)