All Components

Effects / Expand

HTML5/JavaScript 源码

<!DOCTYPE html>
<html>
 <head> 
  <title>Expand</title> 
  <meta charset="utf-8"> 
  <link href="../content/shared/styles/examples-offline.css" rel="stylesheet"> 
  <link href="../../styles/kendo.common.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.rtl.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.default.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.dataviz.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.dataviz.default.min.css" rel="stylesheet"> 
  <script src="../../js/jquery.min.js"></script> 
  <script src="../../js/kendo.all.min.js"></script> 
  <script src="../content/shared/js/console.js"></script> 
  <script>
        
    </script> 
 </head> 
 <body> 
  <a class="offline-button" href="../index.html">Back</a> 
  <div id="example"> 
   <div id="listView"></div> 
   <script type="text/x-kendo-tmpl" id="template">
        <div class="product">
            <img src="../content/web/foods/${ProductID}.jpg" alt="${ProductName} image" />
            <div class="product-description">
                <h3>${ProductName}</h3>
                <p>${kendo.toString(UnitPrice, "c")}</p>
            </div>
        </div>
    </script> 
   <script>
        $(document).ready(function() {
            var dataSource = new kendo.data.DataSource({
                    transport: {
                        read: {
                            url: "//demos.telerik.com/kendo-ui/service/Products",
                            dataType: "jsonp"
                        }
                    },
                    pageSize: 30
                });

            $("#listView").kendoListView({
                dataSource: dataSource,
                template: kendo.template($("#template").html())
            });
        });
    </script> 
   <style>
        #listView {
            max-width: 660px;
            margin: 0 auto;
            background: none;
            border: none;
        }
        #listView:after {
            content: "";
            display: block;
            clear: both;
            height: 0;
            line-height: 0;
        }

        .product {
            float: left;
            position: relative;
            width: 110px;
            height: 110px;
            padding: 0;
        }

        .product-description {
            position: absolute;
            top: 0;
            width: 110px;
            height: 0;
            overflow: hidden;
            background-color: rgba(0,0,0,0.8)
        }

        .product img {
            width: 110px;
            height: 110px;
        }

        .product h3 {
            margin: 0;
            padding: 10px 10px 0 10px;
            line-height: 1.1em;
            font-size: .9em;
            font-weight: normal;
            text-transform: uppercase;
            color: #ffffff;
            word-wrap: break-word;
        }
        .product p {
            color: #ffffff;
            font-weight: bold;
            padding: 0 10px;
        }
    </style> 
   <script>
        $("#listView").on("mouseenter", ".product", function(e) {
            kendo.fx($(e.currentTarget).find(".product-description")).expand("vertical").stop().play();
        }).on("mouseleave", ".product", function(e) {
            kendo.fx($(e.currentTarget).find(".product-description")).expand("vertical").stop().reverse();
        });
    </script> 
  </div>   
 </body>
</html>