Disable stretch height on Carousel Container
See original GitHub issueHello,
I am having a problem here, current carousel height is stretched. If i inspect there is a view that having flex:1. I have tried to set containerCustomStyle, contentContainerCustomStyle, slideStyle flex to 0 but the carousel still stretching the height.
<View style={{flex:1,justifyContent:'center',alignItems:'center'}}>
<View>
<Carousel
sliderWidth={width}
itemWidth={width-70}
showsHorizontalScrollIndicator={false}
containerCustomStyle={{flex:0}}
contentContainerCustomStyle={{flex:0,alignItems:'flex-start'}}
slideStyle={{flex:0}}
onSnapToItem={this.activeSlide}>
{items}
</Carousel>
</View>
</View>
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Disable stretch height on Carousel Container #57 - GitHub
Hello, I am having a problem here, current carousel height is stretched. If i inspect there is a view that having flex:1.
Read more >carousel - Set caroseul to a fixed height and prevent images ...
Solution - 1. Make the container that holds the image to height:500px and use photoshop or any online tool to make the image's...
Read more >Consistent Height Carousels with CSS Gradients and Object Fit
The documentation tells you to add an an image with a class of d-block w-100 That means that it will shrink or stretch...
Read more >overscroll-behavior - CSS: Cascading Style Sheets | MDN
The overscroll-behavior CSS property sets what a browser does when reaching the boundary of a scrolling area.
Read more >Carousel - Bootstrap
Carousels don't automatically normalize slide dimensions. As such, you may need to use additional utilities or custom styles to appropriately size content.
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
@mostafa No problem 😃 I’ll add the following to the documentation as soon as I’m finished with the update I’m currently working on.
Carousel’s stretched height
Since
<Carousel />
is, ultimately, based on<ScrollView />
, it inherits its default styles and particularly{ flexGrow: 1 }
. This means that, by default, the carousel container will stretch to fill all the available space.If this is not what you’re after, you can prevent this behavior by passing
{ flexGrow: 0 }
to the propcontainerCustomStyle
.Alternatively, you can either use this prop to pass a custom height to the container, or wrap the carousel in a
<View />
with a fixed height.@ariona After giving this a second thought, I realized that I’ve made a mistake: our
<Carousel />
is basically a<ScrollView />
and, as such, inherits from its default styles, especiallyflexGrow: 1
.You should be able to deal with it thanks to the prop
containerCustomStyle
. I know you’ve triedflex: 0
, but can you giveflexGrow: 0
a try? If this doesn’t work, you should either use this prop to pass a custom height to the container or wrap the carousel in a<View />
with fixed height.