Hack Forums
Little problem with to insert an image - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141)
+---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50)
+---- Thread: Little problem with to insert an image (/showthread.php?tid=5508332)

Pages: Pages 1 2


Little problem with to insert an image - iGameKing - Dec 29, 2016

Hi hackforums!
I face a little problem , just started when i try build my first website.
I've try to insert an image to the background of my site in the body part.

This one is on the .css file
PHP Code

<?php 
body
{
      
background-image: url("./images/a.png");
} 

This one is from the index.html file
PHP Code

<?php 
<link rel="stylesheet" type="text/css" href="./css/style.css"> 

So this is my folder situation look like this..
https://gyazo.com/da3e9d8eac848dc04bb43a797a586741

I've keep try all, check on syntax websites, if i've writing something wronge but i dont know why this basic sh*t cant work right. The background page is totaly white without my image.


* - Mr. Robot - Dec 29, 2016

Here's the image for everyone. Will take a look myself in a minute but lunch time.

[Image: da3e9d8eac848dc04bb43a797a586741.png]


* - Lucifer's Inferno - Dec 29, 2016

Code
"<link rel="stylesheet" type="text/css" href="./css/style.css">

Should it not be

Code
<link rel="stylesheet" type="text/css" href="/css/style.css">

You have the dir wrong?


* - Yuikoro - Dec 29, 2016

I'm running on two hours of sleep so forgive me if I'm being retarded but in my current state I'm 100% certain that ./ for a path means "parent, and go here".
Try getting rid of that dot.

Ah shit dud I got sniped


* - iGameKing - Dec 29, 2016

(Dec 29, 2016 05:41 PM)Lucifers Inferno Wrote:  
Code
"<link rel="stylesheet" type="text/css" href="./css/style.css">

Should it not be

Code
<link rel="stylesheet" type="text/css" href="/css/style.css">

You have the dir wrong?

Already try it too, with the dot or not but the page dont want know nothing about insert my image


* - Ancestral - Dec 29, 2016

(Dec 29, 2016 05:43 PM)iGameKing Wrote:  Already try it too, with the dot or not but the page dont want know nothing about insert my image

../images/a.png

Try that. Let me know.

.. will bring back to root.


* - Mr. Robot - Dec 29, 2016

(Dec 29, 2016 05:43 PM)iGameKing Wrote:  Already try it too, with the dot or not but the page dont want know nothing about insert my image

Can you play with the directory of the image? Just shove it all in 1 path/folder and see if it works.
Cbf checking everything


* - iGameKing - Dec 29, 2016

(Dec 29, 2016 05:44 PM)Zetrex Wrote:  ../images/a.png

Try that. Let me know.

.. will bring back to root.

I know the basic how paths work and already try it too.


* - White. - Dec 29, 2016

Your index.html should look like

PHP Code

<?php 
<link rel="stylesheet" type="text/css" href="css/style.css"> 

For the CSS use

PHP Code

<?php 
body 
{
      
background-image: url("/images/a.png");
} 



* - Ancestral - Dec 29, 2016

Code
body
{
      background-image: url('./images/a.png');
}

Try that. Might not do anything.

Also, can you post your whole CSS in a pastebin? Or upload your whole site to a free host or something so we can see what's going on.

Might be a div overlapping where your image is.


* - iGameKing - Dec 29, 2016

(Dec 29, 2016 05:44 PM)Mr. Robot Wrote:  Can you play with the directory of the image? Just shove it all in 1 path/folder and see if it works.
Cbf checking everything

Let's give a try..

The situation look like this now..

Style.css
PHP Code

<?php 
body
{
      
background-image: url("a.png");
} 

Index.html
PHP Code

<?php 
<link rel="stylesheet" type="text/css" href="style.css"> 

and the folder look like this
https://gyazo.com/fa5e328759650b3ac9baec699a281e83

And dont work..


* - Yuikoro - Dec 29, 2016

My dude
Your picture is a jpg not a png


* - White. - Dec 29, 2016

(Dec 29, 2016 05:52 PM)Sender Wrote:  My dude
Your picture is a jpg not a png

[Image: 1f44a.png?v7]

Got it!


* - Ancestral - Dec 29, 2016

(Dec 29, 2016 05:52 PM)Sender Wrote:  My dude
Your picture is a jpg not a png

Haha, problem solved.

Roll out boys.

NEXT TIME USE THE NETWORK TAB IN THE CHROME DEVELOPER TAB PLEASE.

It'll tell you whether or not an image is linked properly.


* - Lucifer's Inferno - Dec 29, 2016

(Dec 29, 2016 05:50 PM)iGameKing Wrote:  Let's give a try..

The situation look like this now..

Style.css
PHP Code

<?php 
body
{
      
background-image: url("a.png");
} 

Index.html
PHP Code

<?php 
<link rel="stylesheet" type="text/css" href="style.css"> 

and the folder look like this
https://gyazo.com/fa5e328759650b3ac9baec699a281e83

And dont work..


Your picture is JPG not a PNG.

🤝🤝🤝