CSS 中奇怪的图片分辨率

Weird picture resolution in CSS

只想把图片做背景,在合适的地方修一下。谢谢!

编辑:

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 获取播放列表中当前视频的名称并将其写入屏幕,歌曲名称应位于图像上方 "Nightcore - Heroes"

您正在使用 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

希望对您有所帮助!

你的background-size设置为100% 100%,而body height只有52px。这意味着背景图像的高度也将仅为 52px。

将背景大小设置为:

background-size: 100%;