Skip to content

Commit

Permalink
Make the YouTube embed responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
danfishgold committed Jul 9, 2021
1 parent 51c50f0 commit e91cce9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion client/src/components/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default function Player({ firstPlaylistSong, onEnd }: Props) {
videoId={currentlyPlaying?.videoId}
onReady={onReady}
onEnd={onEnd}
opts={{ playerVars: { autoplay: 1 } }}
opts={{ width: '100%', height: 'auto', playerVars: { autoplay: 1 } }}
containerClassName={'youtubeContainer'}
/>
</div>
)
Expand Down
19 changes: 18 additions & 1 deletion client/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ main {
max-width: 70rem;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr auto;
grid-template-columns: 3fr 2fr;
grid-template-rows: 1fr;
gap: 2rem;
padding: var(--pad);
Expand Down Expand Up @@ -142,3 +142,20 @@ button {
background: rgb(207, 221, 221);
}
}

.youtubeContainer {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.25%;
overflow: hidden;
margin-bottom: 50px;

iframe {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
}

0 comments on commit e91cce9

Please sign in to comment.