排版设计

Framework7带有许多额外的CSS辅助类,以帮助您进行额外的样式和格式设置。

Content Spacing

Margin

Margin
margin应用于所有边的外边距
margin-left应用于左边的外边距
margin-rightApplies margin to the right
margin-topApplies margin to the top
margin-bottomApplies margin to the bottom
margin-horizontal应用于左右的外边距
margin-vertical应用于上下的外边距
margin-half应用于所有边的一半值外边距
margin-left-half应用于左边的一半值外边距
margin-right-half应用于右边的一半值外边距
margin-top-half应用于顶部的一半值外边距
margin-bottom-half应用于底部的一半值外边距
margin-horizontal-half应用于左右的一半值外边距
margin-vertical-half应用于上下的一半值外边距
no-margin移除外边距
no-margin-left移除左边的外边距
no-margin-right移除右边的外边距
no-margin-topRemoves top margin
no-margin-bottomRemoves bottom margin
no-margin-horizontal移除左右的外边距
no-margin-vertical移除上下的外边距

For example:

<p class="margin-left">Text with left margin</p>
<p class="margin-right">Text with right margin</p>

Padding

Padding
padding应用于所有边的内边距
padding-left应用于左边的内边距
padding-rightApplies padding to the right
padding-topApplies padding to the top
padding-bottomApplies padding to the bottom
padding-horizontalApplies padding to the left and right
padding-verticalApplies padding to the top and bottom
padding-halfApplies half-value padding to all sides
padding-left-halfApplies half-value padding to the left
padding-right-halfApplies half-value padding to the right
padding-top-halfApplies half-value padding to the top
padding-bottom-halfApplies half-value padding to the bottom
padding-horizontal-halfApplies half-value padding to the left and right
padding-vertical-halfApplies half-value padding to the top and bottom
no-paddingRemoves padding
no-padding-leftRemoves left padding
no-padding-rightRemoves right padding
no-padding-topRemoves top padding
no-padding-bottomRemoves bottom padding
no-padding-horizontalRemoves left and right paddings
no-padding-verticalRemoves top and bottom paddings

For example:

<p class="padding-left">Text with left padding</p>
<p class="padding-right">Text with right padding</p>

Float Elements

float-leftThe element will float on the left side of its containing block
float-rightThe element will float on the right side of its containing block
float-noneDisable floating

For example

<div class="float-left">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda earum tempora, voluptatem quas? Beatae cumque, ea porro, eius sed nemo impedit tempora nesciunt, nam necessitatibus quis animi. Nobis, dicta, sit!</p>
</div>
<div class="float-right">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda earum tempora, voluptatem quas? Beatae cumque, ea porro, eius sed nemo impedit tempora nesciunt, nam necessitatibus quis animi. Nobis, dicta, sit!</p>
</div>

Text Alignment

text-align-leftThe inline contents are aligned to the left edge of the line box
text-align-rightThe inline contents are aligned to the right edge of the line box
text-align-centerThe inline contents are centered within the line box
text-align-justifyThe inline contents are justified

For example:

<p class="text-align-center">Center aligned text</p>
<p class="text-align-right">Right aligned text</p>

Element Display

display-blockElement will be displayed as block element
display-inlineElement will be displayed as inline element
display-inline-blockElement will be displayed as inline block element
display-flexElement will be displayed as flex element
display-inline-flexElement will be displayed as inline flex element
display-noneElement will be hidden

For example:

<div class="display-flex">
  <div>Hello</div>
  <div>World!</div>
</div>

Flexbox

有几个辅助类来控制弹性模型:

Flex Direction

CSS的justify-content属性定义了浏览器沿其容器的主轴如何在内容项之间和周围分配空间。

flex-direction-row方向沿一条线排列
flex-direction-row-reverse类似于flex-direction-row,但是是相反的方向
flex-direction-columnThe direction in which lines are stacked
flex-direction-column-reverseLike flex-direction-column, but reversed

Justify Content

CSS的justify-content属性定义了浏览器如何在容器的主轴上分配空间,以及围绕内容项之间的空间分布。

justify-content-flex-startPack flex items from the start
justify-content-centerPack items around the center
justify-content-flex-endPack flex items from the end
justify-content-space-betweenDistribute items evenly. The first item is flush with the start, the last is flush with the end
justify-content-space-aroundDistribute items evenly. Items have a half-size space on either end
justify-content-space-evenlyDistribute items evenly. Items have equal space around them
justify-content-stretchDistribute items evenly. Stretch 'auto'-sized items to fit the container
justify-content-startPack items from the start
justify-content-endPack items from the end
justify-content-leftPack items from the left
justify-content-rightPack items from the right

Align Content

The CSS align-content property defines how the browser distributes space between and around content items along the cross-axis of their container, which is serving as a flexbox container.

align-content-flex-startPack flex items from the start
align-content-flex-endPack flex items from the end
align-content-centerPack items around the center
align-content-space-betweenDistribute items evenly. The first item is flush with the start, the last is flush with the end
align-content-space-aroundDistribute items evenly. Items have a half-size space on either end
align-content-stretchDistribute items evenly. Stretch 'auto'-sized items to fit the container

Align Items

The CSS align-items property defines how the browser distributes space between and around flex items along the cross-axis of their container. This means it works like justify-content but in the perpendicular direction.

align-items-flex-startPack flex items from the start
align-items-flex-endPack flex items from the end
align-items-centerPack items around the center
align-items-stretchDistribute items evenly. Stretch 'auto'-sized items to fit the container

Align Self

The align-self CSS property aligns flex items of the current flex line overriding the align-items value. If any of the item's cross-axis margin is set to auto, then align-self is ignored.

align-self-flex-startPut the flex item at the start
align-self-flex-endPut the flex item at the end
align-self-centerPut the item around the center
align-self-stretchStretch 'auto'-sized items to fit the container

Flex Shrink

flex-shrink CSS属性指定了flex项目的收缩因子。当flex项目的默认宽度大于flex容器时,根据flex-shrink的数值,flex项目将收缩以填充容器。.

flex-shrink-0Sets CSS property flex-shrink: 0
flex-shrink-1Sets CSS property flex-shrink: 1
flex-shrink-2Sets CSS property flex-shrink: 2
flex-shrink-3Sets CSS property flex-shrink: 3
flex-shrink-4Sets CSS property flex-shrink: 4
flex-shrink-5Sets CSS property flex-shrink: 5
flex-shrink-6Sets CSS property flex-shrink: 6
flex-shrink-7Sets CSS property flex-shrink: 7
flex-shrink-8Sets CSS property flex-shrink: 8
flex-shrink-9Sets CSS property flex-shrink: 9
flex-shrink-10Sets CSS property flex-shrink: 10

For example:

<div class="display-flex justify-content-space-between align-items-flex-start">
  <div class="flex-shrink-0">Item 1</div>
  <div class="align-self-center">Item 2</div>
  <div class="align-self-flex-end">Item 3</div>
</div>

CSS Variables

Below is the list of related CSS variables (CSS custom properties).

:root {
  --f7-typography-padding: 16px;
  --f7-typography-margin: 16px;
}