我还在学习,但这让我感到有些困惑。我有使用PHP填充从我的数据库中提取内容的页面。这些页面中的每一个都采用相同的方式。但是,当我对它们进行全部测试时,其中一些会有所不同,我不确定原因。
这是PHP:
<div id="container">
<?php
$result = mysql_query ("SELECT id, large_images, project_name, category_name, description, applications_used, web
FROM projects
WHERE {$_GET['id']}=id") or die ("mysql_query error");
while ($row = mysql_fetch_assoc($result))
{
$large_image = $row['large_images'];
$large_image = explode(",", $large_image);
$applications_used = $row ['applications_used'];
$applications_used = explode(",", $applications_used);
echo "<div id='info'>";
echo "<div class='banner2'><p>{$row['project_name']}</p></div>";
echo "<div class='category'><h3>{$row['category_name']}</h3></div>";
echo "<div id='description'>{$row['description']}";
echo "<div class='web_link'><p>{$row['web']}</p></div>";
echo "</div>";
echo "<div id='applications'><h4>Applications</h4>{$row['applications_used']}</div>";
echo "</div>";
echo "<div id='slideshow_container'>";
echo "<div id='slides'>";
echo "<div class='slides_container'>";
foreach($large_image as $large_image)
{
echo "<div><img src='images/portfolio/large/$large_image' alt='{$row[project_name]}' width='100%' /></div>";
}
echo "</div>";
echo "</div>";
echo "</div>";
echo "<div id='extra'>";
echo "<span></span>";
echo "</div>";
}
?>
</div>
我设计它使页面看起来像这样:
http://www.liannesuggitt.com/test/portfolio/slideshow.php?%20id=0
然而,有时它看起来像这样(太高):
http://www.liannesuggitt.com/test/portfolio/slideshow.php?%20id=1
或者这个太低了:(我没有足够的代表,用id = 9替换最后一位)
CSS有两个地方,一个名为portfolio_slideshow.css,如下所示:(改编自slidesjs.com)
#slideshow_container
{
height: 500px;
width: 702px;
margin: -775px auto 0 auto;
}
#slideshow_container:after
{
display:block;
clear: both;
content: "";
}
/*
Slides container
Important:
Set the width of your slides container
Set to display none, prevents content flash
*/
.slides_container {
width: 702px;
display: none;
position: relative;
height: 552px;
margin: -770px auto 0 auto;
float: left;
}
.slides_container img
{
border: 1px solid black;
width: 700px;
height: 550px;
margin: 0 auto;
}
/*
Each slide
Important:
Set the width of your slides
If height not specified height will be set by the slide content
Set to display block
*/
.slides_container a {
width:90%;
height:400px;
display:block;
}
/*
Pagination
*/
.pagination {
margin: 720px auto auto 35%;
width: 200px;
position: absolute;
padding-bottom: 2px;
}
.pagination li {
float:left;
margin:0 1px;
list-style:none;
}
.pagination li:first-child
{
margin-left: 10px;
}
.pagination li a {
display:block;
width:13px;
height:0;
padding-top:14px;
background-image:url(../img/pagination.png);
background-position:0 0;
float:left;
overflow:hidden;
}
.pagination li a:hover
{
background-position:0 -25px;
}
.pagination li.current a {
background-position:0 -13px;
}
另一个来自style.css,这里涉及的片段是:
#info
{
width: 78%;
margin: 590px auto 0 auto;
height: 70px;
padding: 15px;
}
#description p
{
text-align: justify;
}
.banner2
{
background: url("../images/banner.png");
width: 200px;
height: 40px;
position: absolute;
z-index: 200;
margin-top: -580px;
margin-left: -110px;
color: white;
}
.banner2 p
{
text-align: center;
font-size: 110%;
line-height: 30px;
font-family: 'Conv_Essays1743';
}
.category
{
margin-top: 50px;
font-family: 'Conv_Essays1743';
text-transform: uppercase;
}
.category h3
{
font-family: 'Conv_Essays1743';
color: black;
font-size: 120%;
margin-left: -25px;
margin-bottom: 15px;
}
#description
{
height: auto;
padding-bottom: 6px;
float: left;
width: 82%;
}
#description p
{
margin-bottom: 5px;
}
#applications
{
/*border: 1px solid green;*/
height: 29%;
margin-left: 10px;
float: right;
width: 12%;
}
#applications h4
{
font-family: 'Conv_Essays1743';
margin-bottom: 8px;
}
.web_link
{
margin-top: -7px;
text-align: left;
float: left;
}
.web_link a
{
color: black;
text-transform: uppercase;
font-family: 'Conv_Essays1743';
font-size: 80%;
}
.web_link a:hover
{
color: #5a5a5a;
}
很抱歉,如果这很冗长,我认为更容易看到代码而不是寻找它! 而且我知道幻灯片部分有一些奇怪的边缘,有很多奇怪的div(据我所知哈哈)
感谢您提供任何信息,
答案 0 :(得分:0)
好的,所以要解决这个困境,我必须重新排列php,以便首先“幻灯片”部分而不是内容,并相应地设置样式。之前,幻灯片放映的位置取决于内容结束的位置(因为幻灯片放映的边缘 - 顶部是从内容的div的结束点计算的),并且由于内容的长度在每个页面上有所不同,因此导致幻灯片放映转移它的位置。
它仍然是x像素值,只是它计算它的点正在移动。
感谢那些看过的人。