Angularjs ui bootstrap: how to vertical center modal component?

Recently I am learning angularjs. I have used bootstrap before. With jquery, I can easily change the position of the modal component position to make it vertical align. Now with angularjs, it seems not very easy to do that. Here is a plunker link of ui bootstrap modal, Does anyone know how to make it vertical align?

ui bootstrap modal component


    <!doctype html>
    <html ng-app="ui.bootstrap.demo">
        <script src="//"></script>
        <script src="//"></script>
        <script src="//"></script>
        <script src="example.js"></script>
        <link href="//" rel="stylesheet">
        <div ng-controller="ModalDemoCtrl">
            <script type="text/ng-template" id="myModalContent.html">
                <div class="modal-header">
                    <h3 class="modal-title">I'm a modal!</h3>
                <div class="modal-body">
                    This is modal body
                <div class="modal-footer">
                    <button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
                    <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
            <button type="button" class="btn btn-default" ng-click="open()">Open me!</button>


    angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']);
    angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function($scope, $uibModal, $log) {

        $scope.items = ['item1', 'item2', 'item3'];

        $scope.animationsEnabled = true;

        $ = function(size) {

            var modalInstance = ${
                animation: $scope.animationsEnabled,
                templateUrl: 'myModalContent.html',
                controller: 'ModalInstanceCtrl',
                size: size,
                resolve: {
                    items: function() {
                        return $scope.items;

    angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl',   function($scope, $uibModalInstance, items) {
        $scope.ok = function() {

        $scope.cancel = function() {


If I understand your problem correctly, you can acheive the vertical center alignment just by using CSS. Add following CSS:

.modal {
  text-align: center;
  padding: 0!important;

.modal::before {
  content: '';
  display: inline-block;
  height: 100%;
  vertical-align: middle;
  margin-right: -4px;

.modal-dialog {
  display: inline-block;
  text-align: left;
  vertical-align: middle;

I have setup a Plunker forked from yours to make a demonstration.

You can find following links Helpful

  1. Bootstrap 3 modal vertical position center
  2. Codepen Emaple

Hope this helps. Cheers !!

Leave a Reply

Your email address will not be published. Required fields are marked *