[英]Why do I need to use 'localhost:8080' instead of just 'localhost' to connect to my server WAMP?
[英]How do I get my image to open in my localhost (WAMP)
我正在處理一個 index.php 文件,該文件保存在 Wamp 上的 htdocs 文件夾中的 6-php 文件夾中。 我正在嘗試制作整頁背景圖片。 我從 unsplash 下載了一張圖片並將其保存為 background.jpg 在 Wamp 上的 6-php 文件夾中。 當我試圖讓圖像顯示在http://localhost/6-php/index.php/ 中時,它沒有打開。 文字顯示,只是圖像沒有打開。 當我將它作為http://localhost/6-php/打開時,圖像顯示但是當我添加 /index.php/ 時,圖片消失了,只顯示文本。
我嘗試從不同的站點下載不同的圖像。 我試過將它保存在不同的文件夾中。
html {
background-image: url(background.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
我也只試過<img src="background.jpg">
沒有結果。
我希望“background.jpg”成為我的 index.php 文件中的整頁背景圖片。
圖像的路徑很重要。 有2個optins提及圖片的路徑
path of image htdocs/project/images/background.jpg path of css htdocs/project/css/style.css path of index.php htdocs/project/index.php
圖像的相對路徑路徑從嘗試訪問該文件的基礎文件開始
style.css
body { background-image: url('../images/background.jpg') }
index.php
<img src="../images/background.jpg">
絕對路徑
圖像的路徑從htdocs文件夾開始
style.css
body { background-image: url('/project/images/background.jpg') }
index.php
<img src="/project/images/background.jpg">
html { background-image: url(background.jpg); -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; }
<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> </body> </html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.