Using :before and :after to apply multiple background images

HTML

<div class="mydiv">
  <p>Nguyen Manh Cuong</p>
</div>

CSS

.mydiv {
    position: relative; /* this is needed that the pseudo elements position according to the dimensions of .mydiv instead of body */
    height: 70px;
    background: #efefef;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
}
.mydiv p {
   font-size: 20px; 
 }

.mydiv:before,
.mydiv:after {
    content: ''; /* you have to define that to make the pseudo elements work */
    position: absolute;
    top: 0;
}

.mydiv:before {
    left: 0;
    width: 50px;
    height: 100%;
    background: red;
}

.mydiv:after {
   right: 0;
    width: 50px;
    height: 100%;
    background: blue;
}