You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we use components in angular. We are fairly similar with the selector syntax like app-component or app-home etc. Which are similar to how custom-elements are defined. So, browsers don't have a clue on how to render these. And so defines them as inline elements.
If an element is inline the width and height doesn't effect. And so, if the element is styled internally with a width and height the changes still doesn't have any effect. Let's take a look at an example from Angular
The component root has a width of 100% explicitly set by the user, but this doesn't reflect because. The encapsulated app-component behaves as a inline element.
JayaKrishnaNamburu
changed the title
Angular Projects render un-expectedly when they are exported
Angular Projects render un-expectedly when they are exported, because of the custom tag wrapper around them
Apr 21, 2021
JayaKrishnaNamburu
changed the title
Angular Projects render un-expectedly when they are exported, because of the custom tag wrapper around them
Projects render un-expectedly when they are exported, because of the custom tag wrapper around them
Apr 21, 2021
Issue
When we use
components
in angular. We are fairly similar with theselector
syntax likeapp-component
orapp-home
etc. Which are similar to howcustom-elements
are defined. So, browsers don't have a clue on how to render these. And so defines them asinline
elements.If an element is
inline
the width and height doesn't effect. And so, if the element is styled internally with a width and height the changes still doesn't have any effect. Let's take a look at an example from AngularCodesandbox link --> https://codesandbox.io/s/bjkpo
![Screenshot 2021-04-20 at 8 08 56 PM](https://user-images.githubusercontent.com/11075561/115415252-60158200-a214-11eb-9921-951a09ac7678.png)
The component root has a width of
100%
explicitly set by the user, but this doesn't reflect because. The encapsulatedapp-component
behaves as ainline
element.CSS for the root element inside component
Let's check the same example using React
![Screenshot 2021-04-20 at 8 08 48 PM](https://user-images.githubusercontent.com/11075561/115415747-c9959080-a214-11eb-8d80-9af546afa007.png)
Codesandbox link --> https://codesandbox.io/s/7x28c
Solution
contents
to the:host
of the component. So, the component wrapper doesn't effect the way in which things are rendered. Like herehttps://codesandbox.io/s/angular-bug-forked-4lcpk?file=/src/app/components/component/component.component.css
width
to the the:host
when any width is explicitly mentioned on the root of the element.My opinion is
contents
works the best. Since, with the second solution we might sometimes come across un-expected behaviours too.The text was updated successfully, but these errors were encountered: