Bootstrap 4 .d-*-flex class

Use the .d-*-flex class in Bootstrap to set a flexbox container on a screen size as shown below −

<div class="d-flex bg-primary">d-flex</div>
<span class="d-sm-flex bg-warning">d-sm-flex</span>
<span class="d-md-flex bg-info">d-md-flex</span>
<span class="d-lg-flex bg-success">d-lg-flex</span>

Above the flex is set for different screen sizes, for example,

d-sm-flex = Flex for Small Screen Size
d-md-flex = Flex for Medium Screen Size
d-lg-flex = Flex for Large Screen Size
d-xl-flex = Flex for Extra Large Screen Size

Let us see an example of the class −


Live Demo

<!DOCTYPE html>
<html lang="en">
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="">
    <script src=""></script>
    <script src=""></script>


<div class="container mt-3">
  <h2>Understanding Flex</h2>
  <div class="d-flex bg-primary">d-flex</div>
  <span class="d-sm-flex bg-warning">Small Screen Size</span>
  <span class="d-md-flex bg-info"> Medium Screen Size </span>
  <span class="d-lg-flex bg-success"> Large Screen Size </span>
  <span class="d-xl-flex bg-danger"> Extra Large Screen Size </span>