卡片HTML布局(Card HTML Layout)
优质
小牛编辑
131浏览
2023-12-01
描述 (Description)
卡片HTML布局包含许多类,如下所示 -
S.No | 课程和描述 |
---|---|
1 | cards 这是卡片容器。 |
2 | card-header 它是可选的卡片标题,用于显示卡片标题。 |
3 | card-footer 它是可选的,用于指定其他信息或自定义链接。 |
4 | card-content 它是卡内容的主要容器,是必需的。 |
5 | card-content-inner 它是可选的附加内包装,用于对内容进行额外填充。 |
card-header和card-footer都有flexbox layout ,其中项目具有中心垂直对齐。 如果要将商品订购到页眉/页脚的顶部或底部,则可以使用valign属性。
例子 (Example)
以下示例演示了在Framework7中使用卡片HTML布局 -
<!DOCTYPE html>
<html>
<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>
输出 (Output)
让我们执行以下步骤,看看上面给出的代码是如何工作的 -
将上面给出的HTML代码保存为服务器根文件夹中的cards_html_layout.html文件。
以http://localhost/cards_html_layout.html打开此HTML文件,输出显示如下。
该示例定义了卡片布局,其中包含唯一的相关数据,例如照片,文本,链接。