DIV 标签内的图像上的超链接显示问题
我正在尝试在图像上显示文本(超链接);我编写了以下代码片段,但它们没有执行我想要执行的操作(在 .css 文件中)。
#menu-bar
{
padding: 10px 0px auto 0px;
height:auto;
width: 1000px;
float:left;
margin: 10px 0px auto 0px;
background:url(/images/bar_full_3_1.jpg) repeat-x;
}
HTML:
<div id ="menu-bar">
file | open | edit | ...
</div>
此代码仅在 IDE 中显示图像,但不在浏览器中显示。 谢谢!!
现在这个问题已经解决了:我犯的错误如下: ->语法不正确 - 在为属性赋予值时使用了逗号。 ->路径/网址不正确
I'm trying to display text(hyperlinks) over an image; I have written the following code snippets that doesn't do what I want to do (in the .css file).
#menu-bar
{
padding: 10px 0px auto 0px;
height:auto;
width: 1000px;
float:left;
margin: 10px 0px auto 0px;
background:url(/images/bar_full_3_1.jpg) repeat-x;
}
HTML:
<div id ="menu-bar">
file | open | edit | ...
</div>
this code display IMAGE in IDE ONLY but doesn't display it in BROWSER.
Thanks!!
NOW THIS PROBLEM HAS SOLVED: THE MISTAKE I MADE ARE AS FOLLOWS:
-> Incorrect syntax- used commas while giving values to attribute.
-> incorrect path/url
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的 CSS 文件位于“styles”之类的文件夹中,那么您需要在背景图像 url 中跳出该文件夹:(
注意 images 文件夹之前的 ../)。
这是图像不显示的最常见原因。
更新
还值得注意的是,正如此处的评论所指出的,您的 CSS 代码中存在一些错误。首先,您不需要使用逗号来分隔属性值。只需要一个空格即可。
还要确保属性值的顺序正确。
If your CSS file is in a folder like "styles" then you'll need to jump out of that folder in your background image url:
(notice the ../ before the images folder).
This is the most common cause of images not displaying.
UPDATE
It's also worth noting, as pointed out in the comments here, that you've got a couple of mistakes in your CSS code. Firstly you needn't use a comma to seperate property values. A single space is all that's required.
Also make sure you get the order of your property values correct.