Aligning a bootstrap modal to the side of the page

Hi,

I have a regular css bootstrap Modal looking like this:

 <!-- modal default -->
                <div id="myModal2" aria-hidden="true" aria-labelledby="myModalLabel" class="modal fade" role="dialog" tabindex="-1">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button aria-label="Close" class="close" data-dismiss="modal" type="button"><span aria-hidden="true">&times;</span></button>
                                <h4 id="myModalLabel" class="modal-title">Modal title</h4>
                            </div>
                            <div class="modal-body">
                                <p>Aliquam erat volutpat. Proin lacus erat, aliquam id efficitur sit amet, mattis vel urna. Pellentesque malesuada turpis vitae vestibulum facilisis. Aliquam vehicula felis vel justo consectetur, quis volutpat tellus consequat. Aliquam tellus lacus, eleifend at leo vitae, imperdiet cursus ex. Sed sodales augue euismod felis auctor auctor. Suspendisse sodales fermentum dolor sed mattis. Ut ipsum nunc, volutpat non velit a, tristique tempor mauris. Duis ac finibus lectus. Cras blandit eros ac diam luctus mattis. Nam dignissim mattis blandit. Nulla facilisi. Nullam non massa ac mauris efficitur congue aliquet ut orci.</p>
                                <p>Maecenas volutpat, massa rhoncus eleifend sagittis, sem nulla mollis ante, non porta dolor quam ullamcorper elit. Mauris accumsan nulla non risus accumsan auctor. Praesent luctus, mi id aliquet molestie, ex sem aliquet lorem, ut tempor ex urna ut orci. Aenean eget mi magna. Vestibulum quis congue nunc. Nulla faucibus felis eros, ut ultricies sapien mattis at. Aenean facilisis gravida quam vitae dignissim. Quisque ac orci vel tellus eleifend faucibus.</p>
                                <p>Suspendisse vitae tincidunt leo, eu tempus sem. Donec congue, lacus id mattis convallis, ex lectus molestie tortor, at porttitor ipsum quam sit amet tellus. Nulla facilisi. Ut ut risus mi. Donec nec sollicitudin lacus. Praesent at lorem mauris. Curabitur pulvinar nunc non auctor elementum.</p>
                            </div>
                            <div class="modal-footer">
                                <button class="btn btn-default" data-dismiss="modal" type="button">Close</button>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.modal default -->

Open in new window


Now I want to just align it to the right of the page and to the full with of the div holding it. How can I do it?

Thanks!

Peter
Peter NordbergIT ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
If you look at the example page https://getbootstrap.com/docs/4.0/components/modal/#using-the-grid (and here note that you can use the grid inside the modal to adjust your content) you will see by using your browser console that the class modal-dialog has the following.

.modal-dialog {
    position: relative; 
    width: auto;
    margin: .5rem;
    pointer-events: none;

}

Open in new window

If you change this to float to the right it should do what you want. Just make sure to place this class in your custom css and load it after bootstrap.
modal-dialog {
    /* position: relative; */
    width: auto;
    margin: .5rem;
    pointer-events: none;
    float: right;
}

Open in new window


You can also change the size of the modal as well https://getbootstrap.com/docs/4.0/components/modal/#optional-sizes
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Peter NordbergIT ManagerAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.