当前位置: 动力学知识库 > 问答 > 编程问答 >

html - I can't get a background image size to change

问题描述:

I'm very new to HTML and CSS.

I'm using a book called The Missing Manual, CSS3 and I'm stuck on changing the size of an image that I want to use as a background. To help isolate the problem, I made up simple HTML and CSS files, but I still can't get the background-size property to actually do anything. The image shows OK and I can change the repeat, but no matter what I put for background size (% or px) the size of the image never changes (bigger or smaller). I've tried also changing the image to a PNG, but still no go. The sprial.jpg image size is 292x288 px - so 'small' that I may not use it in the end.

I'm using Notepad++ to write the code and Chrome to view it.

HTML

<!DOCTYPE html>

<html lang="en">

<link href="Background.css" rel="stylesheet">

<body>

<p> Hello

</p>

</body>

</html>

CSS

body {

background-image: url(images/spiral.jpg);

background-repeat: no-repeat;

background-size; 50% 50%;

}

网友答案:

There is a typo on

backgroud-size: 50% 50%;

This should work fine.

NOTE: You should add some plugin that helps you with this kind of simples syntax error. For instance this one: Css Explorer

网友答案:

The problem is the semicolon, you write background-size; instead of background-size:.

分享给朋友:
您可能感兴趣的文章:
随机阅读: