博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
常用布局-1
阅读量:6658 次
发布时间:2019-06-25

本文共 7162 字,大约阅读时间需要 23 分钟。

面包屑导航(Breadcrumb navigation)

.breadcrumb ul {    list-style: none;    margin: 0;    padding: 0;    display: flex;}.breadcrumb a,.breadcrumb span {    padding: .5em 1em;}.breadcrumb li::before {    content: "→";}.breadcrumb li:first-child::before {    content: "";}复制代码
复制代码

居中元素(Center an element)

.container {    border: 2px solid rgb(75, 70, 74);    border-radius: .5em;    height: 200px;    display: flex;    align-items: center;    justify-content: center;}.item {    border: 2px solid rgb(95, 97, 110);    border-radius: .5em;    padding: 20px;    width: 10em;}复制代码
I am centered!
复制代码

粘性页脚(Sticky footers)

A sticky footer pattern is one where the footer of your page "sticks" to the bottom of the viewport in cases where the content is shorter than the viewport height.

flex

.wrapper {    min-height: 100%;    display: flex;    flex-direction: column;}.page-header,.page-footer {    flex-shrink: 0;}.page-body {    flex-grow: 1;}复制代码

Main page content here, add more if you want to see the footer push down.

Sticky footer
复制代码

grid

.wrapper {    min-height: 100%;    display: grid;    grid-template-rows: auto 1fr auto;}复制代码

Main page content here, add more if you want to see the footer push down.

Sticky footer
复制代码

分割导航(Split navigation)

A navigation pattern where some links are visually separated from the others.

.main-nav {    display: flex;    margin: 0;    padding: 0;    list-style: none;}.main-nav a {    padding: .5em 1em;    display: block;}.push {    margin-left: auto;}复制代码
复制代码

带标识的列表组

In this recipe we will create a list group pattern with badges that indicate a count.Our list items should be displayed with the badges lined up on the right, no matter how much content the item has. The badge should always be centered vertically whether there is a single line of content, or more than one.

.list-group {    list-style: none;    margin: 0;    padding: 0;    border: 1px solid #ccc;    border-radius: .5em;    width: 20em;}.list-group li {    border-top: 1px solid #ccc;    padding: .5em;    display: flex;    justify-content: space-between;    align-items: center;}.list-group li:first-child {    border-top: 0;}.list-group .badge {    background-color: rebeccapurple;    color: #fff;    font-weight: bold;    font-size: 80%;    border-radius: 10em;    min-width: 1.5em;    padding: .25em;    text-align: center}复制代码
  • Item One 2
  • Item Two 10
  • Item Three 9
  • Item Four 0
复制代码

分页器(Pagination)

The pagination pattern typically displays items in a row. To ensure that the pagination is understandable by people using a screenreader, we mark the items up as a list inside a <nav> element, and then use CSS to display the layout visually as a row.

Typically, the pagination component will be centered horizontally underneath the content.

.visuallyhidden {    border: 0;    clip: rect(0 0 0 0);    height: auto;    margin: 0;    overflow: hidden;    padding: 0;    position: absolute;    width: 1px;    white-space: nowrap;}nav {    display: flex;    justify-content: center;    border-top: 1px solid #eee;    margin-top: 1em;    padding-top: .5em;}.pagination {    list-style: none;    margin: 0;    padding: 0;    display: flex;}.pagination li {    margin: 0 1px;}.pagination a {    display: block;    padding: .5em 1em;    border: 1px solid #999;    border-radius: .2em;    text-decoration: none;}.pagination a[aria-current="page"] {    background-color: #333;    color: #fff;}复制代码
复制代码

卡片布局(Card)

The card component can contain a variety of content, including a heading, image, content and a footer. Each card should be the same height, and footers should stick to the bottom of the card. When added to a collection of cards, the cards should line up in two dimensions.

img {    max-width: 100%;}.cards {    display: grid;    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));    grid-gap: 20px;    max-width: 800px;    margin: 1em auto;}.card {    display: grid;    grid-template-rows: max-content 200px 1fr;    border: 1px solid #999;    border-radius: 3px;}.card img {    object-fit: cover;    width: 100%;    height: 100%;}.card h2 {    margin: 0;    padding: .5rem;}.card .content {    padding: .5rem;}.card footer {    background-color: #333;    color: #fff;    padding: .5rem;}复制代码

A short heading

Hot air balloons

The idea of reaching the North Pole by means of balloons appears to have been entertained many years ago.

A short heading

Hot air balloons

Short content.

I have a footer!

A longer heading in this card

Hot air balloons

In a curious work, published in Paris in 1863 by Delaville Dedreux, there is a suggestion for reaching the North Pole by an aerostat.

I have a footer!

A short heading

Hot air balloons

The idea of reaching the North Pole by means of balloons appears to have been entertained many years ago.

复制代码

多列布局(Column layouts)

There are a number of design patterns you might want to achieve with your columns:

  • A continuous thread of content broken up into newspaper-style columns.
  • A single row of items arranged as columns, with all heights being equal.
  • Multiple rows of columns lined up by row and column.
.container {    border: 2px solid rgb(75, 70, 74);    border-radius: .5em;    padding: 20px;    column-width: 10em;    column-rule: 1px solid rgb(75, 70, 74);}复制代码

Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic.

Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini.

Turnip greens yarrow ricebean rutabaga endive cauliflower sea lettuce kohlrabi amaranth water spinach avocado daikon napa cabbage asparagus winter purslane kale. Celery potato scallion desert raisin horseradish spinach.

复制代码

参考文章

转载于:https://juejin.im/post/5cd27e666fb9a032374f652f

你可能感兴趣的文章
CuteEditor.Editor+a+a+c+a+a.a() System.RuntimeType.get_Assembly() 问题解决方法
查看>>
Int8 and UInt8 types different from Byte and SByte
查看>>
全面剖析Cocos2d游戏触摸机制 (下)
查看>>
Android 检测网络连接状态(转)
查看>>
Javascript的转义Escape
查看>>
C++结构体中的静态变量
查看>>
JSON.parse()和JSON.stringify()
查看>>
mysql 查排名
查看>>
中国最大的融资平台
查看>>
OO第二单元作业小结
查看>>
[华为机试练习题]37.合唱队
查看>>
犯错了~
查看>>
[PHP] 最简单的权限控制设计
查看>>
在虚拟机和主机之间共享文件夹
查看>>
用户场景描述
查看>>
JSAP107
查看>>
cocos2d-x学习笔记12:如何将win32移植到iOS
查看>>
你们可能都小看了Windows!
查看>>
linux下mrtg,cacti,nagios,ganglia的搭建和win/linux主机等的监控。
查看>>
写在网管员世界杂志更名之际
查看>>