简体   繁体   English

样式-背景图片未显示

[英]Style - background-image not showing

Can someone please tell me why my background-image isn't showing up? 有人可以告诉我为什么我的背景图片没有显示吗? This is my style.css layout? 这是我的style.css布局吗? I've tried numerous codes but for some reason the image just won't show up. 我已经尝试了许多代码,但是由于某种原因,图像不会显示。 Please help me, it's for a project. 请帮助我,这是一个项目。

<style>

.body {
  background-image: url('http://i58.tinypic.com/2ngegih.png'); 
  background-repeat: repeat-y;
  background-position: left top;
  font-family: arial;
  font-size: 10pt;
}


#heading {
  text-align: center;

}

#left {
  float: left;
  padding: 0px 10px 0px 0px;
  width: 200px;
}

#middle {
  top: 10px;
  margin-left: 100px;
  margin-right: 700px;
  width: 810px;



}

#right {
  float: right;
  padding: 0px 10px 0px 10px;
  width: 90px;
}
 <style>

This is my header page: 这是我的标题页:

<div id="heading">
<div class="heading">

<title>MediaBuzz</title>
<center><img src="http://i59.tinypic.com/vdjsqx.jpg">
</center>
</div></div>

This is the index page. 这是索引页面。 All these pages are all I've got since I just started. 所有这些页面都是我刚开始就拥有的所有页面。

<?php
include('header.php');
?>

<div id="left">
<div class="left">
this is the left column
</div></div>


<div id="middle">
<div class="middle">

this is the middle column 
</div></div>

</style>
</div>
  • You don't need a period for selecting the body element. 您无需花费时间来选择body元素。 Not sure if you're using body as a class name. 不知道您是否使用body作为类名。 Please post the rest of the HTML page. 请发布HTML页面的其余部分。
  • That url points to an HTML page but not the raw image itself. 该URL指向HTML页面,但不指向原始图像本身。 Try using http://oi58.tinypic.com/2ngegih.jpg 尝试使用http://oi58.tinypic.com/2ngegih.jpg

Edit: 编辑:

That is invalid HTML. 那是无效的HTML。

The body element or class does not exist, and so your CSS declaration will not be applied. body元素或类不存在,因此不会应用您的CSS声明。 You need to learn the basic structure of an HTML page. 您需要学习HTML页面的基本结构。 Make use of the W3C Validator: http://validator.w3.org/ 利用W3C验证程序: http : //validator.w3.org/

You also need a PHP server running to interpret the PHP code in there. 您还需要运行一个PHP服务器来解释其中的PHP代码。

The following code should answer your question: 以下代码可以回答您的问题:

<!DOCTYPE html>
<html>
<head>
<title>MediaBuzz</title>
<style>
    html {
        height: 100%;
        width: 100%;
    }
body  {
    height: 100%;
    width: 100%;
    background-image: url("http://oi58.tinypic.com/2ngegih.jpg");
}
</style>
</head>
<body>

<!-- the rest of the HTML goes in here -->

</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM