前提・実現したいこと
・ヘッダー部分に、画面いっぱいの動画を背景として埋め込みたい。
・あわよくばこのまま自動再生されてほしい。
発生している問題・エラーメッセージ
試しに私が好きなアーティストのものを乗っけているのですが
だからダメなのでしょうか?
一般公開するものではなく、あくまで個人利用のものなのですが、
利用にあたり、ブロックされているというような感じでしょうか?
該当のソースコード
html
1<div class="video"> 2 <iframe width="560" height="315" src="https://www.youtube.com/embed/Nt6ZwuVzOS4?controls=0?autoplay=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> 3</div>
CSS
1.video { 2 margin: 0 auto; 3 position: relative; 4 width: 100%; 5 padding-top: 56.25%; 6} 7 8.video iframe { 9 position: absolute; 10 top: 0; 11 left: 0; 12 width: 100% !important; 13 height: 100% !important; 14}
初心者過ぎて言葉足らずかもしれません・・・
宜しくお願いします。
修正(2020-08-18 21:13)
html全文を貼ります!
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" /> <link rel="stylesheet" href="../portfolio/webfontkit-20200818-043127/stylesheet.css" type="text/css" charset="utf-8" /> <title>Document</title> </head> <body> <header> <div class="video"> <iframe width="560" height="315" src="https://www.youtube.com/embed/Nt6ZwuVzOS4?controls=0?autoplay=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </div> <p>LOGO</p> <div class="content"> <h1>portfolio</h1> </div> </header> <section class="introduction"> <span>こんにちは*** ****です。</span> <div class="dig"> <p>はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶</p> <p>はじめの挨拶<br> はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶</p> <p>はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶はじめの挨拶</p> </div> </section> <footer> </footer> </body> </html>
controls=0?を削除した場合動作しませんでしょうか?
削除してみました!そして、だめでした…
自動再生どころかクリックしても動画を再生できませんとなってしまいます…
自分が試した限りでは、HTMLの部分の変更は必要なさそうです。Youtbeはブロックされずに再生されました。
HTMLの他の部分に起因する問題かもしれないので、HTMLの全文を送って欲しいです。
全文を記載させていただきました!すみませんありがとうございます・・・
ごめんなさい。先ほど、普通に再生されたと書いたのは、開発者ツールを用いて埋め込んでいたからのようです。一からHTMLを書くと再生されませんでした。結論を回答に書いておきます。
回答2件
あなたの回答
tips
プレビュー