Kaushal Patel
Kaushal Patel

Reputation: 29

Center a div element

<div class="user-box text-center">
                        <img src="assets/images/users/user-1.jpg" alt="user-img" title="Mat Helme" class="rounded-circle img-thumbnail avatar-md">
                        <div class="dropdown">
                            <span class="user-name h5 mt-2 mb-1 d-block">Nowak Helme</span>
                        </div>
                        <p class="text-muted">Admin Head</p>
                        <ul class="list-inline">
                            <li class="list-inline-item">
                                <div class="dropdown">
                                    <a href="#" class="text-muted dropdown-toggle h5 mt-2 mb-1 d-block" data-toggle="dropdown"  aria-expanded="false">
                                        <i class="fas fa-cog"></i>
                                    </a>
                                    <div class="dropdown-menu user-pro-dropdown">

                                        <!-- item-->
                                        <a href="javascript:void(0);" class="dropdown-item notify-item">
                                            <i class="fe-user mr-1"></i>
                                            <span>My Account</span>
                                        </a>

                                        <!-- item-->
                                        <a href="javascript:void(0);" class="dropdown-item notify-item">
                                            <i class="fe-settings mr-1"></i>
                                            <span>Settings</span>
                                        </a>

                                        <!-- item-->
                                        <a href="javascript:void(0);" class="dropdown-item notify-item">
                                            <i class="fe-lock mr-1"></i>
                                            <span>Lock Screen</span>
                                        </a>

                                        <!-- item-->
                                        <a href="javascript:void(0);" class="dropdown-item notify-item">
                                            <i class="fe-log-out mr-1"></i>
                                            <span>Logout</span>
                                        </a>

                                    </div>
                                </div>
                            </li>

                            <li class="list-inline-item">
                                <a href="#">
                                    <i class="fas fa-power-off"></i>
                                </a>
                            </li>
                        </ul>
                    </div>

Above is my code. I want to center a dropdown in user-box element. Please help me fix my issue. I have attached a screenshot for your reference. I have read some of the references online but couldn't find sutiable for the solution.

Screenshot

Upvotes: 1

Views: 107

Answers (1)

anthumchris
anthumchris

Reputation: 9090

.a { font-size: 50px; line-height: 1em; }
div { outline: 2px dotted #aaa; }

.wrapper {
  background: #eee;
  width: 15em;
  height: 10em;
  margin: 0 auto;
  
  /* center */
  display: flex;
  align-items: center;
  justify-content: center;
}
<div class="wrapper">
  <div class="a">🧘🏽‍♀️</div>
  <div>Center Thyself</div>
</div>

Upvotes: 3

Related Questions