当你找到" hard"简单的东西和简单的东西很难!
我不确定为什么我会在看起来非常简单的html和/或css问题上寻求帮助,但我在这里。
请查看截图,了解问题的视觉效果。即使我已经通过div和html语法检查,我的电子设备似乎到处都是,这也适用于我的页脚。我认为css是正确的,但也许我在某个地方错过了一个div。我需要一双新鲜的眼睛才能看到我明显不喜欢的东西。
所以我添加了我的getItem函数()
function getItem(){
global $con;
//limit to just getting 6 random products per page
$get_item = "select * from items order by RAND() LIMIT 0,6";
$run_item = mysqli_query($con,$get_item);
//using while loop to get multiple data from items table
while($row_item = mysqli_fetch_array($run_item)){
$item_id = $row_item['item_id'];
$item_cat = $row_item['item_cat'];
$item_brand = $row_item['item_brand'];
$item_title = $row_item['item_title'];
$item_price = $row_item['item_price'];
$item_image = $row_item['item_image'];
echo "
<div id='single_item'>
<h3>$item_title</h3>
<img src='admin_area/item_imgs/$item_image'width=180' height='180'/>
";
}
}
?>
&#13;
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {background:skyblue;}
.wrapper_main{
width:1000px;
height:auto;
margin:auto;
background:black;
}
.wrapper_header{
width:1000px;
height:100px;
margin:auto;
}
#logo {float:left;}
#banner {float:right;}
.menubar {
width:1000px;
height:50px;
background:gray;
color:white;
}
#indexmenu {
padding:0;
margin:0;
line-height:40px;
float:left;
}
#indexmenu li {
list-style:none;
display:inline;
}
#indexmenu a {
text-decoration:none;
color:white;
padding:8px;
margin:5px;
font-size:18px;
font-family:COMIC SANS MS;
}
#indexmenu a:hover {color:orange; font-weight:bolder; text-decoration:underline;}
#form {float:right; padding-right:8px; line-height:50px;}
.content_wrapper {
width:1000px;
margin:auto;
background:pink;
}
#content_area {
width:800px;
float:right;
background:pink;
}
#sidebar {
width:200px;
background:black;
float:left;
}
#sidebar_title {
background:white;
color:black;
font-size:22px;
font-family:arial;
padding:10px;
text-align:center;
}
#cats {
text-align:center;
}
#cats li {list-style:none; margin:5px;}
#cats a {color:white; padding:8px; margin:5px; text-align:center; font-size:20px; text-decoration:none; font-family:Comic Sans Ms;}
#cats a:hover {color:orange; font-weight:bolder; text-decoration:underline;}
#items_box {
width:780px;
text-align:center;
margin-left:30px;
margin-bottom:10px;
}
#single_item {float:left; margin-left:30px; padding:10px;}
#single_item img {border:2px solid black;}
#shopping_cart {width:800px; height:50px; background:black; color:white;}
#footer {
width:1000px;
height:100px;
background:gray;
clear:both;
}
&#13;
<!DOCTYPE>
<?php
session_start();
include("functions/functions.php");
?>
<html>
<head>
<title>My Online Shop</title>
<link rel="stylesheet" href="styles/style.css" media="all" />
</head>
<body>
<!--Main Container starts here-->
<div class="wrapper_main">
<!--Header starts here-->
<div class="wrapper_header">
<a href="index.php"><img id="logo" src="img/logo.gif" /> </a>
<img id="banner" src="img/banner_ad.gif" />
</div>
<!--Header ends here-->
<!--Navigation Bar starts-->
<div class="menubar">
<ul id="indexmenu">
<li><a href="index.php">Home</a></li>
<li><a href="all_products.php">All Products</a></li>
<li><a href="customer/my_account.php">My Account</a></li>
<li><a href="#">Sign Up</a></li>
<li><a href="cart.php">Shopping Cart</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
<div id="form">
<form method="get" action="results.php" enctype="multipart/form-data">
<input type="text" name="user_query" placeholder="Search a Product"/ >
<input type="submit" name="search" value="Search" />
</form>
</div>
</div>
<!--Navigation Bar ends-->
<!--Content wrapper starts-->
<div class="content_wrapper">
<div id="sidebar">
<div id="sidebar_title">Categories</div>
<ul id="cats">
<?php getCategories(); ?>
</ul>
<div id="sidebar_title">Brands</div>
<ul id="cats">
<?php getBrandsName(); ?>
</ul>
</div>
<div id="content_area">
<div id="items_box">
<?php getItem(); ?>
</div>
</div>
</div>
<!--Content wrapper ends-->
<div id="footer">
<h2 style="text-align:center; padding-top:30px;">© 2018 </h2>
</div>
</div>
<!--Main Container ends here-->
</body>
</html>
&#13;
答案 0 :(得分:1)
关于HTML的第一件事:
将<!DOCTYPE>
更改为<!DOCTYPE html>
<input type="text" name="user_query" placeholder="Search a Product"/ >
至<input type="text" name="user_query" placeholder="Search a Product" />
您还可以多次使用ID 猫 - &gt; id="cats"
。在HTML中,每页只能有一个ID。它必须是独一无二的。
并且php函数中缺少</div>
:
在该行<img src='admin_area/item_imgs/$item_image'width=180' height='180'/>
之后添加此结束元素 - &gt; </div>
答案 1 :(得分:0)
除了Simon的回答之外,您似乎还没有清除一些花车。据我所知,#sidebar
和#content_area
在#content_area
内未被清除。在#content_area
底部添加明确的修复程序应该可以解决问题。由于您在本地开发并且我们无法检查该代码,因此很难区分#content_area
内的内容。