├── .gitignore ├── LICENSE ├── README.md ├── bower.json ├── css ├── modal.css └── styles.css └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 C. T. Lin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pure CSS modal 2 | CSS modal. No javascript. 3 | 4 | 5 | ## DEMO 6 | See the demo: http://jorgechavz.github.io/pure-css-modal/ 7 | 8 | 9 | ## Installation 10 | Via bower 11 | ``` 12 | bower install pure-css-modal 13 | ``` 14 | 15 | Add the CSS file to your project 16 | ```html 17 | 18 | ``` 19 | 20 | Add this basic HTML to your site. 21 | ```html 22 | 35 | ``` 36 | 37 | Use a label as a trigger 38 | ```html 39 | 40 | ``` 41 | 42 | 43 | ## Customize 44 | Add entrance direction to the modal by adding any of this classes to the `modal-wrap` div 45 | 46 | | Class | 47 | | ------------- | 48 | | from-top | 49 | | from-bottom | 50 | | from-left | 51 | | from-right | 52 | 53 | You can center the modal in the middle of the screen by adding the class `a-center` to the `modal-wrap` 54 | 55 | | Class | 56 | |----------| 57 | | a-center | 58 | 59 | 60 | For example: 61 | 62 | ```html 63 | 74 | 75 | ``` 76 | 77 | You also can config the size of the modal by adding one of this classes 78 | 79 | | Class | 80 | | ------------- | 81 | | small | 82 | | full | 83 | 84 | For example: 85 | 86 | ```html 87 | 98 | 99 | ``` 100 | 101 | 102 | 103 | ### Modal in a 'CLOSE' state 104 | 105 | 106 | ### Modal in a 'OPEN' state 107 | 108 | 109 | 110 | ### Author 111 | Jorge Chavez https://github.com/jorgechavz 112 | 113 | ## Licence 114 | The MIT License (MIT) 115 | 116 | See [LICENCE](https://github.com/jorgechavz/pure-css-modal/blob/master/LICENSE) for details. 117 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pure-css-modal", 3 | "version": "0.0.1", 4 | "homepage": "http://jorgechavz.github.io/pure-css-modal/", 5 | "authors": [ 6 | "Jorge Chavez " 7 | ], 8 | "description": "Modal box that works without JavaScript", 9 | "main": "css/modal.css", 10 | "moduleType": [ 11 | "node" 12 | ], 13 | "keywords": [ 14 | "css", 15 | "modal", 16 | "box", 17 | "no", 18 | "javascript" 19 | ], 20 | "license": "MIT", 21 | "ignore": [ 22 | "**/.*", 23 | "node_modules", 24 | "bower_components", 25 | "test", 26 | "tests" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /css/modal.css: -------------------------------------------------------------------------------- 1 | /* 2 | Pure CSS modal box 3 | Author: Jorge Chavez 4 | Github: http://github.com/jorgechavz 5 | */ 6 | 7 | 8 | .pure-modal .checkbox{ 9 | display: none; 10 | } 11 | 12 | /* Gray background */ 13 | .pure-modal .pure-modal-overlay{ 14 | opacity: 0; 15 | transition: all 0.3s ease; 16 | width: 50%; 17 | position: absolute; 18 | width: 100%; 19 | height: 100%; 20 | position: fixed; 21 | top: 0; 22 | left: 0; 23 | z-index: -100; 24 | transform: scale(1); 25 | display: none; 26 | background-color: rgba(0,0,0,0.5); 27 | } 28 | 29 | /* Box */ 30 | .pure-modal .pure-modal-wrap{ 31 | background: #fdfbfb; 32 | border-radius: 0.2em; 33 | box-shadow: 5px 5px 5px rgba(0,0,0,0.2); 34 | letter-spacing: 0.05em; 35 | line-height: 1.6; 36 | padding: 40px 65px; 37 | width: 60%; 38 | margin: 20px auto; 39 | align-self: flex-start; 40 | transition: all 0.5s ease; 41 | } 42 | .pure-modal .pure-modal-wrap.small{ 43 | width: 30%; 44 | } 45 | .pure-modal .pure-modal-wrap.full{ 46 | width: 100%; 47 | height: 100%; 48 | } 49 | 50 | .pure-modal .pure-modal-wrap.a-center { 51 | align-self: center; 52 | } 53 | .pure-modal .pure-modal-wrap.from-left { 54 | transform: translateX(-100%); 55 | } 56 | .pure-modal .pure-modal-wrap.from-right { 57 | transform: translateX(100%); 58 | } 59 | .pure-modal .pure-modal-wrap.from-top { 60 | transform: translateY(-100%); 61 | } 62 | .pure-modal .pure-modal-wrap.from-bottom { 63 | transform: translateY(100%); 64 | } 65 | 66 | 67 | /* Close button */ 68 | .pure-modal .pure-modal-overlay .close{ 69 | display: flex; 70 | flex-direction: column; 71 | align-content: center; 72 | background: #282c34; 73 | border-radius: 50%; 74 | justify-content: center; 75 | position: absolute; 76 | right: -10px; 77 | top: -10px; 78 | font-size: 15px; 79 | width: 30px; 80 | height: 30px; 81 | color: #d1d1d1; 82 | } 83 | 84 | .pure-modal .pure-modal-overlay .close:hover{ 85 | cursor: pointer; 86 | background-color: #d1d1d1; 87 | color: #4b5361; 88 | transition: all 0.3s ease; 89 | } 90 | 91 | 92 | .pure-modal .o-close { 93 | width: 100%; 94 | height: 100%; 95 | position: fixed; 96 | left: 0; 97 | top: 0; 98 | z-index: -100; 99 | } 100 | 101 | .pure-modal input:checked ~ .o-close { 102 | z-index: 9998; 103 | } 104 | .pure-modal input:checked ~ .pure-modal-overlay{ 105 | transform: scale(1); 106 | opacity:1; 107 | z-index: 9997; 108 | overflow: auto; 109 | display: flex; 110 | animation-duration: 0.5s; 111 | animation-name: fade-in; 112 | -moz-animation-duration: 0.5s; 113 | -moz-animation-name: fade-in; 114 | -webkit-animation-duration: 0.5s; 115 | -webkit-animation-name: fade-in; 116 | } 117 | .pure-modal input:checked ~ .pure-modal-overlay .pure-modal-wrap { 118 | transform: translateY(0); 119 | z-index: 9999; 120 | } 121 | 122 | /* Responsive Design */ 123 | /* Tablet size */ 124 | @media (max-width: 800px){ 125 | .pure-modal .pure-modal-wrap { 126 | width: 80%; 127 | padding: 20px; 128 | } 129 | } 130 | 131 | /* Phone size */ 132 | @media (max-width: 500px){ 133 | .pure-modal .pure-modal-wrap { 134 | width: 90%; 135 | } 136 | } 137 | 138 | /* Fadein from display:none */ 139 | @keyframes fade-in { 140 | 0% { 141 | display: none; 142 | opacity: 0; 143 | } 144 | 1% { 145 | display: flex; 146 | opacity: 0; 147 | } 148 | 100% { 149 | display: flex; 150 | opacity: 1; 151 | } 152 | } 153 | 154 | @-moz-keyframes fade-in { 155 | 0% { 156 | display: none; 157 | opacity: 0; 158 | } 159 | 1% { 160 | display: flex; 161 | opacity: 0; 162 | } 163 | 100% { 164 | display: flex; 165 | opacity: 1; 166 | } 167 | } 168 | 169 | @-webkit-keyframes fade-in { 170 | 0% { 171 | display: none; 172 | opacity: 0; 173 | } 174 | 1% { 175 | display: flex; 176 | opacity: 0; 177 | } 178 | 100% { 179 | display: flex; 180 | opacity: 1; 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /css/styles.css: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Jorge Chavez 3 | Licence: MIT 4 | */ 5 | body{ 6 | font-family: 'Helvetica'; 7 | background-color: #f9f9f9; 8 | } 9 | *{ 10 | box-sizing: border-box; 11 | } 12 | .wrap{ 13 | width: 80%; 14 | margin: 0px auto; 15 | text-align: center; 16 | } 17 | .wrap h1{ 18 | font-size: 70px; 19 | } 20 | .wrap h1 span{ 21 | color: #F42A54; 22 | } 23 | .contribute { 24 | position: fixed; 25 | right: -20px; 26 | top: 20px; 27 | width: 16em; 28 | height: 10em; 29 | overflow: hidden; 30 | transform: rotate(45deg); 31 | } 32 | .contribute p { 33 | padding: 3px; 34 | background-color: #444444; 35 | } 36 | .contribute p a { 37 | border-top: 1px dashed white; 38 | border-bottom: 1px dashed white; 39 | display: block; 40 | color: white; 41 | text-decoration: none; 42 | padding: 2px 0px; 43 | } 44 | 45 | .open-modal { 46 | background-color: #3C3C3C; 47 | border-radius: 2px; 48 | box-shadow: 2px 2px 0 #F42A54; 49 | color: white; 50 | font-size: 20px; 51 | padding: 10px; 52 | transition: all 0.2s ease; 53 | display: inline-block; 54 | margin: 10px; 55 | border-top: 1px solid transparent; 56 | min-width: 150px; 57 | } 58 | 59 | .open-modal:hover { 60 | cursor: pointer; 61 | background-color: #E7E7E7; 62 | color: #3C3C3C; 63 | border-top: 1px solid #eEeeee; 64 | box-shadow: 0.2px 0.2px 2px #F42A54; 65 | } 66 | 67 | @media (max-width: 500px){ 68 | .wrap { 69 | width: 100%; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Pure CSS modal 6 | 7 | 8 | 9 | 19 | 20 | 21 |
22 |

Pure CSS Modal

23 | 24 | 25 |
26 | 27 |
28 | 29 |
30 | 31 |

This is the modal content

32 |

33 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Similique cum sequi maxime officia provident voluptatibus aut! Non autem asperiores repellat architecto laboriosam officiis ab libero enim illo animi, error alias. 34 |

35 |
36 |
37 |
38 | 39 | 40 | 41 |
42 | 43 |
44 | 45 |
46 | 47 |

This is the modal content

48 |

49 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Similique cum sequi maxime officia provident voluptatibus aut! Non autem asperiores repellat architecto laboriosam officiis ab libero enim illo animi, error alias. 50 |

51 |
52 |
53 |
54 | 55 | 56 | 57 |
58 | 59 |
60 | 61 |
62 | 63 |

This is the modal content

64 |

65 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Similique cum sequi maxime officia provident voluptatibus aut! Non autem asperiores repellat architecto laboriosam officiis ab libero enim illo animi, error alias. 66 |

67 |
68 |
69 |
70 | 71 | 72 | 73 |
74 | 75 |
76 | 77 |
78 | 79 |

This is the modal content

80 |

81 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Similique cum sequi maxime officia provident voluptatibus aut! Non autem asperiores repellat architecto laboriosam officiis ab libero enim illo animi, error alias. 82 |

83 |
84 |
85 |
86 | 87 | 88 | 89 |
90 | 91 |
92 | 93 |
94 | 95 |

This is the modal content

96 |

97 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Similique cum sequi maxime officia provident voluptatibus aut! Non autem asperiores repellat architecto laboriosam officiis ab libero enim illo animi, error alias. 98 |

99 |
100 |
101 |
102 | 103 | 104 | 105 |
106 | 107 |
108 | 109 |
110 | 111 |

This is the modal content

112 |

113 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Similique cum sequi maxime officia provident voluptatibus aut! Non autem asperiores repellat architecto laboriosam officiis ab libero enim illo animi, error alias. 114 |

115 |
116 |
117 |
118 | 119 | 120 | 121 |
122 | 123 |
124 | 125 |
126 | 127 |

This is the modal content

128 |

129 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Similique cum sequi maxime officia provident voluptatibus aut! Non autem asperiores repellat architecto laboriosam officiis ab libero enim illo animi, error alias. 130 |

131 |
132 |
133 |
134 | 135 | 136 | 137 |
138 | 139 |
140 | 141 |
142 | 143 |

This is the modal content

144 |

145 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Similique cum sequi maxime officia provident voluptatibus aut! Non autem asperiores repellat architecto laboriosam officiis ab libero enim illo animi, error alias. 146 |

147 |
148 |
149 |
150 | 151 | 152 | 153 |
154 | 155 |
156 | 157 |
158 | 159 |

This is the modal content

160 |

161 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Similique cum sequi maxime officia provident voluptatibus aut! Non autem asperiores repellat architecto laboriosam officiis ab libero enim illo animi, error alias. 162 |

163 |
164 |
165 |
166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 |

181 | Click the button to open the modal 182 |

183 | 184 |
185 |

186 | Contribute 187 |

188 |
189 | 190 | Star 191 |
192 | 193 | 194 | 195 | 196 | --------------------------------------------------------------------------------