# Modal width as percentage

**URL:** <https://community.hubspot.com/t/modal-width-as-percentage/3902>\
**Category:** CMS Development\
**Created:** [November 14, 2017, 9:48pm UTC](https://community.hubspot.com/t/modal-width-as-percentage/3902 "2017-11-14T21:48:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattgen180](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mattgen180/32/102437_2.png) [@mattgen180](https://community.hubspot.com/u/mattgen180)\
**Post date:** [November 14, 2017, 9:48pm UTC](https://community.hubspot.com/t/modal-width-as-percentage/3902/1 "2017-11-14T21:48:58Z")

</div>

I’m attempting to add a modal to one of our pages using this walkthrough:

> **[How To Implement A Modal On Your CMS Site Pages](https://designers.hubspot.com/blog/how-to-implement-a-modal-on-your-cms-site-pages)**
>
> In this post we’ll look at a way to showcase a form only when visitors take a proactive action, like clicking a button or link.

I’m doing it on this page (only the first case study has the modal applied to it right now):

[https://go.generation180.org/solar-schools-0?hs\_preview=VcVsbjgx-5432422612](https://go.generation180.org/solar-schools-0?hs_preview=VcVsbjgx-5432422612)

Everything is working with just a couple of exceptions. I’d like to have this modal be more responsive. Since it is a fixed width, I’m getting some issues. I’ve tried using percentages for the width but for some reason, the modal doesn’t stay centered.

Any help would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![TRooInbound](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/trooinbound/32/89545_2.png) [@TRooInbound](https://community.hubspot.com/u/TRooInbound)\
**Post date:** [November 15, 2017, 5:37am UTC](https://community.hubspot.com/t/modal-width-as-percentage/3902/2 "2017-11-15T05:37:25Z")

</div>

Hi @mattgen180,

We prefer to use Magnific Popup due to:  
1) Responsive lightbox  
2) Light and modular  
3) Content is resized with CSS

Below is the step to integrate Magnific Popup in your page.

```auto
<script src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js"></script>
<link rel="stylesheet prefetch" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css">

<script>
$(document).ready(function(){
 $('.OpenModal').magnificPopup({
 type:'inline'
 });
});
</script>

```

Below is the anchor link in which you need to open popup

`<a href="#myModal" class="OpenModal"> {{ your anchor content }} </a>`

below is the body for popup to open on above anchor action

```auto
<div id="myModal" class="white-popup mfp-hide">
 {{ your popup content }}
</div>

```

and here is some basic style to add to your popup.

```auto
<style>
 .white-popup {
 position: relative;
 background: #FFF;
 padding: 20px;
 width: auto;
 max-width: 500px;
 margin: 20px auto;
 }
</style>

```

**Note** : Please visit [Magnific Popup Plugin](http://dimsemenov.com/plugins/magnific-popup/) for more information.

Let us know if you have any concern about this solution.

Team TRooInbound!

---

<div class="post-metadata">

**Author:** ![mattgen180](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mattgen180/32/102437_2.png) [@mattgen180](https://community.hubspot.com/u/mattgen180)\
**Post date:** [November 15, 2017, 6:54pm UTC](https://community.hubspot.com/t/modal-width-as-percentage/3902/3 "2017-11-15T18:54:21Z")

</div>

Great! Thanks for this!

Any quick tips on how to make multiple of these on one page? Would I need to edit, the JS, HTML, and CSS?

---

<div class="post-metadata">

**Author:** ![TRooInbound](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/trooinbound/32/89545_2.png) [@TRooInbound](https://community.hubspot.com/u/TRooInbound)\
**Post date:** [November 16, 2017, 5:26am UTC](https://community.hubspot.com/t/modal-width-as-percentage/3902/4 "2017-11-16T05:26:42Z")

</div>

Hi @mattgen180,

It’s easy to implement multiple popup in one page you just need to change in HTML.

**Eg**. If I had For 2 Popups in my page then Popup 1 below code is needed

```auto
<a href="#myModal1" class="OpenModal"> {{ your anchor content }} </a>

<div id="myModal1" class="white-popup mfp-hide">
 {{ your popup content }}
</div>

```

For Popup 2 below code is needed

```auto
<a href="#myModal2" class="OpenModal"> {{ your anchor content }} </a>

<div id="myModal2" class="white-popup mfp-hide">
 {{ your popup content }}
</div>

```

Make Sure that the **href** of anchor tag and **id** of content wrapper tag both have same value. i.e. for above example it is **myModal1** and **myModal2** respectively.

**NOTE:** In case if you use this plugin you may encounter css/js conflict due to references available for both plugin, so we suggest you to remove existing plugin (reveal.js) references.

We **hope** it helps you.

Team TRooInbound!
