-1

I have looked in many places to find answers such as a few forums here, daniweb, as well as other similar websites like this that I've found on google, bing, and yahoo, and yet I still can't find an answer. Here is my problem that lies:

I am trying to code an image into the top of the screen (using Chrome if you wanted to know) and I want it to appear as it is the leftside of my banner.

Here is the code:

LeftBanner {
    width: 20px;
    height: 40px;
    background-color: #b0c4de;
    position: fixed;
    top: 5px;
    background:url('/Graphics/LeftBanner.png');
    background-attachment: fixed;
}

How do you suppose I make it show up? If, in Inspect Element, I remove the checkmark for the image, a box with those dimensions appear, so I that is out of the equation. I have tried so many things that this was the last result. Any suggestions or answers are appreciated greatly.

4

4 回答 4

2

您忘记了.(class) 或#(id) 选择器。

于 2013-04-16T04:17:15.730 回答
1

尝试这个

  .LeftBanner {
        width: 20px;
        height: 40px;
        background-color: #b0c4de;
        position: fixed;
        top: 5px;
        background-image:url('/Graphics/LeftBanner.png');
        background-attachment: fixed;
    }

http://www.w3schools.com/cssref/pr_background-image.asp

于 2013-04-16T04:18:50.847 回答
0

使用此语法,您应该删除第一个 slach。

如果 LeftBanner 是一个类。

.LeftBanner {
    width: 20px;
    height: 40px;
    background-color: #b0c4de;
    position: fixed;
    top: 5px;
    background-image:url('Graphics/LeftBanner.png');
    background-attachment: fixed;
}

或者

如果 LeftBanner 是一个 id。

#LeftBanner {
    width: 20px;
    height: 40px;
    background-color: #b0c4de;
    position: fixed;
    top: 5px;
    background-image:url('Graphics/LeftBanner.png');
    background-attachment: fixed;
}
于 2013-04-16T04:24:59.210 回答
-1

您不能仅将图像放在您知道的 CSS 中。您必须开始在 HTML 代码中识别它,为它创建一个 ID(仅当您有多张图片时),然后absolute positioning如果您真的需要,请使用 CSS。例如,我将样式放在图像标签中,但这是我所做的:

 <img src="http://www.hrtlc.org/images/amput-2.jpg"  alt="Chest X-Ray" style="position: absolute; right: 200px; top: 100px; height: 200px; width: 300px; ">
于 2013-04-16T04:17:57.107 回答