I’m building an app on RN and I made the mistake to put my values in pixels instead of percentages so it fits with all screen sizes…
Can someone help me convert those values into percentage in my javascript code ?
buttonContainer: {
flexDirection: ‘row’,
justifyContent: ‘space-between’,
width: ‘80%’,
marginTop: 10,
},
arrowButton: {
padding: 10,
marginHorizontal: ‘50%’,
marginLeft: ‘0%’,
},
arrowImage: {
width: 60, // Adjust the width as needed
height: 40, // Adjust the height as needed
right: ‘30%’,
marginHorizontal: ‘10%’,
top: ‘150%’,
},
selectButton: {
marginBottom: ‘10%’,
paddingVertical: 10,
paddingHorizontal: 20,
backgroundColor: ‘#007BFF’,
borderRadius: 8,
left: ‘1%’,
},
2
Answers
Here is more of my code :)
Good evening,
you should wrap your code into a code box (even better with css syntax highlighting). 😉
To transform your absolute values into percentage ones, we would have to know the surrounding code/layout/sizes. E.g.: The child is as big, as the parent when setting width/height to 100%.
So way more information needed on this one, or am I getting you totally wrong here?
Best regards