- 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
Wrap flex items in Bootstrap
If you want to wrap flex items in Bootstrap, then use the flex-wrap class. To wrap, use −
<div class="d-flex flex-wrap>
Then add the flex items to be wrapped inside it −
<div class="d-flex flex-wrap> <div class="p-2 border">India</div> <div class="p-2 border">US</div> <div class="p-2 border">UK</div> <div class="p-2 border">Australia</div> <div class="p-2 border">Denmark</div> </div>
You can try to run the following code to avoid wrapping of 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 Examples</h3> <p>Wrap - Yes</p> <div class="d-flex flex-wrap bg-primary"> <div class="p-2 border">India</div> <div class="p-2 border">US</div> <div class="p-2 border">UK</div> <div class="p-2 border">Australia</div> <div class="p-2 border">Denmark</div> <div class="p-2 border">India</div> <div class="p-2 border">Poland</div> <div class="p-2 border">Netherlands</div> <div class="p-2 border">Ireland</div> <div class="p-2 border">Brazil</div> <div class="p-2 border">Russia</div> <div class="p-2 border">Morocco</div> </div><br> <p>Wrap - No</p> <div class="d-flex flex-nowrap bg-primary"> <div class="p-2 border">India</div> <div class="p-2 border">US</div> <div class="p-2 border">UK</div> <div class="p-2 border">Australia</div> <div class="p-2 border">Denmark</div> <div class="p-2 border">India</div> <div class="p-2 border">Poland</div> <div class="p-2 border">Netherlands</div> <div class="p-2 border">Ireland</div> <div class="p-2 border">Brazil</div> <div class="p-2 border">Russia</div> <div class="p-2 border">Morocco</div> </div><br> </div> </body> </html>
- Related Articles
- Wrap flex items in reversed order in Bootstrap
- Wrap flex items in reversed order in Bootstrap on different screens
- Bootstrap 4 .flex-wrap class
- Wrap the flex items with CSS
- Bootstrap 4 .flex-wrap-reverse class
- Bootstrap 4 .flex-*-wrap class implementation
- Avoid wrapping flex-items in Bootstrap
- Show flex items horizontally in Bootstrap
- Wrap the flex items in reverse order with CSS
- Align flex items from everywhere in Bootstrap
- Display flex items vertically in Bootstrap 4
- Specify whether the flex items should wrap or not with CSS
- Display flex items vertically and reversed in Bootstrap 4
- Avoid wrapping flex-items in Bootstrap on different screens
- Show flex items right aligned and horizontally in Bootstrap

Advertisements