简体   繁体   English

无法在此小提琴中显示背景图像

[英]Can't get background-image to show in this fiddle

I'm trying to practice my jquery and javascript. 我正在尝试练习我的jquery和javascript。 I was working on a fiddle that rotates remarks as the user clicks the arrow.png. 我正在研究一种提琴,当用户单击arrow.png时,该提琴会旋转备注。 But for some reason it's not showing and i can't test my code lol... I was going to add css animations to it as well to have it rotate rather than using javascript. 但是由于某种原因,它没有显示,并且我无法测试我的代码。。。我还要向其中添加css动画,以使其旋转而不是使用javascript。 Here is the fiddle http://jsfiddle.net/wrkmH/6/ . 这是小提琴http://jsfiddle.net/wrkmH/6/ What's wrong with my css that it isn't showing? 没有显示我的CSS有什么问题? I know this is a very noob question, sorry i just can't figure it out. 我知道这是一个非常白痴的问题,对不起,我只是想不通。 The html: 的HTML:

<p>I'm a <span id="remark">nice guy </span>.
   <a href="#" id="spinner" class ="anim"></a>
</p>

The css: CSS:

#spinner {
   height: 30px;
   background-image:url('http://i.imgur.com/bfhwPv9.png');
   background-repeat:no-repeat;
   display: inline-block;    
}

The image you're loading " http://i.imgur.com/bfhwPv9.png " is 200px x 200px. 您正在加载的图片“ http://i.imgur.com/bfhwPv9.png ”为200px x 200px。 You're currently setting the height to only 30px. 您当前将高度设置为仅30px。 If you set #spinner to the image dimension: 如果将#spinner设置为图像尺寸:

#spinner {
    height: 200px;
    width: 200px;
    background-image:url('http://i.imgur.com/bfhwPv9.png');
    background-repeat:no-repeat;
    display: inline-block;    
}

You'll be able to see the spinner: demo fiddle 您将能够看到微调器: 演示小提琴

try this 尝试这个

#spinner {
    height: 200px;
    background-image:url('http://i.imgur.com/bfhwPv9.png');
    background-repeat:no-repeat;
    display: block;    
}

Just replace your css with the following one, 只需将您的CSS替换为以下代码,

#spinner {
    height: 200px;
    width:  200px;
    background-image:url('http://i.imgur.com/bfhwPv9.png');
    background-repeat:no-repeat;
    display: inline-block;    
}

This would solve your problem. 这样可以解决您的问题。 keep coding :) 继续编码:)

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

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