Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Absolute positioned view inherits the padding from parent #4240

Closed
meznaric opened this issue Nov 19, 2015 · 4 comments
Closed

Absolute positioned view inherits the padding from parent #4240

meznaric opened this issue Nov 19, 2015 · 4 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@meznaric
Copy link

I've built this RNPlay.org to demonstrate the issue.

When View is absolutely positioned inside a View that has a padding, padding gets inherited by absolutely positioned div. I did not expect this behaviour at all. Is this normal?

@brentvatne
Copy link
Collaborator

Hi @meznaric! I'm not really sure what the issue is -- no padding is being inherited in the example that you provided. Perhaps you mean the spacing on Text -- you actually can't use the flex property on Text, you should just use that on container views. I fixed your example here: https://rnplay.org/apps/yAseGA

@meznaric
Copy link
Author

Hey @brentvatne! I forked your example and reintroduced paddingHorizontal which you removed. I also changed the colours for clarity. Here is the updated code https://rnplay.org/apps/4M1JoA (look at iOS version).

What I expect:

  • Container has paddingHorizontal and its contents should respect it
  • Absolutely positioned Views inside Container shouldn't be affected by Container's padding

What I get:

  • Absolutely positioned Views (in my example error) have some weird padding on the right which seems to be double of paddingHorizontal (paddingLeft+paddingRight). Where does it come from?

Problem

Hopefully I described a problem better this time.

@brentvatne
Copy link
Collaborator

Hey @meznaric! Thanks for that, it definitely helped! I'll create an issue on https://github.com/facebook/css-layout and reference this! 😄

@nikoloza
Copy link

nikoloza commented Dec 6, 2017

Workaround for this can be:

Instead of:

width: '100%'

Use:

left: 0,
right: 0,

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants