是否可以减去填充
is it possible to minus padding
正如您在图片上看到的那样,我的数字向右浮动,我需要将它们放入我的 div 标签中。我试图将我的数组中的所有值都设置为 0,但数字不能再靠左了。正如您现在在代码中看到的那样,我尝试使用 -1,但这也无济于事。
有人知道我能做什么吗?
HTML:
<div id="show">
<div class="numberheader">
<p>Tal</p>
</div>
<ul class="latestnumbers" style="list-style:none;padding-top: 60px;">
<?php include('response.php');?>
</ul>
PHP:
<?php
//echo "kuagdjagd";
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//include('session.php');
// Selecting Database
include 'dbconfic.inc.php';
$pad_left_values = array(0 => 19, 1 => -25, 2 => 1, 3 => -1, 4 => 38, 5 => -1, 6 => 38, 7 => -1, 8 => 38, 9 => -1, 10 => 38, 11 => 38, 12 => -1, 13 => 33, 14 => -1, 15 => 33, 16 => -1, 17 => 33, 18 => -1, 19 => -1, 20 => 33, 21 => -1, 22 => 33, 23 => -1, 24 => 33, 25 => -1, 26 => 33, 27 => -1, 28 => 33, 29 => 33, 30 => -1, 31 => 33, 32 => -1, 33 => 33, 34 => -1, 35 => 33, 36 => -1);
$colorArr = array(0=>"#029002", 1=>"#ff2700", 2=>"#ffaf32", 3=>"#ff2700", 4=>"#ffaf32", 5=>"#ff2700", 6=>"#ffaf32", 7=>"#ff2700", 8=>"#ffaf32", 9=>"#ff2700", 10=>"#ffaf32", 11=>"#ffaf32", 12=>"#ff2700", 13=>"#ff2700", 13=>"#ffaf32", 14=>"#ff2700", 15=>"#ffaf32", 16=>"#ff2700", 17=>"#ffaf32", 18=>"#ff2700", 19=>"#ff2700", 20=>"#ffaf32", 21=>"#ff2700", 22=>"#ffaf32", 23=>"#ff2700", 24=>"#ffaf32", 25=>"#ff2700", 26=>"#ffaf32", 27=>"#ff2700", 28=>"#ffaf32", 29=>"#ffaf32", 30=>"#ff2700", 31=>"#ffaf32", 32=>"#ff2700", 33=>"#ffaf32", 34=>"#ff2700", 35=>"#ffaf32", 36=>"#ff2700");
// '?' er placeholders for variabler
$stmt = $mysqli->prepare("SELECT * FROM numbertable ORDER BY num_id DESC LIMIT 9;");
// execute prepared statement
$stmt->execute();
// gør variabler klar:
$number = null;
$n_id = null;
/* bind result variabler */
$stmt->bind_result($n_id, $number);
/* fetch values for hver row, her kun 1 row dog: */
while ($stmt->fetch()) {
$pad = ($number >= 1 && $number <= 36? $pad_left_values[$number]: $pad_left_values[0]);
$col = ($number >= 1 && $number <= 36? $colorArr[$number]: $colorArr[0]);
echo "<li><div style='padding-left: ".$pad."px; color: ".$col."'>$number</div></li>";
}
// luk statement
$stmt->close();
// luk connection
$mysqli->close();
?>
答案是:padding:60px 0 0 0
而不是 padding-top:60px
正如您在图片上看到的那样,我的数字向右浮动,我需要将它们放入我的 div 标签中。我试图将我的数组中的所有值都设置为 0,但数字不能再靠左了。正如您现在在代码中看到的那样,我尝试使用 -1,但这也无济于事。
有人知道我能做什么吗?
HTML:
<div id="show">
<div class="numberheader">
<p>Tal</p>
</div>
<ul class="latestnumbers" style="list-style:none;padding-top: 60px;">
<?php include('response.php');?>
</ul>
PHP:
<?php
//echo "kuagdjagd";
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//include('session.php');
// Selecting Database
include 'dbconfic.inc.php';
$pad_left_values = array(0 => 19, 1 => -25, 2 => 1, 3 => -1, 4 => 38, 5 => -1, 6 => 38, 7 => -1, 8 => 38, 9 => -1, 10 => 38, 11 => 38, 12 => -1, 13 => 33, 14 => -1, 15 => 33, 16 => -1, 17 => 33, 18 => -1, 19 => -1, 20 => 33, 21 => -1, 22 => 33, 23 => -1, 24 => 33, 25 => -1, 26 => 33, 27 => -1, 28 => 33, 29 => 33, 30 => -1, 31 => 33, 32 => -1, 33 => 33, 34 => -1, 35 => 33, 36 => -1);
$colorArr = array(0=>"#029002", 1=>"#ff2700", 2=>"#ffaf32", 3=>"#ff2700", 4=>"#ffaf32", 5=>"#ff2700", 6=>"#ffaf32", 7=>"#ff2700", 8=>"#ffaf32", 9=>"#ff2700", 10=>"#ffaf32", 11=>"#ffaf32", 12=>"#ff2700", 13=>"#ff2700", 13=>"#ffaf32", 14=>"#ff2700", 15=>"#ffaf32", 16=>"#ff2700", 17=>"#ffaf32", 18=>"#ff2700", 19=>"#ff2700", 20=>"#ffaf32", 21=>"#ff2700", 22=>"#ffaf32", 23=>"#ff2700", 24=>"#ffaf32", 25=>"#ff2700", 26=>"#ffaf32", 27=>"#ff2700", 28=>"#ffaf32", 29=>"#ffaf32", 30=>"#ff2700", 31=>"#ffaf32", 32=>"#ff2700", 33=>"#ffaf32", 34=>"#ff2700", 35=>"#ffaf32", 36=>"#ff2700");
// '?' er placeholders for variabler
$stmt = $mysqli->prepare("SELECT * FROM numbertable ORDER BY num_id DESC LIMIT 9;");
// execute prepared statement
$stmt->execute();
// gør variabler klar:
$number = null;
$n_id = null;
/* bind result variabler */
$stmt->bind_result($n_id, $number);
/* fetch values for hver row, her kun 1 row dog: */
while ($stmt->fetch()) {
$pad = ($number >= 1 && $number <= 36? $pad_left_values[$number]: $pad_left_values[0]);
$col = ($number >= 1 && $number <= 36? $colorArr[$number]: $colorArr[0]);
echo "<li><div style='padding-left: ".$pad."px; color: ".$col."'>$number</div></li>";
}
// luk statement
$stmt->close();
// luk connection
$mysqli->close();
?>
答案是:padding:60px 0 0 0
而不是 padding-top:60px