4 Replies - 494 Views - Last Post: 07 February 2013 - 03:20 AM

#1 W1174503  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 07-January 13

Won’t show the background picture.

Posted 05 February 2013 - 05:44 PM

I am having trouble with my html file. As the title states my problem is the page won’t show the background picture. I know I wrote that images.jpg correctly because the other pictures are shown just fine.

<!DOCTYPE html>

<html>
<head>
<title>Title</title>
body{
	background-image:url(images.jpg);
	background-position:50%;
	<!-- background image and centered it-->
	}
</head>

<body>
<img src="images.jpg">
<!-- simple image -->
<br>

<a href="http://google.com"><img src="images.jpg"></a>
<!-- image that is a link as well -->
<br>

<img src="images.jpg" height="150"/>
<!-- resizing picture -->
</body>
</html>




Thank you,
W1174503

Is This A Good Question/Topic? 0
  • +

Replies To: Won’t show the background picture.

#2 no2pencil  Icon User is online

  • Dic Head
  • member icon

Reputation: 5165
  • View blog
  • Posts: 26,841
  • Joined: 10-May 07

Re: Won’t show the background picture.

Posted 05 February 2013 - 05:54 PM

Is image.jpg in the same directory as the html file? The path must be correct.

Also, use quotes in the css, & use script tags.

<title>Title</title>
  <script>
body{
    background-image:url('images.jpg');
    background-position:50%;
    <!-- background image and centered it-->
    }
  </script>
</head>


Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3182
  • View blog
  • Posts: 10,666
  • Joined: 12-December 12

Re: Won’t show the background picture.

Posted 05 February 2013 - 06:31 PM

<!-- background image and centered it-->

and this is an HTML comment, CSS comments /* are like this */.

This post has been edited by andrewsw: 05 February 2013 - 06:32 PM

Was This Post Helpful? 0
  • +
  • -

#4 codespook  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 141
  • Joined: 31-October 12

Re: Won’t show the background picture.

Posted 07 February 2013 - 03:03 AM

You are not linking the stylesheet like it needs to be. Try this. And no repeat should be set because otehrwise you wil have a repeating background image (unless that is what you want)


<title>Title</title>
<style type="text/css">
<!--
body{
    background-image:url('images.jpg');

	background-repeat:no-repeat;
    background-position:50%;

    }
 </style>
</head>


[/quote]

View Postno2pencil, on 05 February 2013 - 05:54 PM, said:

Is image.jpg in the same directory as the html file? The path must be correct.

Also, use quotes in the css, & use script tags.

<title>Title</title>
  <script>
body{
    background-image:url('images.jpg');
    background-position:50%;
    <!-- background image and centered it-->
    }
  </script>
</head>


Was This Post Helpful? 0
  • +
  • -

#5 raghav.naganathan  Icon User is offline

  • Perfectly Squared ;)
  • member icon

Reputation: 408
  • View blog
  • Posts: 1,440
  • Joined: 14-September 12

Re: Won’t show the background picture.

Posted 07 February 2013 - 03:20 AM

Well, on the lines of no2pencil and codespook, I thought I would combine both their codes and do something like this.

background:url('images.jpg') center no-repeat;


regards,
Raghav
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1