How to display flex items horizontally in Bootstrap?

Web Development Bootstrap in Web Development 3 years ago

  1   0   0   0   0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

With Bootstrap, it’s possible to display FLEX items horizontally using the .flex-row class.

You need to use the following:

<div class="d-flex flex-row bg-secondary mb-3">

Above, we have used the contextual class “bg-secondary” for background color.

Now, we will work on an 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">   <h1>Student Name</h1>   <div class="d-flex flex-row bg-primary mb-3">     <div class="p-2 bg-danger">Sehral</div>     <div class="p-2 bg-primary">Fara</div>     <div class="p-2 bg-dark">Kelly</div>     <div class="p-2 bg-secondary">Gemma</div>     <div class="p-2 bg-warning">Jessica</div>     <div class="p-2 bg-primary">Lauren</div>   </div> </div> </body> </html>

The above aligns the flex items horizontally:


OR

To display flex items horizontally, use the flex-*-row class in Bootstrap. For difference screens, replace the * in the class name with the following:

For large screen:

flex-lg-row

For medium size screen:

flex-md-row

For SMALL screen: 

flex-sm-row

Posted on 31 May 2022, this text provides information on Web Development related to Bootstrap in Web Development. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Tuteehub forum answer Answers

Post Answer

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.