Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add padding or margin only to the layout container in Angular ngMaterial?

When I add layout-margin or layout-padding to a layout container this adds margin/padding around each flex child element and to the container itself.

Example:

<div layout="row" layout-margin>
  <div flex>Parent layout and this element have margins.</div>
</div>

flex with margins

I want to add margins to the the container and not to the childrens of the container.

margins to container only

Is there a predefined class in Material Design to add padding or margin to the layout container without adding them to the childrens inside the layout container?

like image 804
Mustapha Aoussar Avatar asked Nov 27 '15 17:11

Mustapha Aoussar


People also ask

How do I add padding to material UI?

To add padding and margin to all React Material-UI components, we can use the Box component. We use Material UI's Box component to add a container with margin and padding. We set the margin on all sides with the m prop and we set the top padding with the pt prop.

What is padding vs margin?

In CSS, a margin is the space around an element's border, while padding is the space between an element's border and the element's content. Put another way, the margin property controls the space outside an element, and the padding property controls the space inside an element.


2 Answers

Please try this ,

<div layout="row" class=md-margin>
  <div flex>Parent layout and this element have margins.</div>
</div>
like image 195
Özgür ÇATALKAYA Avatar answered Sep 23 '22 00:09

Özgür ÇATALKAYA


You can create class parent for container and write css as follows.

.container {
   margin : 20px;
}

Hope this helps!

like image 29
Zeel Shah Avatar answered Sep 20 '22 00:09

Zeel Shah