我有2个文件,其中包含.php,我与我的数据库进行了对比。我试图在Jackpot“RESULT”页面添加背景。但我对底部的空白(白色)空间有疑问。
这是我的result.php代码:
<html>
<head>
<title>RESULT</title>
<style type="text/css">
body {
text-align: center;
background-image:url(../images/background/background5.jpg);
background-repeat:no-repeat;
background-position:50% 50%;
color: white;
}
#true {color:green; font-style:underline}
#close {color:blue;}
#false {color:red;}
a {font-size:35; color: yellow;}
</style>
</head>
<body>
<?php
$date = new DateTime();
define('DB_NAME', 'test');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link)
{
die('Could not connect: '. mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected)
{
die('Can\'t use '.DB_NAME.': '.mysql_error());
}
$data = mysql_query("SELECT * FROM config") or die(mysql_error());
$a = mysql_real_escape_string($_POST['number1']);
$b = mysql_real_escape_string($_POST['number2']);
$c = mysql_real_escape_string($_POST['number3']);
$username = mysql_real_escape_string($_POST['user_name']);
$d = "$a$b$c";
echo 'Guessed code:'.$d.'<br>';
while($info = mysql_fetch_array( $data ))
{
if($info['jackpot_code'] == $d)
{
mysql_query("UPDATE `config` SET `jackpot_code`= ".rand(000,999)." WHERE `id`=1");
echo '<a href="././jackpot.php"><img src="../images/img/jackpot1.gif" height="100px" width="200"/><br><div id="true">CORRECT!</div></a>';
}
else if( $d + 30 > $info['jackpot_code'] && $info['jackpot_code'] > $d - 30){
echo '<a href="././jackpot.php">Try again!</a><br>';
die('<div id="close">The code u guessed is at the range of +/- 30 to jackpot.</div>');
} else
{
echo '<a href="././jackpot.php">Try again!</a><br>';
die('<div id="false">CODE FALSE!</div>');
}
}
$sql = "INSERT INTO jackpot_log (username, code, time) VALUES ('".$username."','".$d."','".$date->getTimestamp()."')";
if (!mysql_query($sql))
{
die('Error: '. mysqli_error($con));
}
?>
</body>
页面的图片result.php:RESULT PAGE IMAGE
如果您需要:jackpotpage.php
<html>
<head>
<title>RESULT</title>
<style type="text/css">
body {
text-align: center;
background-image:url(../images/background/background5.jpg);
background-repeat:no-repeat;
background-position:50% 50%;
color: white;
}
img {
margin-top:25px;
}
</style>
</head>
<body>
<form action="result.php" method="POST"/>
<img src="../images/img/jackpot2.jpg" height="150px" width="300"/><br></br>
<h1>Name:</h1>
<input type="text" name="user_name">
<br><br>
<table cellpadding="5px"cellspacing="5px">
<tr>
<select name="number1">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
</tr>
<tr>
<select name="number2">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
</tr>
<tr>
<select name="number3">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
</tr>
</table><br>
<input type="submit" value="TRY!">
</form>
</body>
答案 0 :(得分:0)
在你的result.php中尝试改变这个:
background-repeat:no-repeat;
为:
background-repeat:repeat-y;
答案 1 :(得分:0)
试试这个
html {
background: url(cm3v.jpg) no-repeat center center fixed; //replace cm3v.jpg with your image path
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
适用于:
Safari 3+ Chrome无论如何+ IE 9+ Opera 10+(Opera 9.5支持背景大小但不支持关键字) Firefox 3.6+(Firefox 4支持非供应商前缀版本)
来源:http://css-tricks.com/perfect-full-page-background-image/