Movatterモバイル変換


[0]ホーム

URL:


CoreUI Angular Logo
Framework:
Getting startedIntroductionSupport CoreUICustomizeSassOptionsCSS VariablesLayoutBreakpointsContainersGridColumnsGuttersFormsOverviewAutocompletePRODate PickerPRODate Range PickerPROForm ControlSelectMulti SelectPROChecks & RadiosPassword InputPRORangeRange SliderPRORatingPROStepperPROInput GroupFloating LabelsLayoutTime PickerPROValidationComponentsAccordionAlertAvatarBadgeBreadcrumbButtonButton GroupCalendarPROCalloutCardCarouselClose buttonCollapseDropdownFooterHeaderImageList GroupLoading ButtonPROModalNavNavbarOffcanvasPaginationPlaceholderPopoverProgressSmart PaginationPROSmart TablePROSidebarSpinnerTableTabsNewToastTooltipWidgetsIconsChartsTemplatesNewAdmin & DashboardDownloadInstallationCustomizeContentMigrationv4 → v5v3 → v4Angular version


DownloadHire UsGet CoreUI PRO

Angular Columns

Learn how to modify columns with a handful of options for alignment, ordering, and offsetting thanks to flexbox grid system.

How they work

  • Columns build on the grid's flexbox architecture. Flexbox means we have options for changing individual columnsandmodifying groups of columns at the row level. Youchoose how columns grow, shrink, or otherwise change.

  • When building grid layouts, all content goes in columns. The hierarchy of CoreUI grid goes fromcontainer torow to column to your content. On rare occasions, you may combine content and column, but be aware there can beunintended consequences.

  • CoreUI for Angular includes predefined components for creating fast, responsive layouts. Withsixbreakpointsand a dozen columns at each grid tier, we have dozens of components already built for you to create your desiredlayouts. This can be disabled via Sass if you wish.


Alignment

Use flexbox alignment utilities to vertically and horizontally align columns.

Vertical alignment

One of three columnsOne of three columnsOne of three columnsOne of three columnsOne of three columnsOne of three columnsOne of three columnsOne of three columnsOne of three columns
<c-container>  <c-row>    <c-col>One of three columns</c-col>    <c-col>One of three columns</c-col>    <c-col>One of three columns</c-col>  </c-row>  <c-row>    <c-col>One of three columns</c-col>    <c-col>One of three columns</c-col>    <c-col>One of three columns</c-col>  </c-row>  <c-row>    <c-col>One of three columns</c-col>    <c-col>One of three columns</c-col>    <c-col>One of three columns</c-col>  </c-row></c-container>
import { Component } from '@angular/core';import { ColComponent, ContainerComponent, RowComponent } from '@coreui/angular';@Component({  selector: 'docs-columns01',  templateUrl: './columns01.component.html',  styleUrls: ['./columns01.component.scss'],  standalone: true,  imports: [ContainerComponent, RowComponent, ColComponent]})export class Columns01Component {}
:host {  .row {    background-color: rgba(255, 0, 0, .1);    min-height: 10rem;  }  .row+.row {    margin-top: 1rem;  }  .row > .col, .row > [class^=col-] {    background-color: rgba(39, 41, 43, .03);    border: 1px solid rgba(39, 41, 43, .1);    padding-bottom: .75rem;    padding-top: .75rem;  }}
One of three columnsOne of three columnsOne of three columns
<c-container>  <c-row>    <c-col>One of three columns</c-col>    <c-col>One of three columns</c-col>    <c-col>One of three columns</c-col>  </c-row></c-container>
import { Component } from '@angular/core';import { ColComponent, ContainerComponent, RowComponent } from '@coreui/angular';@Component({  selector: 'docs-columns02',  templateUrl: './columns02.component.html',  styleUrls: ['./columns01.component.scss'],  standalone: true,  imports: [ContainerComponent, RowComponent, ColComponent]})export class Columns02Component {}
:host {  .row {    background-color: rgba(255, 0, 0, .1);    min-height: 10rem;  }  .row+.row {    margin-top: 1rem;  }  .row > .col, .row > [class^=col-] {    background-color: rgba(39, 41, 43, .03);    border: 1px solid rgba(39, 41, 43, .1);    padding-bottom: .75rem;    padding-top: .75rem;  }}

Horizontal alignment

One of two columns One of two columns One of two columns One of two columns One of two columns One of two columns One of two columns One of two columns One of two columns One of two columns One of two columns One of two columns
<c-container>  <c-row>    <c-col xs="4">      One of two columns    </c-col>    <c-col xs="4">      One of two columns    </c-col>  </c-row>  <c-row>    <c-col xs="4">      One of two columns    </c-col>    <c-col xs="4">      One of two columns    </c-col>  </c-row>  <c-row>    <c-col xs="4">      One of two columns    </c-col>    <c-col xs="4">      One of two columns    </c-col>  </c-row>  <c-row>    <c-col xs="4">      One of two columns    </c-col>    <c-col xs="4">      One of two columns    </c-col>  </c-row>  <c-row>    <c-col xs="4">      One of two columns    </c-col>    <c-col xs="4">      One of two columns    </c-col>  </c-row>  <c-row>    <c-col xs="4">      One of two columns    </c-col>    <c-col xs="4">      One of two columns    </c-col>  </c-row></c-container>
import { Component } from '@angular/core';import { ColComponent, ContainerComponent, RowComponent } from '@coreui/angular';@Component({  selector: 'docs-columns03',  templateUrl: './columns03.component.html',  styleUrls: ['./columns03.component.scss'],  standalone: true,  imports: [ContainerComponent, RowComponent, ColComponent]})export class Columns03Component {}
:host {  .row+.row {    margin-top: 1rem;  }  .row > .col, .row > [class^=col-] {    background-color: rgba(39, 41, 43, .03);    border: 1px solid rgba(39, 41, 43, .1);    padding-bottom: .75rem;    padding-top: .75rem;  }}

Column wrapping

If more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a newline.

.col-9 .col-4
Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
.col-6
Subsequent columns continue along the new line.
<c-container>  <c-row>    <c-col xs="9">.col-9</c-col>    <c-col xs="4">      .col-4      <br />      Since 9 + 4 = 13 &gt; 12, this 4-column-wide div gets wrapped onto a new line as one      contiguous unit.    </c-col>    <c-col xs="6">      .col-6      <br />      Subsequent columns continue along the new line.    </c-col>  </c-row></c-container>
import { Component } from '@angular/core';import { ColComponent, ContainerComponent, RowComponent } from '@coreui/angular';@Component({  selector: 'docs-columns04',  templateUrl: './columns04.component.html',  styleUrls: ['./columns03.component.scss'],  standalone: true,  imports: [ContainerComponent, RowComponent, ColComponent]})export class Columns04Component {}
:host {  .row+.row {    margin-top: 1rem;  }  .row > .col, .row > [class^=col-] {    background-color: rgba(39, 41, 43, .03);    border: 1px solid rgba(39, 41, 43, .1);    padding-bottom: .75rem;    padding-top: .75rem;  }}

Column breaks

Breaking columns to a new line in flexbox requires a small hack - add an element withwidth: 100% wherever you wantto wrap your columns to a new line. Normally this is accomplished with multiplec-rows, but not every implementationmethod can account for this.

.col-6 .col-sm-3.col-6 .col-sm-3
.col-6 .col-sm-3.col-6 .col-sm-3
<c-container>  <c-row>    <c-col xs="6" sm="3">.col-6 .col-sm-3</c-col>    <c-col xs="6" sm="3">.col-6 .col-sm-3</c-col>    <div></div>    <c-col xs="6" sm="3">.col-6 .col-sm-3</c-col>    <c-col xs="6" sm="3">.col-6 .col-sm-3</c-col>  </c-row></c-container>
import { Component } from '@angular/core';import { ColComponent, ContainerComponent, RowComponent } from '@coreui/angular';@Component({  selector: 'docs-columns05',  templateUrl: './columns05.component.html',  styleUrls: ['./columns03.component.scss'],  standalone: true,  imports: [ContainerComponent, RowComponent, ColComponent]})export class Columns05Component {}
:host {  .row+.row {    margin-top: 1rem;  }  .row > .col, .row > [class^=col-] {    background-color: rgba(39, 41, 43, .03);    border: 1px solid rgba(39, 41, 43, .1);    padding-bottom: .75rem;    padding-top: .75rem;  }}

You may also apply this break at specific breakpoints with ourresponsive display utilities.

.col-6 .col-sm-4 .col-6 .col-sm-4
.col-6 .col-sm-4 .col-6 .col-sm-4
<c-container>  <c-row>    <c-col xs="6" sm="4">      .col-6 .col-sm-4    </c-col>    <c-col xs="6" sm="4">      .col-6 .col-sm-4    </c-col>    <div></div>    <c-col xs="6" sm="4">      .col-6 .col-sm-4    </c-col>    <c-col xs="6" sm="4">      .col-6 .col-sm-4    </c-col>  </c-row></c-container>
import { Component } from '@angular/core';import { ColComponent, ContainerComponent, RowComponent } from '@coreui/angular';@Component({  selector: 'docs-columns06',  templateUrl: './columns06.component.html',  styleUrls: ['./columns03.component.scss'],  standalone: true,  imports: [ContainerComponent, RowComponent, ColComponent]})export class Columns06Component {}
:host {  .row+.row {    margin-top: 1rem;  }  .row > .col, .row > [class^=col-] {    background-color: rgba(39, 41, 43, .03);    border: 1px solid rgba(39, 41, 43, .1);    padding-bottom: .75rem;    padding-top: .75rem;  }}

Reordering

Order props

Useorder="1" (first,1..5,last) props for controlling the visual order of your content. These props areresponsive, so you can set the order by breakpoint (e.g.,order="{xs: 1, md: 2}").Includes support for 1 through 5 across all six grid tiers.

First in DOM, no order applied Second in DOM, with a larger order Third in DOM, with an order of 1
<c-container>  <c-row>    <c-col>      First in DOM, no order applied    </c-col>    <c-col [order]="5">      Second in DOM, with a larger order    </c-col>    <c-col [order]="{xs: 1}">      Third in DOM, with an order of 1    </c-col>  </c-row></c-container>
import { Component } from '@angular/core';import { ColComponent, ContainerComponent, RowComponent } from '@coreui/angular';@Component({  selector: 'docs-columns07',  templateUrl: './columns07.component.html',  styleUrls: ['./columns03.component.scss'],  standalone: true,  imports: [ContainerComponent, RowComponent, ColComponent]})export class Columns07Component {}
:host {  .row+.row {    margin-top: 1rem;  }  .row > .col, .row > [class^=col-] {    background-color: rgba(39, 41, 43, .03);    border: 1px solid rgba(39, 41, 43, .1);    padding-bottom: .75rem;    padding-top: .75rem;  }}

There are also responsive propsorder="first" andorder="last" with responsive variationsorder={xs: "last", sm: "first"} that change the order of an element by applying order:-1 and order:6,respectively. These values can also be intermixed with the numbered1..5 values as needed.

First in DOM, ordered last Second in DOM, unordered Third in DOM, ordered first
<c-container>  <c-row>    <c-col order="last">      First in DOM, ordered last    </c-col>    <c-col>      Second in DOM, unordered    </c-col>    <c-col [order]="{ xs: 'first' }">      Third in DOM, ordered first    </c-col>  </c-row></c-container>
import { Component } from '@angular/core';import { ColComponent, ContainerComponent, RowComponent } from '@coreui/angular';@Component({  selector: 'docs-columns08',  templateUrl: './columns08.component.html',  styleUrls: ['./columns03.component.scss'],  standalone: true,  imports: [ContainerComponent, RowComponent, ColComponent]})export class Columns08Component {}
:host {  .row+.row {    margin-top: 1rem;  }  .row > .col, .row > [class^=col-] {    background-color: rgba(39, 41, 43, .03);    border: 1px solid rgba(39, 41, 43, .1);    padding-bottom: .75rem;    padding-top: .75rem;  }}

Offsetting columns

You can offset grid columns in two ways: our col propsoffset="0..12" with responsive variationsoffset={md: 2, lg: 3} col props and ourmargin utilities.Grid props are sized to match columns while margins are more useful for quick layouts where the width of the offset is variable.

Offset prop

Move columns to the right usingoffset={ md: * } props. These props increase the left margin of a column by* columns.For example,offset={ md: 4 } moves .col-md-4 over four columns.

.col-md-4.col-md-4 .offset-md-4.col-md-3 .offset-md-3.col-md-3 .offset-md-3.col-md-6 .offset-md-3
<c-container>  <c-row>    <c-col md="4">.col-md-4</c-col>    <c-col md="4" [offset]="{md: 4}" >.col-md-4 .offset-md-4</c-col>  </c-row>  <c-row>    <c-col md="3" [offset]="{md: 3}" >.col-md-3 .offset-md-3</c-col>    <c-col md="3" [offset]="{md: 3}">.col-md-3 .offset-md-3</c-col>  </c-row>  <c-row>    <c-col md="6" [offset]="{md: 3}">.col-md-6 .offset-md-3</c-col>  </c-row></c-container>
import { Component } from '@angular/core';import { ColComponent, ContainerComponent, RowComponent } from '@coreui/angular';@Component({  selector: 'docs-columns09',  templateUrl: './columns09.component.html',  styleUrls: ['./columns03.component.scss'],  standalone: true,  imports: [ContainerComponent, RowComponent, ColComponent]})export class Columns09Component {}
:host {  .row+.row {    margin-top: 1rem;  }  .row > .col, .row > [class^=col-] {    background-color: rgba(39, 41, 43, .03);    border: 1px solid rgba(39, 41, 43, .1);    padding-bottom: .75rem;    padding-top: .75rem;  }}
.col-sm-5 .col-md-6 .col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0 .col-sm-6 .col-md-5 .col-lg-6 .col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0
<c-container>  <c-row>    <c-col sm="5" md="6">      .col-sm-5 .col-md-6    </c-col>    <c-col sm="5" md="6" [offset]="{sm: 2, md: 0}">      .col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0    </c-col>  </c-row>  <c-row>    <c-col sm="6" md="5" lg="6">      .col-sm-6 .col-md-5 .col-lg-6    </c-col>    <c-col sm="6" md="5" lg="6" [offset]="{md: 2, lg: 0}">      .col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0    </c-col>  </c-row></c-container>
import { Component } from '@angular/core';import { ColComponent, ContainerComponent, RowComponent } from '@coreui/angular';@Component({  selector: 'docs-columns10',  templateUrl: './columns10.component.html',  styleUrls: ['./columns03.component.scss'],  standalone: true,  imports: [ContainerComponent, RowComponent, ColComponent]})export class Columns10Component {}
:host {  .row+.row {    margin-top: 1rem;  }  .row > .col, .row > [class^=col-] {    background-color: rgba(39, 41, 43, .03);    border: 1px solid rgba(39, 41, 43, .1);    padding-bottom: .75rem;    padding-top: .75rem;  }}

Margin utilities

You can use margin utilities like.me-auto to force sibling columns away from one another.

.col-md-4.col-md-4 .ms-auto.col-md-3 .ms-md-auto.col-md-3 .ms-md-auto.col-auto .me-auto.col-auto
<c-container>  <c-row>    <c-col md="4">.col-md-4</c-col>    <c-col md="4">.col-md-4 .ms-auto</c-col>  </c-row>  <c-row>    <c-col md="3">.col-md-3 .ms-md-auto</c-col>    <c-col md="3">.col-md-3 .ms-md-auto</c-col>  </c-row>  <c-row>    <c-col xs="auto">.col-auto .me-auto</c-col>    <c-col xs="auto">.col-auto</c-col>  </c-row></c-container>
import { Component } from '@angular/core';import { ColComponent, ContainerComponent, RowComponent } from '@coreui/angular';@Component({  selector: 'docs-columns11',  templateUrl: './columns11.component.html',  styleUrls: ['./columns11.component.scss'],  standalone: true,  imports: [ContainerComponent, RowComponent, ColComponent]})export class Columns11Component {}
:host {  .row+.row {    margin-top: 1rem;  }  c-col {    background-color: rgba(39, 41, 43, .03);    border: 1px solid rgba(39, 41, 43, .1);    padding-bottom: .75rem;    padding-top: .75rem;  }}

Standalone columns

Thec-col component can also be used outside ac-row to give an element a specific width. Whenever columncomponent are used as non direct children of a row, the paddings are omitted.

.col-3: width of 25% .col-sm-9: width of 75% above sm breakpoint
<c-col xs="3">  .col-3: width of 25%</c-col><c-col sm="9">  .col-sm-9: width of 75% above sm breakpoint</c-col>
import { Component } from '@angular/core';import { ColComponent } from '@coreui/angular';@Component({  selector: 'docs-columns12',  templateUrl: './columns12.component.html',  styleUrls: ['./columns03.component.scss'],  standalone: true,  imports: [ColComponent]})export class Columns12Component {}
:host {  .row+.row {    margin-top: 1rem;  }  .row > .col, .row > [class^=col-] {    background-color: rgba(39, 41, 43, .03);    border: 1px solid rgba(39, 41, 43, .1);    padding-bottom: .75rem;    padding-top: .75rem;  }}

The classes can be used together with utilities to create responsive floated images. Make sure to wrap the content ina.clearfix wrapper to clear the float if the text is shorter.

CoreUI for Angular

Notice the use ofcCol md="6" directive. We're using it here to show the use of the clearfix class. We're adding quite a few meaningless phrases here to demonstrate how the columns interact here with the floated image.

As you can see the paragraphs gracefully wrap around the floated image. Now imagine how this would look with some actual content in here, rather than just this boring placeholder text that goes on and on, but actually conveys no tangible information at. It simply takes up space and should not really be read.

And yet, here you are, still persevering in reading this placeholder text, hoping for some more insights, or some hidden easter egg of content. A joke, perhaps. Unfortunately, there's none of that here.

<div>  <img cCol md="6" src="./assets/img/angular.jpg" alt="CoreUI for Angular" />  <p>    Notice the use of <code>cCol md="6"</code> directive. We're using it here to show the use of the    clearfix class. We're adding quite a few meaningless phrases here to    demonstrate how the columns interact here with the floated image.  </p>  <p>    As you can see the paragraphs gracefully wrap around the floated image. Now    imagine how this would look with some actual content in here, rather than    just this boring placeholder text that goes on and on, but actually conveys    no tangible information at. It simply takes up space and should not really    be read.  </p>  <p>    And yet, here you are, still persevering in reading this placeholder text,    hoping for some more insights, or some hidden easter egg of content. A joke,    perhaps. Unfortunately, there's none of that here.  </p></div>
import { Component } from '@angular/core';import { ColDirective } from '@coreui/angular';@Component({  selector: 'docs-columns13',  templateUrl: './columns13.component.html',  standalone: true,  imports: [ColDirective]})export class Columns13Component {}

API reference

Grid Module

import { GridModule } from '@coreui/angular';@NgModule({   imports: [GridModule,]})export class AppModule() { }

c-col cCol

componentdirective

Inputs
propdescriptiontypedefaultnotes
xsThe number of columns on extra small devices (<576px).auto | number | booleanundefined
smThe number of columns on extra small devices (<768px).auto | number | booleanundefined
mdThe number of columns on extra small devices (<992px).auto | number | booleanundefined
lgThe number of columns on extra small devices (<1200px).auto | number | booleanundefined
xlThe number of columns on extra small devices (<1400px).auto | number | booleanundefined
xxlThe number of columns on extra small devices (≥1400px).auto | number | booleanundefined
offsetOffset grid columnsnumber|{sm|md|lg|xl|xxl}:numberundefined
orderControls the visual order of your columns. Includes support for1 through5 across all six grid tiers."first"|"last"|number|{sm|md|lg|xl|xxl}:numberundefined

CoreUI for Angular is Open Source UI Components Library for Angular.

Currently v5.5.17 Code licensed MIT, docs CC BY 3.0 .
CoreUI PRO requires acommercial license.


[8]ページ先頭

©2009-2025 Movatter.jp