Background-image: no-repeat does not work, syntax is correct

Below is the syntax that I use for the background image. For some reason, he repeats on the Y . I can not useoverflow:hidden;

<style>
body{background-image:url('<?php echo $ActualPath; ?>images/backgroundimage.jpg'); background-image:no-repeat;}

</style>

I want the background image not to repeat on x and y.

+5
source share
4 answers

The syntax you should use is

background-image: url(path/images/backgroundimage.jpg);
background-repeat: no-repeat;

.. or alternatively

background: url(path/images/backgroundimage.jpg) no-repeat;

if you prefer short hand syntax .

background-imagealways just defines an image file, so in your example the second rule background-imagetries to override the first, but since "no-repeat" is not a valid image file, the browser simply ignores it.

.

+28

background , .

  • -
  • -

, , , . , .

background-image , background-repeat.

, -

background:#ffffff url('img_tree.png') no-repeat right top;

. ,

body{ background: url('<?php echo $ActualPath; ?>images/backgroundimage.jpg') no-repeat; }
+2

background-repeat:no-repeat;

+1

html :  CSS ( )

background-image:url("some picture url");
background-repeat:no repeat;

- It will provide a background image of one kind without repetition.

-2
source

All Articles