
Responsive Web Design (RWD) framework
The Responsive Web Design (RWD) framework uses several technologies and design patterns to create a responsive storefront across devices.
Fluid layouts and grids
The responsive storefront uses fluid layouts, where most of the page components contain percentage widths. Dynamic adjustments are enabled for the storefront layout and page elements when the screen resolution or browser window is resized.
The fluid grid system is defined in the WC_eardir/Stores.war/storedir/css/base.css file. This CSS file is the stylesheet for CSS rules common to all store pages. For more information about the files used in responsive starter stores, see Responsive Aurora starter store file structure.
The grid system is a CSS framework that helps build layouts by constructing a page into rows and columns. A 12-column fluid grid system with containers is used by default in the responsive storefront. This approach can then be used in customization scenarios to create consistent custom containers.
The fluid grid system with responsive features is used to build responsive layout templates and container widgets.
Example: Fluid grid
<div class="row">
<div class="col12"></div>
</div>
<div class="row">
<div class="col6"></div>
<div class="col6"></div>
</div>
<div class="row">
<div class="col4"></div>
<div class="col4"></div>
<div class="col4"></div>
</div>
<div class="row">
<div class="col3"></div>
<div class="col3"></div>
<div class="col3"></div>
<div class="col3"></div>
</div>
<div class="row">
<div class="col2"></div>
<div class="col2"></div>
<div class="col2"></div>
<div class="col2"></div>
<div class="col2"></div>
<div class="col2"></div>
</div>
<div class="row">
<div class="col1"></div>
<div class="col11"></div>
</div>
<div class="row">
<div class="col2"></div>
<div class="col10"></div>
</div>
<div class="row">
<div class="col3"></div>
<div class="col9"></div>
</div>
<div class="row">
<div class="col4"></div>
<div class="col8"></div>
</div>
<div class="row">
<div class="col5"></div>
<div class="col7"></div>
</div>
Considerations for rows and columns in a fluid grid system
- A row is always divided into 12 columns, regardless of the breakpoint.
- A row's child element can span 1 to 12 columns, regardless of
the breakpoint by using one of the
col*
classes. - If a row has child elements spanning a total of more than 12 column,
they flow according to how HTML handles float elements.For example, for a row containing 3 child elements spanning 8, 8 and 4 columns:
- The first child element is positioned at the top left of the row spanning 8 columns. That is, 2/3 of the row's width.
- The second child element is positioned under the first child element, also spanning 8 columns.
- The third child element is positioned to the right of the second child element, spanning 4 columns. That is, 1/3 of the row's width.
- A row's child element can respond to the RWD-A and RWD-C breakpoints
by using the
acol*
class for RWD-A orccol*
class for RWD-C.For example, a row's child element can span 6 columns by default and 12 columns in the RWD-A breakpoint by using
class="col6 acol12"
. - Rows and their child elements should have a flexible or automatic height, as a fixed row height interferes with column stacking. Fixed child element heights are typically acceptable, but should be avoided since content heights can change as a row's child elements resize horizontally with the viewport.
- The fluid grid system does not have built-in gutters, or margins, between a row's child elements. A separate set of CSS rules is used to define the margins between widgets.
- Do not apply any margin to a row's child elements, as that causes the column width total to exceed 100%.
- Avoid borders or padding to a row's child elements, as that requires
box-sizing: border-box
tagging. In addition, this rule also applies for rows. However, row margins are acceptable. - The
col*
classes contain no breakpoints. Elements with only thecol*
classes do not stack, regardless of the viewport width.
Column stacking
Column
stacking can be enabled by specifying the column span for the RWD-A
breakpoint using the acol*
classes.
acol12
. For example, for a row containing
2 child elements with the col4 acol12
classes and col8
acol12
classes respectively. In this scenario, the child
elements are side by side by default, spanning 4 and 8 columns respectively.
The acol12
class, however, makes the child elements
span 12 columns each in the RWD-A breakpoint, so that they are laid
out vertically, each spanning the full width of the row.- It is valid to have a row with child elements that span a total of more than 12 columns at certain breakpoints. The result is that they stack when the row runs out of space.
- it is possible to merge rows to reduce HTML markup, as long as their child elements can be divided into groups that span 12 columns in total.
- The
col*
classes are used instead ofbcol*
since it is used not only for RWD-B, but for all viewport widths, regardless of breakpoint. That is, RWD-B is used by default and theacol*
andccol*
classes are used as overrides.
Column nesting
You can nest a row and its child elements within the child element of another row. This causes content to overlap with other elements on store pages.
Stacking order
The stacking order lets you control where a sidebar element is stacked, relative to the content element.