简体   繁体   English

如何使用 Angular 并排获取组件?

[英]How do I get the components side by side using Angular?

Please, explain this simple thing to the novice.请向新手解释这个简单的事情。

So I have 3 three components made in Angular:所以我在 Angular 中制造了 3 个三个组件:

  • App.Component (Which comes automatically) App.Component(自动出现)
  • Dog.Component狗组件
  • Cat.Component猫组件

The cat and dog components contain one images of these animals.猫和狗组件包含这些动物的一张图像。

Question: How and where do I put the code snippet when I want to get the cat & dog components side by side(not below)?问题:当我想将 cat & dog 组件并排放置(不在下方)时,如何以及在何处放置代码片段? Index.html/styles.css? Index.html/styles.css? or App.Component?还是 App.Component? or?或者?

As you can see, I may be a little lost with this structure at this point...如您所见,此时我可能对这种结构有些迷茫……

You can create a wrapper using a div and then apply the styles in CSS that will make the components be side by side.您可以使用 div 创建包装器,然后在 CSS 中应用 styles,这将使组件并排。

Example例子

In your App component HTML:在您的应用程序组件 HTML 中:

<div class="app-container">
   <dog-component></dog-component>
   <cat-component></cat-component>
</div>

App component CSS:应用组件 CSS:

.app-container {
   display: flex;
}

I have used bootstrap to display image side by side.我使用引导程序并排显示图像。

 <div class="col-md-12 col-sm-12"> <div class=" col-md-6 col-sm-6"> <dog-component></dog-component> </div> <div class=" col-md-6 col-sm-6"> <cat-component></cat-component> </div> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在客户端使用 Ionic 5 和 angular,在服务器端使用 Flask,如何加密我的 http URL 参数? - Using Ionic 5 and angular on client side and Flask on server side, how do I encrypt my http URL parameters? 如何使用 Angular 并排添加 2 个标题元素? - How can I add 2 Title elements side by side using Angular? 如何在 Web 应用程序中并排放置 Angular 组件 - How to place Angular components side by side in web app Angular 并排放置两个组件 - Angular putting two components side by side 如何在服务器端重用 Angular 表单进行验证? - How do I reuse Angular form on server side for validation? 使用 Angular Universal 时客户端渲染部分组件 - Client-side render some components when using Angular Universal 在angular 2中,如何在某些组件中隐藏侧面导航栏 - In angular 2 , how to hide side nav bar in some components 结合使用Meteor和Angular2 / Typescript,如何基于客户端事件从服务器端代码调用外部Web服务? - Using Meteor with Angular2/Typescript, how do I call an external web service from server-side code based on a client-side event? 如何在服务器端Angular Universal上获取Cookie - How to get cookie on the server side Angular Universal 如何在带有Angular CLI的Angular 2中使用Angular Universal进行服务器端渲染? - How to do server side rendering using Angular universal in Angular 2 with Angular CLI?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM