I am writing an Extension for the Text-Editing software called Brackets, Brackets uses Bootstrap to style the Modal and CSS. I am trying to add custom CSS to the Modal so that I can reformat, move and resize different elements on the Modal such as the Checkboxes and dropdown menus to make it look cleaner.
Everytime I attempt to add CSS to the Modal by either using tags built in or a linked CSS the Modal doesn't load correctly. The modal loads and then the whole screen gets a opaque black film over it, and the Modal bees un-useable.
So I can deduct that I am not adding the CSS correctly as the Modal corrects the behavior when I remove the CSS I added.
How do I add custom CSS styling to this Bootstrap Modal?
<div id='templates_modal' class='template modal'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>×</span></button>
<h1 class='dialog-title'>{{TITLE_H1}}</h1>
</div>
<p style='display: none; color: red; font-weight: bold;' id='templates_warning'>{{DOCTYPE_ALERT}}</p>
<p style='display: none; color: red; font-weight: bold;' id='templates_warning'>{{CONTENT_ERROR}}</p>
<p style='display: none; color: red; font-weight: bold; padding: 10px;' id='templates_error'>{{NO_FILE_OPEN_ERROR}}</p>
<div class='modal-body'>
<h4>{{LANGUAGE_SELECTION}}</h4>
<p>{{LANGUAGE_DESCRIPTION}}</p>
<select id='languages'>
<option value=''>{{SELECT_LABEL}}</option>
<option value='english'>en</option>
<option value='german'>de</option>
<option value='spanish'>es</option>
<option value='french'>fr</option>
<option value='italian'>it</option>
<option value='chinese'>zh-cn</option>
</select>
<h4>{{CHARSET_SELECTION}}</h4>
<p>{{CHARSET_DESCRIPTION}}</p>
<select id="charset">
<option value=''>{{SELECT_LABEL}}</option>
<option value='utf8'>UTF-8</option>
<option value='utf16'>UTF-16</option>
</select>
<h4>{{TITLE_H4}}</h4>
<select id="doctype">
<option value=''>{{SELECT_LABEL}}</option>
<option value='html5'>HTML5</option>
<option value='html4loose'>HTML4 Transitional</option>
<option value='html4strict'>HTML4 Strict</option>
<option value='xhtml1loose'>XHTML 1 Trasitional</option>
<option value='xhtml1strict'>XHTML 1 Strict</option>
<option value='xhtml11'>XHTML 1.1</option>
</select>
<h4>{{SECTION_TEMPLATES}}</h4>
<p>{{SECTION_TEMPLATES_DESC}}</p>
<ul class="checkbox-grid" id="libraries">
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".3.15/angular.min.js"></script>' id="angularjs" value="angularjs" /><label for="angularjs"> Angular JS | 1.3.15</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".10.1/angular-material.min.js"></script>' id="angularmaterial" value="angularmaterial" /><label for="angularmaterial"> Angular Material | 0.10.0</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".10.4/dojo/dojo.js"></script>' id="dojo" value="dojo" /><label for="dojo"> Dojo | 1.10.4</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".1.0/ext-core.js"></script>' id="extcore" value="extcore" /><label for="extcore"> Ext Core | 3.1.0</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".11.3/jquery.min.js"></script>' id="jquery111" value="jquery111" /><label for="jquery111"> jQuery | 1.11.3</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".1.4/jquery.min.js"></script>' id="jquery214" value="jquery214" /><label for="jquery214"> jQuery | 2.1.4</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".4.5/jquery.mobile.min.js"></script>' id="jquerymobile" value="jquerymobile" /><label for="jquerymobile"> jQuery Mobile | 1.4.5</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".11.4/jquery-ui.min.js"></script>' id="jqueryui" value="jqueryui" /><label for="jqueryui"> jQUery UI | 1.11.4</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".5.1/mootools-yui-pressed.js"></script>' id="mootools" value="mootools" /><label for="mootools"> MooTools | 1.5.1</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".7.2.0/prototype.js"></script>' id="prototype"value="prototype" /><label for="prototype"> Prototype | 1.7.2.0</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".9.0/scriptaculous.js"></script>' id="script_aculo_us" value="script_aculo_us" /><label for="script_aculo_us"> script.aculo.us | 1.9.0 (Requires Prototype)</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".2.0/spf.js"></script>' id="spf" value="spf" /><label for="spf"> SPF | 2.2.0</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".2/swfobject.js"></script>' id="swfobject" value="swfobject" /><label for="swfobject"> SWFObject | 2.2</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".min.js"></script>' id="threejs" value="threejs" /><label for="threejs"> three.js | r69</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src=".5.18/webfont.js"></script>' id="webfontloader" value="webfontloader" /><label for="webfontloader"> Web Font Loader | 1.5.18</label></li>
</ul>
<div class='modal-footer'>
<a id='templates_modalGenBtn generate_html_btn' href='#' class='dialog-button btn btn-danger'>{{GENERATE_BUTTON}}</a>
<a id='templates_modalBtn' href='#' class='dialog-button btn btn-danger' data-dismiss='modal'>{{CANCEL_BUTTON}}</a>
</div>
</div>
</div>
I am writing an Extension for the Text-Editing software called Brackets, Brackets uses Bootstrap to style the Modal and CSS. I am trying to add custom CSS to the Modal so that I can reformat, move and resize different elements on the Modal such as the Checkboxes and dropdown menus to make it look cleaner.
Everytime I attempt to add CSS to the Modal by either using tags built in or a linked CSS the Modal doesn't load correctly. The modal loads and then the whole screen gets a opaque black film over it, and the Modal bees un-useable.
So I can deduct that I am not adding the CSS correctly as the Modal corrects the behavior when I remove the CSS I added.
How do I add custom CSS styling to this Bootstrap Modal?
<div id='templates_modal' class='template modal'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>×</span></button>
<h1 class='dialog-title'>{{TITLE_H1}}</h1>
</div>
<p style='display: none; color: red; font-weight: bold;' id='templates_warning'>{{DOCTYPE_ALERT}}</p>
<p style='display: none; color: red; font-weight: bold;' id='templates_warning'>{{CONTENT_ERROR}}</p>
<p style='display: none; color: red; font-weight: bold; padding: 10px;' id='templates_error'>{{NO_FILE_OPEN_ERROR}}</p>
<div class='modal-body'>
<h4>{{LANGUAGE_SELECTION}}</h4>
<p>{{LANGUAGE_DESCRIPTION}}</p>
<select id='languages'>
<option value=''>{{SELECT_LABEL}}</option>
<option value='english'>en</option>
<option value='german'>de</option>
<option value='spanish'>es</option>
<option value='french'>fr</option>
<option value='italian'>it</option>
<option value='chinese'>zh-cn</option>
</select>
<h4>{{CHARSET_SELECTION}}</h4>
<p>{{CHARSET_DESCRIPTION}}</p>
<select id="charset">
<option value=''>{{SELECT_LABEL}}</option>
<option value='utf8'>UTF-8</option>
<option value='utf16'>UTF-16</option>
</select>
<h4>{{TITLE_H4}}</h4>
<select id="doctype">
<option value=''>{{SELECT_LABEL}}</option>
<option value='html5'>HTML5</option>
<option value='html4loose'>HTML4 Transitional</option>
<option value='html4strict'>HTML4 Strict</option>
<option value='xhtml1loose'>XHTML 1 Trasitional</option>
<option value='xhtml1strict'>XHTML 1 Strict</option>
<option value='xhtml11'>XHTML 1.1</option>
</select>
<h4>{{SECTION_TEMPLATES}}</h4>
<p>{{SECTION_TEMPLATES_DESC}}</p>
<ul class="checkbox-grid" id="libraries">
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/angularjs/1.3.15/angular.min.js"></script>' id="angularjs" value="angularjs" /><label for="angularjs"> Angular JS | 1.3.15</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/angular_material/0.10.1/angular-material.min.js"></script>' id="angularmaterial" value="angularmaterial" /><label for="angularmaterial"> Angular Material | 0.10.0</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>' id="dojo" value="dojo" /><label for="dojo"> Dojo | 1.10.4</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/ext-core/3.1.0/ext-core.js"></script>' id="extcore" value="extcore" /><label for="extcore"> Ext Core | 3.1.0</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/jquery/1.11.3/jquery.min.js"></script>' id="jquery111" value="jquery111" /><label for="jquery111"> jQuery | 1.11.3</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.4/jquery.min.js"></script>' id="jquery214" value="jquery214" /><label for="jquery214"> jQuery | 2.1.4</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script>' id="jquerymobile" value="jquerymobile" /><label for="jquerymobile"> jQuery Mobile | 1.4.5</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>' id="jqueryui" value="jqueryui" /><label for="jqueryui"> jQUery UI | 1.11.4</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/mootools/1.5.1/mootools-yui-pressed.js"></script>' id="mootools" value="mootools" /><label for="mootools"> MooTools | 1.5.1</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/prototype/1.7.2.0/prototype.js"></script>' id="prototype"value="prototype" /><label for="prototype"> Prototype | 1.7.2.0</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/scriptaculous/1.9.0/scriptaculous.js"></script>' id="script_aculo_us" value="script_aculo_us" /><label for="script_aculo_us"> script.aculo.us | 1.9.0 (Requires Prototype)</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/spf/2.2.0/spf.js"></script>' id="spf" value="spf" /><label for="spf"> SPF | 2.2.0</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/swfobject/2.2/swfobject.js"></script>' id="swfobject" value="swfobject" /><label for="swfobject"> SWFObject | 2.2</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/threejs/r69/three.min.js"></script>' id="threejs" value="threejs" /><label for="threejs"> three.js | r69</label></li>
<li><input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/webfont/1.5.18/webfont.js"></script>' id="webfontloader" value="webfontloader" /><label for="webfontloader"> Web Font Loader | 1.5.18</label></li>
</ul>
<div class='modal-footer'>
<a id='templates_modalGenBtn generate_html_btn' href='#' class='dialog-button btn btn-danger'>{{GENERATE_BUTTON}}</a>
<a id='templates_modalBtn' href='#' class='dialog-button btn btn-danger' data-dismiss='modal'>{{CANCEL_BUTTON}}</a>
</div>
</div>
</div>
Share
Improve this question
edited Sep 16, 2015 at 4:47
Alexis Tyler
9686 gold badges32 silver badges51 bronze badges
asked Sep 16, 2015 at 3:41
jward01jward01
7594 gold badges11 silver badges27 bronze badges
2
- 1 Adding custom classes (as your markup shows) is the correct way to do this. If your CSS is affecting how the modal renders, I suspect you're targeting the wrong portions of the modal's content. Can you trim this back to a minimal example, and add some of the CSS you've tried? – Tieson T. Commented Sep 16, 2015 at 3:48
- When I try to add a <link> from the HTML to the CSS page, the Opaque film appears. So I am having difficulty manipulating the classes. Unfortunately, the modal is built for a Brackets Extension. So if I add the CSS you cannot see it 'fail' unless if you load the extension into Brackets. – jward01 Commented Sep 16, 2015 at 4:13
2 Answers
Reset to default 4The modal loads, and then the whole screen gets a opaque black film over it, and the Modal bees un-useable.
You are missing 2 div <div class="modal-dialog">
and <div class='modal-content'>
without <div class="modal-dialog">
and <div class='modal-content'>
Fiddle
and with
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#templates_modal">Open Modal</button>
<div id='templates_modal' class='template modal'>
<div class="modal-dialog">
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>×</span>
</button>
<h1 class='dialog-title'>{{TITLE_H1}}</h1>
</div>
<p style='display: none; color: red; font-weight: bold;' id='templates_warning'>{{DOCTYPE_ALERT}}</p>
<p style='display: none; color: red; font-weight: bold;' id='templates_warning'>{{CONTENT_ERROR}}</p>
<p style='display: none; color: red; font-weight: bold; padding: 10px;' id='templates_error'>{{NO_FILE_OPEN_ERROR}}</p>
<div class='modal-body'>
<h4>{{LANGUAGE_SELECTION}}</h4>
<p>{{LANGUAGE_DESCRIPTION}}</p>
<select id='languages'>
<option value=''>{{SELECT_LABEL}}</option>
<option value='english'>en</option>
<option value='german'>de</option>
<option value='spanish'>es</option>
<option value='french'>fr</option>
<option value='italian'>it</option>
<option value='chinese'>zh-cn</option>
</select>
<h4>{{CHARSET_SELECTION}}</h4>
<p>{{CHARSET_DESCRIPTION}}</p>
<select id="charset">
<option value=''>{{SELECT_LABEL}}</option>
<option value='utf8'>UTF-8</option>
<option value='utf16'>UTF-16</option>
</select>
<h4>{{TITLE_H4}}</h4>
<select id="doctype">
<option value=''>{{SELECT_LABEL}}</option>
<option value='html5'>HTML5</option>
<option value='html4loose'>HTML4 Transitional</option>
<option value='html4strict'>HTML4 Strict</option>
<option value='xhtml1loose'>XHTML 1 Trasitional</option>
<option value='xhtml1strict'>XHTML 1 Strict</option>
<option value='xhtml11'>XHTML 1.1</option>
</select>
<h4>{{SECTION_TEMPLATES}}</h4>
<p>{{SECTION_TEMPLATES_DESC}}</p>
<ul class="checkbox-grid" id="libraries">
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/angularjs/1.3.15/angular.min.js"></script>' id="angularjs" value="angularjs" />
<label for="angularjs">Angular JS | 1.3.15</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/angular_material/0.10.1/angular-material.min.js"></script>' id="angularmaterial" value="angularmaterial" />
<label for="angularmaterial">Angular Material | 0.10.0</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>' id="dojo" value="dojo" />
<label for="dojo">Dojo | 1.10.4</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/ext-core/3.1.0/ext-core.js"></script>' id="extcore" value="extcore" />
<label for="extcore">Ext Core | 3.1.0</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/jquery/1.11.3/jquery.min.js"></script>' id="jquery111" value="jquery111" />
<label for="jquery111">jQuery | 1.11.3</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.4/jquery.min.js"></script>' id="jquery214" value="jquery214" />
<label for="jquery214">jQuery | 2.1.4</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script>' id="jquerymobile" value="jquerymobile" />
<label for="jquerymobile">jQuery Mobile | 1.4.5</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>' id="jqueryui" value="jqueryui" />
<label for="jqueryui">jQUery UI | 1.11.4</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/mootools/1.5.1/mootools-yui-pressed.js"></script>' id="mootools" value="mootools" />
<label for="mootools">MooTools | 1.5.1</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/prototype/1.7.2.0/prototype.js"></script>' id="prototype" value="prototype" />
<label for="prototype">Prototype | 1.7.2.0</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/scriptaculous/1.9.0/scriptaculous.js"></script>' id="script_aculo_us" value="script_aculo_us" />
<label for="script_aculo_us">script.aculo.us | 1.9.0 (Requires Prototype)</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/spf/2.2.0/spf.js"></script>' id="spf" value="spf" />
<label for="spf">SPF | 2.2.0</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/swfobject/2.2/swfobject.js"></script>' id="swfobject" value="swfobject" />
<label for="swfobject">SWFObject | 2.2</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/threejs/r69/three.min.js"></script>' id="threejs" value="threejs" />
<label for="threejs">three.js | r69</label>
</li>
<li>
<input type="checkbox" name="lib_checkboxes" data-script='<script src="https://ajax.googleapis./ajax/libs/webfont/1.5.18/webfont.js"></script>' id="webfontloader" value="webfontloader" />
<label for="webfontloader">Web Font Loader | 1.5.18</label>
</li>
</ul>
<div class='modal-footer'> <a id='templates_modalGenBtn generate_html_btn' href='#' class='dialog-button btn btn-danger'>{{GENERATE_BUTTON}}</a>
<a id='templates_modalBtn' href='#' class='dialog-button btn btn-danger' data-dismiss='modal'>{{CANCEL_BUTTON}}</a>
</div>
</div>
</div>
</div>
</div>
Fiddle
Use bootstrap predefined classes to style and grid system to format the form inside modal
Fiddle
And you can add custom css as like you are doing inline style <p style='display: none; color: red; font-weight: bold;' id='templates_warning'>{{DOCTYPE_ALERT}}</p>
or put custom selectors and add those in style sheet, preferable is adding custom selector because later you can adjust modal content according to screen size with media queries.
e.g
<p class="nodisplay" id='templates_warning'>{{DOCTYPE_ALERT}}</p>
and in style sheet
.nodisplay {
display: none;
color: red;
font-weight: bold;
}
Fiddle
in html file add ids like :
<div class="modal fade" style="border-radius : 20px !important;" id="createPageModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" style="border-radius : 20px !important;" role="document">
<!--here--> <div class="modal-content" id="page_modal_content">
<!--here--><div class="modal-header" id="page_modal_header">
<h5 class="modal-title" id="exampleModalLongTitle">Please enter your credentials to login.</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form class="login_form ">
<label for="user_form_name">User name</label>
<input id="user_form_name" type="text" placeholder="User name" required />
</form>
</div>
<div class="modal-footer">
<button style="border-radius : 20px; width : 45%;" type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button>
<button style="border-radius : 20px; width : 45%;" type="button" class="btn btn-success">Save changes</button>
</div>
</div>
</div>
</div>
And css should be :
#page_modal_content {
border-radius: 10px !important;
}
#page_modal_header {
border-top-right-radius: 10px !important;/* you must add important*/
border-top-left-radius: 10px !important;
}