Place a div element in the center

<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>

I am struggling to center a dropdown within the user-box element in my code. Could someone kindly assist me in resolving this issue? The attached screenshot provides visual context for reference.

Screenshot

Answer №1

.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>Find Your Balance</div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What could be causing the issue with my Date and Time input not functioning correctly?

I developed a React frontend application styled with Material UI design. The issue I am facing is that after adding the Date and Time component styling to the form, it is unable to process the "name" value for posting. Specifically, the error message "Ty ...

Displaying or concealing list elements in Angular 6

I am working on a simple Angular app that displays a list of items. I want the behavior to be such that when the first item in the list is clicked, its description (card) should be displayed. And, if the second item is clicked and its description is displa ...

Deny/Stop/Authorize an HTML 5 state alteration event (onpopstate)

When the window's unload event is triggered, users can be presented with a confirmation dialog. This can be especially useful in scenarios where you have an ongoing request that needs to complete before navigating away from the page. Is it possible t ...

Efficiently Organizing Database Content: Ordering List with Dropdown Menu and Pagination

Is the title of this script clear? Essentially, I developed a PHP script to retrieve data from a database and display it. I then implemented code to use a drop-down menu for sorting that data. Everything was working fine until I attempted to add pagination ...

Transitioning into a fade out effect using CSS

I successfully created a modal using CSS and jQuery. The fade in transition works perfectly, but I'm having trouble implementing a transition for when it fades out and scales back to 1.4. The main issue is that the modal disappears too quickly. Chec ...

Issue with Datable functionality in Django when paired with Bootstrap 4

Objective: Utilizing django and bootstrap, I aim to integrate the datatable jquery plugin into my bootstrap table. Challenges: Despite my efforts, the table in my HTML remains unchanged and does not utilize the datatable plugin. Resolution Attempts: To a ...

After selecting a subitem, the side menu will automatically close

I designed a side menu that expands to reveal submenus. However, when I click on a subitem within a submenu, the entire list closes. The HTML, CSS, and JavaScript code all appear to be correct as the template is functioning properly. But as soon as I ins ...

Effortlessly move and place items across different browser windows or tabs

Created a code snippet for enabling drag and drop functionality of elements within the same window, which is working smoothly. var currentDragElement = null; var draggableElements = document.querySelectorAll('[draggable="true"]'); [].forEach ...

Ensure that the CSS data-step attribute is replaced with the use of a span element

Hi there, I'm currently working with a step bar template that you can find at the following link: http://codepen.io/mattdrose/pen/qEZBge My issue arises when dealing with the complete step, which is represented by the following code: <li class="i ...

The Material Styles fail to take effect in the angular application despite being imported accurately

Having a frustrating issue where my stylesheets are being included on the webpage but not applied correctly. Here's what's going wrong: I'm attempting to utilize Angular material, and I've followed all the instructions in the beginner& ...

The menu bar created from getJSON is not displaying the jQuery UI CSS styles as expected

I have been working on creating a jQueryUI menubar using JSON data. The JSON data is successfully being converted into valid HTML, but the menubar does not display with the desired styling. It appears as an unstyled unordered list rather than a styled menu ...

What is the process for modifying CSS in Laravel?

New to Laravel over here, currently working in Homestead. When I need to make changes to my CSS, I typically edit the app.scss file located in resources/assets/sass and then recompile the css with Mix using the command npm run dev. I'm not entirely ...

The process of redirecting a web page using htaccess and incorporating URL parameters

I have a directory where I store HTML pages. Using the PHP include function, I am adding these pages to my index.php file by referencing them with a URL parameter value. The URL parameter "xpage" corresponds to the page names stored in another folder, whil ...

Having trouble sending the selected value from a dropdown list to the server using $.ajax

I am embarking on my first project using JQuery (jquery-3.0.0.min.js) and JavaScript. My goal is to build a straightforward web form that connects to a database through a Web API. The form consists of various input text fields and two select dropdowns. ...

What is the most effective way to stop zooming when focusing on form fields on iOS or similar devices when using font sizes of 16px or lower?

It appears that many proposed solutions involve changing the text to 16px or using JavaScript to determine if the phone is an iPhone. However, altering the style may not be the most practical solution and checking for specific devices like iPhones could ...

creating a countdown timer for the carousel

While experimenting, I decided to create a basic carousel from scratch. Initially, I used onclick="function()" to cycle through the images. Later on, I attempted to replace it with onload="setInterval(function, 4000)", but it seems like something went wron ...

Issues with border removal due to overflow content in CSS and AngularJS

There seems to be a peculiar issue with overflow content in my application. When you scroll horizontally on the codepen, you'll notice that the border on the .track or perhaps the .cell divs disappears. Any assistance would be greatly appreciated. HT ...

Creating a navbar that sticks to the top of the page

I've been working on some code to create a sticky navbar that remains fixed as I scroll down, but unfortunately, it's not working. I suspect the issue might lie in the CSS, as the HTML and javascript seem fine. Interestingly, this same code has w ...

How to ensure onmouseenter and onmouseleave work properly in Chrome using HTML, JavaScript, and jQuery

<div style="position: relative; left: 50px; top: 30px; width: 300px; height: 150px; background: #222222;" onmouseenter="this.style.background='#aaaaaa'" onmouseleave="this.style.background='#222222';"></div> http://jsfiddle ...

Accessing a frame inside an iframe using jQuery once the frame has fully loaded

Looking to access an element within a frame using jQuery. Here is the structure: <iframe id="frame1"> <frameset id="frameset"> <frame id="frame2"> <div id="exampleDiv">text</div> </frame> </frameset> < ...