- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Avoid wrapping flex-items in Bootstrap
Use the flex-nowrap class in Bootstrap 4 to avoid wrapping the flex items.
Here you can see the difference between wrap and nowrap −
Above the flex-items are not wrapped. This is achieved using the flex-nowrap class in Bootstrap 4 −
<div class="d-flex flex-nowrap bg-primary"> <div class="p-2 border">One</div> <div class="p-2 border">Two</div> <div class="p-2 border">Three</div> <div class="p-2 border">Four</div> <div class="p-2 border">Five</div> <div class="p-2 border">Six</div> <div class="p-2 border">Seven</div> <div class="p-2 border">Eight</div> <div class="p-2 border">Nine</div> </div>
The following is an example to avoid wrapping flex items −
Example
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script> </head> <body> <div class="container mt-3"> <h3>FLEX WRAP AND NOWRAP</h3> <p>Flex items will wrap</p> <div class="d-flex flex-wrap bg-primary"> <div class="p-2 border">One</div> <div class="p-2 border">Two</div> <div class="p-2 border">Three</div> <div class="p-2 border">Four</div> <div class="p-2 border">Five</div> <div class="p-2 border">Six</div> <div class="p-2 border">Seven</div> <div class="p-2 border">Eight</div> <div class="p-2 border">Nine</div> </div><br> <p>Flex items won't wrap</p> <div class="d-flex flex-nowrap bg-primary"> <div class="p-2 border">One</div> <div class="p-2 border">Two</div> <div class="p-2 border">Three</div> <div class="p-2 border">Four</div> <div class="p-2 border">Five</div> <div class="p-2 border">Six</div> <div class="p-2 border">Seven</div> <div class="p-2 border">Eight</div> <div class="p-2 border">Nine</div> </div><br> </div> </body> </html>
- Related Articles
- Avoid wrapping flex-items in Bootstrap on different screens
- Avoid wrapping flex items with CSS
- Allow wrapping of flex items in Bootstrap on different screens
- Enable Wrapping of Flex Items using CSS3
- Wrap flex items in Bootstrap
- Show flex items horizontally in Bootstrap
- Align flex items from everywhere in Bootstrap
- Display flex items vertically in Bootstrap 4
- Wrap flex items in reversed order in Bootstrap
- Display flex items vertically and reversed in Bootstrap 4
- Show flex items right aligned and horizontally in Bootstrap
- Align flex items around on different screen sizes in Bootstrap
- Set Flex Items into equal width columns with Bootstrap
- Wrap flex items in reversed order in Bootstrap on different screens
- Display flex items vertically on different screen sizes in Bootstrap 4

Advertisements