├── README.md ├── css ├── embedTwitchCSS.css └── style.css └── index.html /README.md: -------------------------------------------------------------------------------- 1 | ## embedTwitchCSS 2 | 3 | Embedding a twitch stream on an external site with the twitch provided code leaves a lot to be desired. This is a simple style sheet that let's you easily drop in a responsive twitch stream & chat while maintaining a proper 16:9 video ratio. In the example I've put the stream and chat next to each other and set the width to be 75% and 25% respectfully. You should adjust those percentages to your liking, the stream will maintain 16:9 regardless of it's width. I also included a default media query that hides the chat if the screen gets too small. You should adjust that trigger to your needs as well. 4 | 5 | an example is up and running here: http://jcrastelli.com/projects/embedTwitchCSS/ 6 | 7 | ## Code Example 8 | 9 | To use as is, download **embedTwitchCSS.css** and link the style sheet to your page 10 | 11 | ```html 12 | 13 | ``` 14 | 15 | then put two divs **twitchStream** and **twitchChat** inside the **twitchWrapper** on your page. 16 | 17 | ```html 18 | ... 19 | 20 |
21 |
22 | 23 |
24 |
25 | 26 |
27 |
28 | 29 | ... 30 | ``` 31 | 32 | and you should be ready to rock! 33 | 34 | I'd suggest you edit the width ratio between twitchStream and twitchChat and the media query trigger as per your needs. And if you're using another library to handle widths just drop the width property from those two elements entirely. 35 | 36 | ## Installation 37 | 38 | Either download the whole project to get the implementation example index.html file or simple just download the embedTwitchCSS.css file within the css folder 39 | 40 | ## Contributors 41 | 42 | If anyone notices anything wonky or has any suggestions I'm all ears 43 | 44 | Big thanks to http://www.mademyday.de/css-height-equals-width-with-pure-css.html for the help with the 16:9 calculations and set up. This borrows heavily from them 45 | 46 | ## License 47 | MIT License 48 | 49 | Copyright (c) 2016 Gregle 50 | 51 | Permission is hereby granted, free of charge, to any person obtaining a copy 52 | of this software and associated documentation files (the "Software"), to deal 53 | in the Software without restriction, including without limitation the rights 54 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 55 | copies of the Software, and to permit persons to whom the Software is 56 | furnished to do so, subject to the following conditions: 57 | 58 | The above copyright notice and this permission notice shall be included in all 59 | copies or substantial portions of the Software. 60 | 61 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 62 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 63 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 64 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 65 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 66 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 67 | SOFTWARE. 68 | -------------------------------------------------------------------------------- /css/embedTwitchCSS.css: -------------------------------------------------------------------------------- 1 | .twitchWrapper { 2 | position: relative; 3 | } 4 | 5 | .twitchStream { 6 | position: relative; 7 | width:75%; 8 | } 9 | 10 | .twitchStream:before{ 11 | content: ""; 12 | display: block; 13 | padding-top: 56.25%; /* 16:9 */ 14 | } 15 | 16 | .twitchChat{ 17 | position: absolute; 18 | top: 0; 19 | bottom: 0; 20 | right: 0; 21 | width: 25%; 22 | } 23 | 24 | .twitchStream iframe, .twitchChat iframe { 25 | position: absolute; 26 | top: 0; 27 | left: 0; 28 | width: 100%; 29 | height: 100%; 30 | } 31 | 32 | @media (max-width: 1024px) { 33 | .twitchStream{ 34 | width:100%; 35 | } 36 | .twitchChat{ 37 | display:none; 38 | } 39 | } -------------------------------------------------------------------------------- /css/style.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background-color: #202020; 3 | } 4 | 5 | .wrapper 6 | { 7 | position: absolute; 8 | top: 50%; 9 | left: 50%; 10 | transform: translate(-50%, -50%); 11 | width:90%; 12 | } 13 | 14 | /* This file is strictly so the demo index page doesn't look so bad. Please ignore! */ -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Example embedded stream/chat 9 | 10 | 11 | 12 |
13 |
14 |
15 | 16 |
17 |
18 | 19 |
20 |
21 |
22 | 23 | 24 | --------------------------------------------------------------------------------