Angular PrimeNG垂直分割线与内容

Angular PrimeNG垂直分割线与内容

Angular PrimeNG是一个开源框架,拥有丰富的原生Angular UI组件,可用于出色的造型,该框架可用于制作响应式网站,非常方便。在这篇文章中,我们将了解如何在Angular PrimeNG中使用Divider Vertical with Content。我们还将学习属性和样式,以及在代码中使用的语法。

分割器组件是用来做一个使用分割器分割内容的组件。

Angular PrimeNG Divider Vertical with Content属性:

  • type。它是边框样式的类型。它有3个可能的值,即虚线、点线实线。它是字符串数据类型,默认值是solid
  • align: 它用于设置内容的对齐方式。它的数据类型是字符串,默认值是null
  • layout。它用于指定方向。它是字符串数据类型,默认值是horizontal
  • style。它是组件的内联风格。它属于对象数据类型,默认值为null
  • styleClass。它是组件的风格类。它的数据类型是字符串,默认值是null

语法:

<div class="p-grid">
    <div class="p-col-5 p-d-flex 
        p-ai-center p-jc-center">
          ...
    </div>

    <div class="p-col-2">
      <p-divider layout="vertical">
        ...
      </p-divider>
    </div>

    <div class="p-col-5 p-d-flex 
        p-ai-center p-jc-center">
          ...
    </div>
</div>

创建Angular应用程序和模块安装。

第1步:使用以下命令创建一个Angular应用程序。

ng new appname

第2步:创建你的项目文件夹即appname后,使用以下命令移动到它。

cd appname

第3步:在你给定的目录中安装PrimeNG。

npm install primeng --save
npm install primeicons --save

项目结构:它将看起来像如下。

Angular PrimeNG垂直分割线与内容

运行以下命令以查看输出。

ng serve --open

例子1:这是说明使用Angular PrimeNG Divider Vertical with Content.的基本例子代码。

<div style="text-align: center">
  <h2 style="color: green">GeeksforGeeks</h2>
  <h5>PrimeNG Divider Vertical with Content</h5>
</div>
  
<div class="p-grid">
  <div class="p-col-4 p-d-flex p-ai-center 
     p-jc-center">
    <div class="p-fluid">
      <div class="p-field">
        <input
          placeholder="Enter the Email"
          pInputText
          id="email"
          type="email"
        />
      </div>
  
      <div class="p-field">
        <input
          placeholder="Enter the Password"
          pInputText
          id="password"
          type="password"
        />
      </div>
  
      <div class="p-field">
        <input
          placeholder="Re-Enter the Password"
          pInputText
          id="password"
          type="password"
        />
      </div>
  
      <p-button styleClass="p-button-success" 
        label="SignUp to GfG"> 
      </p-button>
    </div>
  </div>
  
  <div class="p-col-4">
    <p-divider layout="vertical">
      <b>OR</b>
    </p-divider>
  </div>
  
  <div class="p-col-4 p-d-flex p-ai-center 
     p-jc-center">
    <div class="p-fluid">
      <div class="p-field">
        <input
          placeholder="Enter the Email"
          pInputText
          id="email"
          type="email"
        />
      </div>
  
      <div class="p-field">
        <input
          placeholder="Enter the Password"
          pInputText
          id="password"
          type="password"
        />
      </div>
  
      <p-button styleClass="p-button-success" 
        label="Login to GfG"> 
      </p-button>
    </div>
  </div>
</div>
import { Component } from "@angular/core";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
  
export class AppComponent {}
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } from 
    "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { DividerModule } from "primeng/divider";
import { ButtonModule } from "primeng/button";
  
@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    DividerModule,
    ButtonModule
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {}

输出:

Angular PrimeNG垂直分割线与内容

例子2:下面是另一个例子,说明了使用Angular PrimeNG Divider Vertical with Content作为图像。

<div style="text-align: center">
  <h2 style="color: green">GeeksforGeeks</h2>
  <h5>PrimeNG Divider Vertical with Content</h5>
</div>
  
<div class="p-grid">
  <div class="p-col-5 p-d-flex 
     p-ai-center p-jc-center">
    <img alt="gfg" src=
"https://media.geeksforgeeks.org/wp-content/uploads/20220807104303/dsaselfpacedcourseoverviewimage-300x289.png">
  </div>
  
  <div class="p-col-2">
    <p-divider layout="vertical">
      <b>OR</b>
    </p-divider>
  </div>
  
  <div class="p-col-5 p-d-flex 
     p-ai-center p-jc-center">
    <img alt="gfg" src=
"https://media.geeksforgeeks.org/wp-content/uploads/20220807104255/completeinterviewpreparationcourseoverviewimage-300x289.png">
  </div>
</div>
import { Component } from "@angular/core";
  
@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
  
export class AppComponent {}
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } from 
    "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { DividerModule } from "primeng/divider";
import { ButtonModule } from "primeng/button";
  
@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    DividerModule,
    ButtonModule
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {}

输出:

Angular PrimeNG垂直分割线与内容

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程