CSS卡片堆栈

在浏览各种APP及网站,往往会发现很多酷炫的布局及样式。搜集一下,补充自己的技能库,借鉴学习一下。

HTML

<h1>Stack of Cards</h1>

<div class="card">
    <p>Here's some content. </p>
</div>

<div class="card card-dark">
    <p>Here's a stack of dark cards. </p>
</div>

<div class="card card-primary">
    <p>Here's some more content of another type with a lot more content. </p>
    <p>And it doesn't end there. It just keeps on going. </p>
    <ul>
        <li>Stuff</li>
        <li>And other stuff</li>
        <li>Never ending card</li>
    </ul>
</div>

<div class="card card-secondary">
    Here's yet another card with another color.
</div>

CSS

@import url(//fonts.googleapis.com/css?family=Open+Sans:400,600);
*,
*::before,
*::after {
    box-sizing: border-box;
}
body {
    margin: 2rem 0.5rem;
    background-color: #c4c8cc;
    color: #404448;
    font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    line-height: 1.4;
}
h1 {
    margin: 0 0 2rem;
    font-weight: 400;
    line-height: 1.1;
    text-align: center;
}
p {
    margin: 0 0 1.4em;
}
ul {
    margin: 0 0 1.4em;
    padding: 0;
    padding-left: 1.15em;
    /**
 * The card stack mixin. 
 * 
 * @param   color  $card-color    Main color of the card stack. Defaults to white.
 * @param   color  $shadow-color  Color of the shadow. Defaults to black.
 * 
 * @return  box-shadow            Applies a box shadow to the element.
 */
    
    list-style-type: square;
}
.card {
    margin: 0 auto 2rem;
    padding: 1rem;
    min-width: 10rem;
    max-width: 20rem;
    background-color: white;
    word-wrap: break-word;
    box-shadow: 0 0.0625em 0.1875em 0 rgba(0, 0, 0, 0.1), 0 0.5em 0 -0.25em #f2f2f2, 0 0.5em 0.1875em -0.25em rgba(0, 0, 0, 0.1), 0 1em 0 -0.5em #e5e5e5, 0 1em 0.1875em -0.5em rgba(0, 0, 0, 0.1);
}
.card.card-primary,
.card.card-dark {
    color: white;
}
.card.card-primary {
    background-color: tomato;
    text-shadow: 0 0.0625em 0 rgba(0, 0, 0, 0.25);
    box-shadow: 0 0.0625em 0.1875em 0 rgba(0, 0, 0, 0.1), 0 0.5em 0 -0.25em #f25e43, 0 0.5em 0.1875em -0.25em rgba(0, 0, 0, 0.1), 0 1em 0 -0.5em #e5593f, 0 1em 0.1875em -0.5em rgba(0, 0, 0, 0.1);
}
.card.card-secondary {
    background-color: #47e3ff;
    box-shadow: 0 0.0625em 0.1875em 0 rgba(0, 0, 0, 0.1), 0 0.5em 0 -0.25em #43d7f2, 0 0.5em 0.1875em -0.25em rgba(0, 0, 0, 0.1), 0 1em 0 -0.5em #3fcce5, 0 1em 0.1875em -0.5em rgba(0, 0, 0, 0.1);
}
.card.card-dark {
    background-color: #404040;
    box-shadow: 0 0.0625em 0.1875em 0 rgba(0, 0, 0, 0.1), 0 0.5em 0 -0.25em #3c3c3c, 0 0.5em 0.1875em -0.25em rgba(0, 0, 0, 0.1), 0 1em 0 -0.5em #393939, 0 1em 0.1875em -0.5em rgba(0, 0, 0, 0.1);
}
.card >:last-child {
    margin-bottom: 0;
}
Like (0)
Donate 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
ZEROZERO
Previous 2019年12月27日
Next 2020年1月11日

相关推荐

  • 两栏布局之左侧固定,右侧自适应的实现方法

    实现左侧固定,右侧自适应的两栏布局的方法有很多。其中经常用到的有float方法、BFC方法、CSS3的flex布局及grid布局。并非所有的布局都会在开发中使用,但是其中也会涉及一些知识点。

    2018年10月13日
    2.5K
  • css布局基础总结

    前端css布局知识繁杂,实现方式多种多样。想写出高效、合理的布局,必须以深厚的css基础为前提。为了方便记忆和复习,将css布局要点记录如下。内容较多,应用方面说的不太详细,但都是…

    2018年9月13日
    2.2K
  • css晦涩难懂的点都在这啦

    CSS大家肯定都是会的但是每个人所撑握的情况都不一样,特别是已经工作几年的前辈(这里指的是我司)很多CSS玩法都不知道,可能他们已经习惯了用组件, 但是面试的时候又不可避免问,所以…

    2021年1月20日
    1.3K
  • 外层有一个自适应高度的div,里面有两个div,一个高度固定300px,另一个怎么填满剩余的高度?

    可以设置外层自适应高度的容器为flex布局,利用flex-basis属性即可实现自动填满剩余高度;代码如下:

    2021年2月22日
    1.2K
  • css如何利用transparent属性设置透明度?transparent属性绘制各种三角形

    想到用css设置元素透明度,大家的第一反应会是:用Opacity属性来设置透明度,其实在css中还有其他设置透明度的方法。本章给大家介绍用transparent属性设置透明度,以及…

    2021年2月25日
    1.2K
  • CSS让内容居中的方法总结

    内容水平居中  分行内元素与块级元素两种情况;其中块级元素又分定宽与不定宽两种情况; 行内元素 首先看它的父元素是不是块级元素,如果是,则直接给父元素设置 te…

    2019年6月28日
    3.2K
  • CSS布局之圣杯与双飞翼布局

    所谓圣杯布局和双飞翼布局其实解决的问题是相同的,都是解决左右两栏固定宽度,中间部分自适应,其中某部分内容比其他内容高的时候,保证三者元素等高。他俩的区别就是:圣杯用padding。…

    2019年6月18日
    1.8K
  • px、em和rem实战经验

    在自适应布局或者移动端网页开发时,我们经常会用到em和rem两个长度单位。接下来我们讨论一下这两个单位和px之间的区别,以及他们的使用场景等。 px px,像素(计算机屏幕上的一个…

    2018年9月11日
    2.0K
  • 网页布局之三栏网页宽度自适应布局

    在工作中经常遇到网页布局错乱的问题,往往引发的这种问题都是因为不同设备不同分辨率而导致。归根结底,是因为前端工程师经验不足,代码写得不够完好。以下是我总结及从网络搜集的一些网页布局…

    2018年10月8日
    2.9K
  • flex布局详解

    往往在移动端开发过程中,弹性布局是非常实用的一种手段。往往你并不需要去反复的使用媒体查询的。整整的响应式布局是使界面能够自动的根据屏幕进行变化,做到完美的弹性布局,在必要的时候,去…

    2018年9月10日
    2.2K

发表回复

Please Login to Comment