Framework7 - 卡片 HTML 布局



描述

卡片 HTML 布局包含许多类,如下所列:

序号 类和描述
1

cards

它是卡片容器。

2

card-header

它是可选的卡片头部,用于显示卡片标题。

3

card-footer

它是可选的,用于指定其他信息或自定义链接。

4

card-content

它是卡片内容的主要容器,是必需的。

5

card-content-inner

它是可选的额外内部包装器,用于为内容添加额外的填充。

card-headercard-footer 都有 flexbox 布局,其中项目具有垂直居中的对齐方式。如果要将项目排序到头部/尾部的顶部或底部,则可以使用 valign 属性。

示例

以下示例演示了在 Framework7 中使用卡片 HTML 布局:

<!DOCTYPE html>
<html class="with-statusbar-overlay">
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1, 
         maximum-scale = 1, minimum-scale = 1, user-scalable = no, minimal-ui" />
      <meta name = "apple-mobile-web-app-capable" content = "yes" />
      <meta name = "apple-mobile-web-app-status-bar-style" content = "black" />
      <title>Card HTML Layout</title>
      <link rel = "stylesheet" 
         href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.min.css" />
      <link rel = "stylesheet" 
         href = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/css/framework7.ios.colors.min.css" />
      <link rel = "stylesheet" 
      href = "custom.css" />
   </head>

   <body>
      <style>
         .demo-card-header-pic .card-header {
            height:40vw;
            background-size:cover;
            background-position:center;
         }
         
         .facebook-card .card-header {
            display:block;padding:10px;
         }
         
         .facebook-card .facebook-avatar {
            float:left;
         }
         
         .facebook-card .facebook-name {
            margin-left:44px;
            font-size:14px;
            font-weight:500;
         }
         
         .facebook-card .facebook-date {
            margin-left:44px;
            font-size:13px;
            color:#8e8e93;
         }
         
         .facebook-card .card-footer {
            background:#fafafa;
         }
         
         .facebook-card .card-footer a {
            color:#81848b;
            font-weight:500;
         }
         
         .facebook-card .card-content img {
            display:block;
         }
         
         .facebook-card .card-content-inner {
            padding:15px 10px;
         }
      </style>
      
      <div class = "views">
         <div class = "view view-main">
            <div class = "pages">
               <div data-page = "home" class = "page navbar-fixed">
               
                  <div class = "navbar">
                     <div class = "navbar-inner">
                        <div class = "left"> </div>
                        <div class = "center">Card HTML Layout</div>
                        <div class = "right"> </div>
                     </div>
                  </div>

                  <div class = "page-content">
                     <div class = "content-block-title">Simple Cards</div>
                     
                     <div class = "card">
                        <div class = "card-content">
                           <div class = "card-content-inner">Lorem ipsum dolor sit amet, 
                              consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et 
                              dolore magna aliqua.</div>
                        </div>
                     </div>
                     
                     <div class = "card">
                        <div class = "card-header">Card header</div>
                        <div class = "card-content">
                           <div class = "card-content-inner">Lorem ipsum dolor sit amet, 
                              consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et 
                              dolore magna aliqua.</div>
                        </div>
                        <div class = "card-footer">Card Footer</div>
                     </div>
                     
                     <div class = "card">
                        <div class = "card-content">
                           <div class = "card-content-inner">Another card. Lorem ipsum dolor sit 
                              amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore 
                              et dolore magna aliqua. </div>
                        </div>
                     </div>
                     
                     <div class = "content-block-title">Styled Cards</div>
                     
                     <div class = "card demo-card-header-pic">
                        <div style = "background-image:url(/framework7/images/nature.jpg)" valign = "bottom" class = "card-header color-white no-border">Beautiful Mountains</div>
                        
                        <div class = "card-content">
                           <div class = "card-content-inner">
                              <p class = "color-gray">Posted on May 20, 2015</p>
                              <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
                           </div>
                        </div>
                        
                        <div class = "card-footer"><a href = "#" class = "link">Like</a><a href = "#" class = "link">Comment</a></div>
                     </div>
                     
                     <div class = "card facebook-card">
                        <div class = "card-header">
                           <div class = "facebook-avatar"><img src = "/framework7/images/cat.jpg" width = "34" height = "34"></div>
                           <div class = "facebook-name">John Doe</div>
                           <div class = "facebook-date">Monday at 2:15 PM</div>
                        </div>
                        
                        <div class = "card-content">
                           <div class = "card-content-inner">
                              <p>What a nice view!!</p>
                              <img src = "/framework7/images/blue_hills1.jpg" width = "100%">
                              <p class = "color-gray">Likes: 112    Comments: 43</p>
                           </div>
                        </div>
                        
                        <div class = "card-footer"><a href = "#" class = "link">Like</a><a href = "#" class = "link">Comment</a><a href = "#" class = "link">Share</a></div>
                     </div>
                     
                     <div class = "content-block-title">Cards With List View</div>
                     
                     <div class = "card">
                        <div class = "card-content">
                           <div class = "list-block">
                              <ul>
                                 <li>
                                    <a href = "#" class = "item-link item-content">
                                       <div class = "item-media"><i class = "icon icon-form-name"></i></div>
                                       <div class = "item-inner">
                                          <div class = "item-title">Link 1</div>
                                       </div>
                                    </a>
                                 </li>
                                 
                                 <li>
                                    <a href = "#" class = "item-link item-content">
                                       <div class = "item-media"><i class = "icon icon-form-name"></i></div>
                                       <div class = "item-inner">
                                          <div class = "item-title">Link 2</div>
                                       </div>
                                    </a>
                                 </li>
                                 
                                 <li>
                                    <a href = "#" class = "item-link item-content">
                                       <div class = "item-media"><i class = "icon icon-form-name"></i></div>
                                       <div class = "item-inner">
                                          <div class = "item-title">Link 3</div>
                                       </div>
                                    </a>
                                 </li>
                                 
                                 <li>
                                    <a href = "#" class = "item-link item-content">
                                       <div class = "item-media"><i class = "icon icon-form-name"></i></div>
                                       <div class = "item-inner">
                                          <div class = "item-title">Link 4</div>
                                       </div>
                                    </a>
                                 </li>
                                 
                                 <li>
                                    <a href = "#" class = "item-link item-content">
                                       <div class = "item-media"><i class = "icon icon-form-name"></i></div>
                                       <div class = "item-inner">
                                          <div class = "item-title">Link 5</div>
                                       </div>
                                    </a>
                                 </li>
                              </ul>
                           </div>
                        </div>
                     </div>
                     
                     <div class = "card">
                        <div class = "card-header">Albums:</div>
                        <div class = "card-content">
                           <div class = "list-block media-list">
                              <ul>
                                 <li class = "item-content">
                                    <div class = "item-media"><img src = "/framework7/images/pic.jpg" width = "44"></div>
                                    <div class = "item-inner">
                                       <div class = "item-title-row">
                                          <div class = "item-title">Cast away</div>
                                       </div>
                                       <div class = "item-subtitle">James</div>
                                    </div>
                                 </li>
                                 
                                 <li class = "item-content">
                                    <div class = "item-media"><img src = "/framework7/images/pic3.jpg" width = "44"></div>
                                    <div class = "item-inner">
                                       <div class = "item-title-row">
                                          <div class = "item-title">Don't Follow me</div>
                                       </div>
                                       <div class = "item-subtitle">Rema Taylor</div>
                                    </div>
                                 </li>
                                 
                                 <li class = "item-content">
                                    <div class = "item-media"><img src = "/framework7/images/pic2.jpg" width = "44"></div>
                                    <div class = "item-inner">
                                       <div class = "item-title-row">
                                          <div class = "item-title">Billion words</div>
                                       </div>
                                       <div class = "item-subtitle">Kaveen sharma</div>
                                    </div>
                                 </li>
                              </ul>
                           </div>
                        </div>
                        
                        <div class = "card-footer"> <span>May 1, 2016</span><span>45 comments</span></div>
                     </div>
                     
                  </div>
               </div>
            </div>
         </div>
      </div>
      
      <script type = "text/javascript" 
         src = "https://cdnjs.cloudflare.com/ajax/libs/framework7/1.4.2/js/framework7.min.js"></script>
         
      <script>var myApp = new Framework7();</script>
   </body>

</html>

输出

让我们执行以下步骤来查看上面给出的代码是如何工作的:

  • 将上面给出的 HTML 代码保存为 cards_html_layout.html 文件到服务器根目录。

  • 打开此 HTML 文件,网址为 https://127.0.0.1/cards_html_layout.html,输出结果如下所示。

  • 此示例定义了卡片布局,其中包含唯一相关的

framework7_cards.htm
广告