CSS when inline-block elements line-break, parent wrapper does not fit new width
You can't. By default, inline-block
elements have a shrink-to-fit width:
The shrink-to-fit width is:
min(max(preferred minimum width, available width), preferred width)
.
Then,
- When
preferred minimum width <= preferred width <= available width
, the width will be thepreferred width
, as you desire. - When
available width <= preferred minimum width <= preferred width
, the width will be thepreferred minimum width
, as you desire. - When
preferred minimum width <= available width <= preferred width
, the width will be theavailable width
, even if you don't like it.
If you really don't want this, I guess you could add a resize
event listener with JS, and set the desired width manually.
Remove width after line break in div
It is happening because the text is wrapping into the second line when enough space is not available for the next word. This situation is coming in screen sizes between around 700px to 900px wide.
Use the relevant word wrapping techniques to get the desired result.
If you want your text in one line and don't want them to wrap then add white-space: nowrap;
style in .list-text
class.
CSS when inline-block elements line-break, parent wrapper does not fit new width
You can't. By default, inline-block
elements have a shrink-to-fit width:
The shrink-to-fit width is:
min(max(preferred minimum width, available width), preferred width)
.
Then,
- When
preferred minimum width <= preferred width <= available width
, the width will be thepreferred width
, as you desire. - When
available width <= preferred minimum width <= preferred width
, the width will be thepreferred minimum width
, as you desire. - When
preferred minimum width <= available width <= preferred width
, the width will be theavailable width
, even if you don't like it.
If you really don't want this, I guess you could add a resize
event listener with JS, and set the desired width manually.
Related Topics
Angular - Show Empty Row by Default in Drop Down List and Disable Button
Nested Ngfor Looping Over an Array of Objects
Angular, Image Not Found (Get 404)
Html/Css - Make Alert Disappear After a Few Seconds
How to Clear Input Field After Submitting Data in Angular
How to Embed HTML Formatting Inside of a <Textarea> Tag
Div Elements Overlapping Each Other
Zoom to Fit: Pdf Embedded in HTML
Inserting an Image from Local Directory in Thymeleaf Spring Framework (With Maven)
How to Get Angular to Reload the Same Page But With a Different Argument
Navbar(Menu) Is Getting Overlapped by Body Element
Item Moving Around When Window Resized
How to Force Position Absolute With 100% Width to Fit into Parent Div With Padding
Open an Exe File Through a Link in a HTML File
How to Remove Blue Highlight on Hover in Select, Option Inputs HTML for Chrome