如何使用angular的* ngFor]内联显示项目>

问题描述 投票:0回答:3

我正在尝试以内联方式显示项目,而不是显示在其他行中。请参见下面的代码和图片。我试图在网上寻找解决方案,但其他所有人都在要求不同的用例。请告诉我。谢谢!

enter image description here

<!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Document</title>
 </head>
 <body>
    <div>
        <div class="pimg1">
           <div class="ptext">
               <span class="borderStyle">
                   Kenny's Site
               </span>
           </div>
        </div>
        <section class="section section-light">
            <h2>Skills</h2>
            <p class="skills" *ngFor="let skill of skills">{{skill.skill}}</p>
        </section>
        <div class="pimg2">
           <div class="ptext">
               <span class="borderStyle">
                   Image2 Text
               </span>
           </div>
        </div>
        <section class="section section-dark">
           <h2>Section 1</h2>
           <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolores, saepe.</p>
       </section>
       <div class="pimg3">
           <div class="ptext">
               <span class="borderStyle">
                   Image3 Text
               </span>
           </div>
        </div>
        <section class="section section-dark">
           <h2>Section 3</h2>
           <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolores, saepe.</p>
       </section>
       <div class="pimg1">
           <div class="ptext">
               <span class="borderStyle">
                   Kenny's Site
               </span>
           </div>
        </div>
    </div>
 </body>
 </html>

我正在尝试以内联方式显示项目,而不是显示在其他行中。请参见下面的代码和图片。我试图在网上寻找解决方案,但其他所有人都在询问不同的用例....

javascript css arrays angular ngfor
3个回答
3
投票

我认为这不是一个有角度的问题。您需要管理CSS才能使技能显示在Flex或网格中。


0
投票

您可以在此处使用css flexbox模式。尝试将类添加到<p>标记中并为其提供以下属性


0
投票
    if you don't want to mess around that much with CSS attributes you should have a look at [@angular/flex-layout][1]


          [1]: https://github.com/angular/flex-layout

        1. Rows made like this: 
        <div fxLayout="row wrap">
          <div fxFlex="50%" [fxFlex.lt-md]="100%" fxLayoutAlign="start center">

          </div>
          <div fxFlex="50%" [fxFlex.lt-md]="100%" fxLayoutAlign="end center">

          </div>
        </div>

        2. Columns made like this:

        <div fxLayout="column wrap">
          <div fxFlex="50%" fxLayoutAlign="start center">

          </div>
          <div fxFlex="50%" fxLayoutAlign="end center">

          </div>
        </div>


    [fxFlex.lt-md] makes the styling responsive, depending on your current user's viewport. There are *.lt-sm, *.lt-md and also *.gt-sm and so on...

And you may use on any flexLayout directives like "fxLayoutAlign" and others...
© www.soinside.com 2019 - 2024. All rights reserved.