Has anyone been successful in overriding the style of an embedded YouTube iframe using Angular 4+ with TypeScript?
I've attempted to override a CSS class of the embed iframe, but have not had any luck.
Here is the URL to YouTube's stylesheet:
https://www.youtube.com/yts/cssbin/www-player-webp-vflFb1ac9.css
The specific class I am trying to override on my website is:
.ytp-cued-thumbnail-overlay-image{
background-size: 100%; //instead for background-size: cover;
}
I am attempting this because the thumbnail overlay image does not resize properly on mobile view.
**** Update ****: For instance:
- Visit this site:
- Scroll down to the YouTube video under Community Q&A, right click/inspect element anywhere outside of the video.
- Click on the video thumbnail by using "Pick an element from the page" tool (top left corner of dev tools).
- You will see the contents inside the iframe tag and the div with the class ".ytp-cued-thumbnail-overlay-image" with the background-size: cover; attribute.
- Select mobile view (next to Pick an element from the page) or resize the browser to make it mobile size.
- In my case, the thumbnail won't resize properly and gets cut off on both sides, with mobile view, so my solution was to change "background-size: cover to 100% !important;", but I could only do this via browser dev tools, not in the source code with CSS. Hence, the question about another approach using TypeScript.
== EDIT ==: I have created a small project for this issue, where the link tag seems to be added to the iframe, but has no effect. Also, check out the console area.
Online code link:
https://stackblitz.com/edit/angular-kvmp33?file=src%2Fapp%2Fapp.component.ts
Thank you for all the suggestions and assistance. I will share my solution if I find one, hoping it helps others facing the same issue. Thanks!
P.S.: This is my first post, apologies if anything is unclear or missing.