Skip to content

Instantly share code, notes, and snippets.

@jonjaques
Last active December 22, 2015 04:18
Show Gist options
  • Save jonjaques/6415768 to your computer and use it in GitHub Desktop.
Save jonjaques/6415768 to your computer and use it in GitHub Desktop.
jQuery UI Dialog Reset
.ui-dialog-reset.ui-dialog {
padding: 0;
}
.ui-dialog-reset.ui-dialog .ui-dialog-titlebar,
.ui-dialog-reset.ui-dialog .ui-dialog-content,
.ui-dialog-reset.ui-dialog .ui-dialog-buttonpane,
.ui-dialog-reset.ui-dialog .ui-dialog-buttonpane button,
.ui-dialog-reset.ui-dialog .ui-button-text {
padding: 0;
margin: 0;
}
.ui-dialog-reset.ui-dialog .ui-dialog-title {
margin: 0;
width: auto;
}
.ui-dialog-reset.ui-widget input, .ui-dialog-reset.ui-widget select, .ui-dialog-reset.ui-widget textarea, .ui-dialog-reset.ui-widget button, .ui-dialog-reset.ui-widget {
font-family: inherit;
font-size: inherit;
}
.ui-dialog-reset.ui-corner-all, .ui-dialog-reset .ui-corner-all {
border-top-left-radius: 0px;
border-top-right-radius: 0px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
.ui-dialog-reset.ui-widget-content {
background: white;
border: none;
color: black;
}
.ui-dialog-reset.ui-widget-content .ui-widget-content {
border: none;
background: transparent;
color: inherit;
}
.ui-dialog-reset .ui-widget-header {
border: none;
background: transparent;
color: black;
font-weight: normal;
}
.ui-dialog-reset .ui-state-default, .ui-dialog-reset .ui-state-hover {
border: none;
background: transparent;
color: inherit;
}
.ui-dialog-reset .ui-dialog-titlebar-close {
top: 0;
right: 0;
margin: 0;
padding: 0;
width: 16px;
height: 16px;
}
@mixin ui-dialog-reset (
$dialog-bg: #fff,
$dialog-color: #000,
$dialog-border: none
) {
&.ui-dialog {
padding: 0;
.ui-dialog-titlebar,
.ui-dialog-content,
.ui-dialog-buttonpane,
.ui-dialog-buttonpane button,
.ui-button-text {
padding: 0;
margin: 0;
}
.ui-dialog-title {
margin: 0;
width: auto;
}
}
&.ui-widget {
input, select, textarea, button, & {
font-family: inherit;
font-size: inherit;
}
}
&.ui-corner-all, .ui-corner-all {
border-top-left-radius: 0px;
border-top-right-radius: 0px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
&.ui-widget-content {
background: $dialog-bg;
border: $dialog-border;
color: $dialog-color;
.ui-widget-content {
border: none;
background: transparent;
color: inherit;
}
}
.ui-widget-header {
border: none;
background: transparent;
color: $dialog-color;
font-weight: normal;
}
.ui-state-default, .ui-state-hover {
border: none;
background: transparent;
color: inherit;
}
.ui-dialog-titlebar-close {
top: 0;
right: 0;
margin: 0;
padding: 0;
width: 16px;
height: 16px;
}
}
.ui-dialog-reset {
@include ui-dialog-reset();
}
<html>
<head>
<link href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/css/base/jquery-ui.css">
<link href="dialog-reset.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script>
$(function() {
var dialog = $('#example').dialog({
position: 'center center',
title: 'Foobar',
dialogClass: 'ui-dialog-reset', // change this to whatever class you apply
// the mixin to, or just use this one.
buttons: [
{ text: 'Stuff' },
{ text: 'Things' }
]
});
});
</script>
</head>
<body>
<div id="example">
Stuff and Things
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment