我有一个显示div标签的循环,从数据库返回值。 我正在使用twitter bootstrap进行布局。 该页面按预期显示文本,如列表。 但是,我添加了一个启用打印的链接。 当我点击链接打印时,列表就像这样,在循环迭代处添加一个空格:
我想显示为一个列表,左边没有额外的边距。
<div class="row">
<ul class="unstyled">
<?php
foreach ($user_id3 as $userid) {
$sql = mysqli_query($con, "SELECT u.*, i.item_id, i.item_name, ui.date FROM user_items ui
INNER JOIN users u on ui.user_id = u.user_id
INNER JOIN items i on ui.item_id = i.item_id
WHERE u.user_id = '$userid'");
if(!$sql) {
echo "error sql: " . mysqli_error($con);
}
$item_ids = array();
$item_names = array();
$user_companys = array();
$user_emails = array();
$user_dates = array();
while($row = mysqli_fetch_array($sql)) {
$user_ids = $row['user_id'];
$user_id4[] = $row['user_id'];
$user_names = $row['user_name'];
$user_companys = $row['user_company'];
$user_emails = $row['user_email'];
$contactable = $row['contactable'];
$user_dates = $row['date'];
$item_ids[] = $row['item_id'];
$item_name = $row['item_name'];
$item_names[] = $item_name;
}
echo "<div class='year'><div class='day'><div class='month'><div class='span12'><li><strong>Name:</strong> " . $user_names . "</li></div><br><br>";
echo "<div class='span12'><li><strong>Company:</strong> ". $user_companys . "</li></div><br><br>";
echo "<div class='span12'><li><strong>Email:</strong> " . $user_emails . "</li></div><br><br>";
echo "<div class='span12'><li><strong>Contactable: </strong>";
if($contactable == 0) {
echo 'No';
} elseif ($contactable == 1) {
echo 'Yes';
}
echo "</li></div><br><br>";
$date = $user_dates;
echo "<div class='span12'><li><strong>Date:</strong> ";
echo date('j-n-Y', strtotime($date));
echo "</li></div><br><br>";
echo "<div class='span12'><li><strong>Items requested:</strong> ";
foreach ($item_names as $item_name) {
echo $item_name . ',';
}
echo "</li></div><br><br>";
$sql_feedback2 = mysqli_query($con, "SELECT * FROM feedback WHERE user_id = '$userid'");
if(!$sql_feedback2) {
echo "error sql_feedback2: " . mysqli_error($con);
}
$rating = array();
$recommend = array();
$comment = array();
while($row3 = mysqli_fetch_array($sql_feedback2)) {
$rating[] = $row3['rating'];
$recommend[] = $row3['recommend'];
$comment[] = $row3['comment'];
}
echo "<div class='span12'><li><strong>Rating: </strong>" . $rating[0] . "</li></div><br><br>";
echo "<div class='span12'><li><strong>Recommend: </strong>" . $recommend[0] . "</li></div><br><br>";
echo "<div class='span12'><li><strong>Comment: </strong>" . $comment[0] . "</li></div><br><br>";
提前致谢。
答案 0 :(得分:0)
是的,你可以做到。您需要将ul
重置为margin
和padding
。这将删除额外的间距。
对于实例,
<强> WORKING DEMO 强>
HTML代码:
<ul class="noLeftMargin">
<li>This is a list item</li>
<li>This is a list item</li>
<li>This is a list item</li>
<li>This is a list item</li>
<li>This is a list item</li>
<li>This is a list item</li>
</ul>
CSS代码:
ul.noLeftMargin{
margin:0px;
padding:0px;
}
.noLeftMargin li{
list-style-type:none;
}
希望这有帮助。