Doesn't fit inside container unless width/height are hard-coded
See original GitHub issueI’d like the Swiper to take up the full size of its parent View
element. Approaches:
- If I don’t specify
width
andheight
attributes, theSwiper
element extends outside the parent container to full-screen (gets size from device properties?). - Styling the container doesn’t appear to have any effect.
- If I hard-code
width
andheight
attributes it will sit inside the container, but I don’t want to hard-code these numbers.
If the container is indeed flex:1
, I’d expect it to expand to the parent container size rather than the full screen dimensions. Is there a way to achieve this?
Issue Analytics
- State:
- Created 8 years ago
- Comments:15 (1 by maintainers)
Top Results From Across the Web
Avoid hardcoding container width - css - Stack Overflow
I'm setting up a grid of images with flex flow, wrap-reverse. Finally got the container setup to overflow, but I had to artificially ......
Read more >Fluid Width Video | CSS-Tricks
Declaring static widths isn't a good idea in fluid width environments. What if the parent container for that video shrinks narrower than the ......
Read more >Intrinsic Sizing - SVG
Firstly, CSS' object-fit sizing determines the concrete object size of the replaced content which is possibly different to the CSS box the replaced...
Read more >Setting Height And Width On Images Is Important Again
To prevent layout shifts and improve performance scores, we need to always set width and height attributes on our images.
Read more >fit-content - CSS: Cascading Style Sheets - MDN Web Docs
The fit-content behaves as fit-content(stretch). In practice this means that the box will use the available space, but never more than ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, so this is horrendously ugly on multiple fronts, but depending on how many times you need to do this… This does work for me… I’m basically just measuring the parent container after it renders (plus a timeout), then just hard-coding it anyway. It’s really not great. Forgive the ES6/7 notation, but it should be reasonably straightforward. Let me know if not. Or if you have a better solution.
@joehui - Your solution worked for me. Thanks