{"id":13447105,"url":"https://github.com/drublic/css-modal","last_synced_at":"2025-05-15T00:14:21.471Z","repository":{"id":5612553,"uuid":"6820011","full_name":"drublic/css-modal","owner":"drublic","description":"A modal built with pure CSS, enhanced with JavaScript","archived":false,"fork":false,"pushed_at":"2022-12-03T13:38:12.000Z","size":3504,"stargazers_count":1816,"open_issues_count":29,"forks_count":209,"subscribers_count":61,"default_branch":"master","last_synced_at":"2025-04-13T21:34:04.543Z","etag":null,"topics":["css","css-modal","plugin","sass"],"latest_commit_sha":null,"homepage":"https://drublic.github.io/css-modal","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drublic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-22T23:09:26.000Z","updated_at":"2025-03-23T21:19:07.000Z","dependencies_parsed_at":"2022-08-31T03:01:03.008Z","dependency_job_id":null,"html_url":"https://github.com/drublic/css-modal","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drublic%2Fcss-modal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drublic%2Fcss-modal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drublic%2Fcss-modal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drublic%2Fcss-modal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drublic","download_url":"https://codeload.github.com/drublic/css-modal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254035973,"owners_count":22003650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","css-modal","plugin","sass"],"created_at":"2024-07-31T05:01:08.311Z","updated_at":"2025-05-15T00:14:16.459Z","avatar_url":"https://github.com/drublic.png","language":"JavaScript","readme":"# CSS Modals [![Build Status](https://secure.travis-ci.org/drublic/css-modal.png?branch=master)](http://travis-ci.org/drublic/css-modal)\n\nModals built out of pure CSS\n\nPlease [visit the website](http://drublic.github.io/css-modal) to read more\nabout this project and refer to the [FAQ](FAQ.md) in case of a question.\n\n## What is it\n\n**Built with pure CSS:** CSS Modal is built out of pure CSS. JavaScript is only\nfor sugar. This makes them perfectly accessible.\n\n**Optimized for mobile:** The modals are designed using responsive web design\nmethods. They work on all screen sizes from a small mobile phone up to high\nresolution screens.\n\n**Use as Sass plugin:** You can use CSS Modal as [Sass](http://sass-lang.com/)\nplugin and apply it to your custom classes. No need to understand all the code.\n\n**A few other advantages:** Accessible, cross-browser, media-adaptive, small and\nfast!\n\n\n## How to use\n\nPlease be aware that modals get stacked above each other if you open one modal\nfrom within another. You can add a data-attribute `data-stackable=\"false\"` to\nthe modal in order to make it non-stackable.\n\n### Markup\n\nYou need to include the markup and content for modals in your website. This has\na positive effect on SEO. The example code:\n\n```html\n\u003csection class=\"modal--show\" id=\"modal-text\" tabindex=\"-1\"\n        role=\"dialog\" aria-labelledby=\"modal-label\" aria-hidden=\"true\"\u003e\n\n    \u003cdiv class=\"modal-inner\"\u003e\n        \u003cheader id=\"modal-label\"\u003e\u003c!-- Header --\u003e\u003c/header\u003e\n        \u003cdiv class=\"modal-content\"\u003e\u003c!-- The modals content --\u003e\u003c/div\u003e\n        \u003cfooter\u003e\u003c!-- Footer --\u003e\u003c/footer\u003e\n    \u003c/div\u003e\n\n    \u003ca href=\"#!\" class=\"modal-close\" title=\"Close this modal\" data-close=\"Close\"\n        data-dismiss=\"modal\"\u003e?\u003c/a\u003e\n\u003c/section\u003e\n```\n\nThe `id` attribute is the one which identifies the modal. You can link to this\nID from everywhere.\n\n\u003e Please note that the ID cannot include the `/` character since this one is\nneeded for identifying stacked modals.\n\nUsing header and footer is optional. Just remove the tags if you don't want them\nin a modal.\n\nYou should leave the link's href attribute that way to close the modal in order\nto prevent the page from scrolling to top when clicking on it.\n\nPlease remember to set a unique ID for the header and change the\n`aria-labelledby` attribute to the same value.\n\nYou link to a modal by simply setting the ID to a link element's `href` like this:\n\n```html\n\u003ca href=\"#modal\"\u003eModal\u003c/a\u003e\n```\n\nIf you want to decouple the modal call from the location's hash you need to add\n`data-cssmodal-nohash` to the link.\n\n### JavaScript\n\nAs stated above you don't need JavaScript to get a good experience out of CSS\nModals. But there are some issues where JavaScript helps:\n\n* IE 8 compatibility (please include jQuery if you need full compatibility).\n* Pressing escape: If you press \u003ckbd\u003eESC\u003c/kbd\u003e on your keyboard while the modal is visible\nit closes itself. This behavior cannot be achieved with CSS only.\n* Preventing background page from scrolling: If you scroll within the modal and\nyou reach the end you don't want the page in the background to scroll. To\nprevent this JavaScript pushes a CSS class selector to the body element.\n* Being accessible: To get the browser's focus to the modal and back after\nclosing.\n* Firing events: When a modal opens a custom event is fired called\n`cssmodal:show`. When the modal is hidden, an event called `cssmodal:hide` is\ntriggered.\n* To add this behavior to your website, please include the JavaScript file\nmodal.js right before the closing body-tag:\n\n```html\n\u003cscript src=\"js/modal.js\"\u003e\u003c/script\u003e\n```\n\n\n## Browser Support\n\nThis modal is designed to work on all modern browsers. Unfortunately this does\nnot include Internet Explorer 7 or lower. But we deal with IE 8 – well,… at\nleast it works.\n\nOn mobile Safari for iOS and Android 4+ it is tested pretty well, while Android\n2.3 has some problems (biggest issue\n[is scrolling](https://github.com/drublic/css-modal/issues/4)).\nIt's also working on Windows Phone 8.\n\nIn numbers:\n\n* Chrome\n* Firefox\n* Safari 6.x\n* Opera 12+\n* Internet Explorer 8 (functional, include jQuery if you want support for\n  events)\n* Internet Explorer 9+\n* iOS 6\n* Android 2.3 (functional)\n* Android 4.x\n* Windows Phone 8\n\n## Media\n\nPlease be aware that you need to stop playing videos or audio manually after\nhiding the modal. We have [a plugin](plugins/html5video.js) for this though.\n\n## Events\n\nThere is an event `cssmodal:show` fired on the modal itself after the modal is\nshown. Another event `cssmodal:hide` is fired after the modal is hidden.\n\nYou can use the events by subscribing to them as if they were click events or\nsomething. Here is an example using jQuery:\n\n```js\n$(document).on('cssmodal:show', function (event) {\n    console.log(event);\n});\n```\n\nThere events are not fired in IE8. Please be aware of that and use jQuery or\nsomething else to create custom events.\n\n\n## Plugins\n\nWe have a couple for the modal to enhance it:\n\n* Resize - Resizes modal to size of input elements\n* Gallery - A lightbox plugin (in connection with resize)\n* HTML5 Video - Load videos within the modal\n* Maximum Width - Set a custom maximum width on a per-modal basis\n\n\n## Bug reports and feature requests\n\nIf you got something that's worth including into the project please\n[open an issue](https://github.com/drublic/css-modal/issues) for further\ndiscussion.\n\nPlease see the [section on contributing](http://drublic.github.io/css-modal/#contributing)\non the website.\n\n\n## Contributors\n\nThis is a project by [Hans Christian Reinl](http://drublic.de). Thanks goes out\nto [all other contributors](https://github.com/drublic/css-modal/contributors).\n","funding_links":[],"categories":["JavaScript","Modals and Popups","Modals and Popups [🔝](#readme)","UI","模态框和弹出框","Uncategorized"],"sub_categories":["Other","其它","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrublic%2Fcss-modal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrublic%2Fcss-modal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrublic%2Fcss-modal/lists"}