[英]Issue with HTML image not loading
我是HTML的新手。 我正在嘗試在網頁背景中加載圖片。 路徑似乎有問題。 有人可以建議我哪里出問題了嗎?
<!DOCTYPE html>
<html>
<head>
<title>Login & Registration Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body background="../IMG_2609.jpg">
<div style="font-family:verdana;padding:20px;border-radius:20px;border:20px solid #0000FF;">
<h1> Login Screen</h1>
<form action="Login" method = "post">
<center><strong> User Email</strong>:<input type = "text" name = "email"><br></center>
<center><strong>Password</strong>:<input type="password" name="password"><br></center>
<center><input type = "submit" value = "Login"></center>
</form>
<br>
</div>
</body>
</html>
任何幫助表示贊賞。
謝謝!!
嘗試使用背景CSS屬性 :
<body style="background: url(IMG_2609.jpg) center center no-repeat;">
始終記住url
是相對於CSS文件的,但是在您的情況下,因為它是內聯的,所以它將是您實際的HTML文件。
<!DOCTYPE html>
<html>
<head>
<title>Login & Registration Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body style="background: url('http://www.google.com/images/srpr/logo11w.png') center center no-repeat;">
<div style="font-family:verdana;padding:20px;border-radius:20px;border:20px solid #0000FF;">
<h1> Login Screen</h1>
<form action="Login" method = "post">
<center><strong> User Email</strong>:<input type = "text" name = "email"><br></center>
<center><strong>Password</strong>:<input type="password" name="password"><br></center>
<center><input type = "submit" value = "Login"></center>
</form>
<br>
</div>
</body>
</html>
HTML5
不支持<body>
background
屬性(從doctype
聲明中可以明顯看出)。 改用CSS。
CSS語法: <body style="background-image:url('IMG_2609.jpg')">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.