Flexbox with one fixed column width [duplicate]

Instead of setting width in % on right column you can just use flex: 1 and it will take rest of free width in a row. .flex_container { display: flex; width: 100%; } .flex_item_left { width: 200px; background: lightgreen; } .flex_item_right { flex: 1; background: lightblue; } <div class=”flex_container”> <div class=”flex_item_left”> ….. </div> <div class=”flex_item_right”> … Read more

How to vertically align Bootstrap v4 modal dialogs

Update, as of Beta 3, [docs]: Add .modal-dialog-centered to .modal-dialog to vertically center the modal. Original answer: SCSS: .modal-dialog { min-height: calc(100vh – 60px); display: flex; flex-direction: column; justify-content: center; overflow: auto; @media(max-width: 768px) { min-height: calc(100vh – 20px); } } or unprefixed CSS: .modal-dialog { min-height: calc(100vh – 60px); display: flex; flex-direction: column; justify-content: … Read more

Flexbox alternative for IE9

Use modernizr to detect whether flex capabilities are present, and provide fallback styles where necessary. Modernizr will add classes like flexbox, no-flexbox, and flexbox-legacy to the html element, so in your styles you can use: .container { display: flex; } .no-flexbox .container { display: table-cell; } I highly recommend reading through Zoe Gillenwater’s (@zomigi) presentations … Read more

In what circumstances is flex-shrink applied to flex elements and how does it work?

In order to see flex-shrink in action, you need to be able to make its container smaller. HTML: <div class=”container”> <div class=”child one”> Child One </div> <div class=”child two”> Child Two </div> </div> CSS: div { border: 1px solid; } .container { display: flex; } .child.one { flex: 1 1 10em; color: green; } .child.two … Read more

Removing margin from flex items when they wrap

Update in late 2021 Now the gap property also works with Flexbox (on newer browser versions). * { margin: 0; padding: 0; } html, body { box-sizing: border-box; } .container { width: 600px; margin: 0 auto; margin-top: 25px; border: 1px solid; padding: 5px; } .tags { list-style-type: none; display: flex; flex-direction: row; flex-wrap: wrap; justify-content: … Read more

React-Native: Avoid Text Wrapping

The solution ended up being fairly simple. Not entirely intuitive but here’s how to solve this. It appears that the text that needs ellipsis requires flex: 1. <View style={{ flexDirection: “row” }}> <Text numberOfLines={1} style={{ flex: 1, textAlign: “left” }}> {title} </Text> <Text style={{ textAlign: “right” }}>{duration}</Text> </View>;

Flexbox : grow all items but last line

You can add an ::after pseudo-element with a huge flex-grow, so that the flex-grow: 1 of the li elements will be negligible: ul::after { content: ”; flex-grow: 1000000000; } ul { display: flex; flex-wrap: wrap; list-style: none; padding: 0; } li { flex-grow: 1; padding: 20px; margin: 10px; background: #ddd; } ul::after { content: ”; … Read more