CSS中奇怪的图片分辨率

时间:2015-11-19 21:18:51

标签: php jquery css image youtube

只想将图像作为背景,在适当的地方修复。三江源!

编辑:

div {
color: #13eee6;
font: 30px Roboto;
position: absolute;
bottom: 0;
left: 0;

}

PHP:

<!DOCTYPE html>
<html>
  <body>
    <!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
    <div id="player"></div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

    <script>
  // 2. This code loads the IFrame Player API code asynchronously.
  var tag = document.createElement('script');

  tag.src = "https://www.youtube.com/iframe_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  // 3. This function creates an <iframe> (and YouTube player)
  //    after the API code downloads.
  var player;
  function onYouTubeIframeAPIReady() {
    player = new YT.Player('player', {
      height: '1',
      width: '1',
      //videoId: 'M7lc1UVf-VE',
      playerVars: 
      {
        listType:'playlist',
        list: 'PLsVV8G4dmXyE2mSm3ZSz_AcNVduhw2ZwM'
      },
      events: {
        'onReady': onPlayerReady,
        'onStateChange': onPlayerStateChange,

      }
    });
  }

 // console.log(player);



  // 4. The API will call this function when the video player is ready.
  function onPlayerReady(event) {
    event.target.playVideo();

    $('.title').text(event.target.getVideoData().title);

  }

  // 5. The API calls this function when the player's state changes.
  //    The function indicates that when playing a video (state=1),
  //    the player should play for six seconds and then stop.
  var done = false;
  function onPlayerStateChange(event) {
    if (event.data == YT.PlayerState.PLAYING && !done) {
      setTimeout(stopVideo, 6000);
      done = true;
    }
    console.log(event);
     if ((event.data == -1)) {
        $('.title').text(event.target.getVideoData().title);
     }
  }     


  function stopVideo() {
    player.stopVideo();
  }
</script>

<div class="title"> </div> 
<link rel="stylesheet" type="text/css" href="style.css">

CSS:

body {
    background-image: url("http://i.imgur.com/z6fgaW8.png");
    background-color: #cccccc;
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

div {
    color: #13eee6;
    font: 30px Roboto;
}

网站:http://darklegionrp.byethost24.com/ 应该是一个图像背景,一个播放背景音乐的1,1 youtube视频播放器(不可观看)。音乐在播放列表中。 jQuery获取播放列表中当前视频的名称并将其写在屏幕上,歌曲名称应该位于图像的顶部,它表示&#34; Nightcore - Heroes&#34;

2 个答案:

答案 0 :(得分:2)

您正在使用background-size: 100% 100%;尝试将此更改为background-size: cover;,当我尝试在Chrome开发者控制台中更改它时,它会放大图片。

您的代码将变为:

body {
    background-image: url("http://i.imgur.com/z6fgaW8.png");
    background-color: #cccccc;
    background-size: cover;/* Note the change here */
    background-repeat: no-repeat;
}

div {
    color: #13eee6;
    font: 30px Roboto;
}

要获得合理的解释,请检查here

希望这有帮助!

答案 1 :(得分:2)

您的背景尺寸设置为100%100%,而身高仅为52px。这意味着背景图像高度也只有52px。

将背景大小设置为:

background-size: 100%;