简体   繁体   English

属性浮动在CSS中的块显示不正确

[英]Incorrect display of the blocks with the property float in css

I have some problem with page-proofs. 我对页面校样有一些问题。 This is my style.css file: 这是我的style.css文件:

#wrapper {
 margin-top:40px;
 width: 1200px;
 margin: 0 auto;
 height: auto !important;
 }
#category
 {
 padding:10px 10px 10px 20px;
 border-left: 1px solid #d9d9d9;
 border-right: 1px solid #d9d9d9;
 border-bottom: 1px solid #d9d9d9;
 width:200px;
 clear:both;
 display:block;
 }

 #category ul li{
 word-wrap: break-word;
 list-style-image: url(/neoshop/images/check.png);
 padding:10px 0px 10px 10px;
border-bottom:1px dotted #cccccc;
 }
 #category ul li:last-child{
border-bottom:0px dotted #cccccc;
 }

#category ul li a{
font:15px/1.3 "Arial", Arial,Helvetica, sans-serif;
 margin-top:0px;
 font-weight:100;
 display:block;
 color:#2f3638;
 text-decoration:none;
 line-height:20px;

 }

#category ul li a:hover{

 color:#0bb1e8;
 }

#category ul ul a{

list-style-image:none;
color:#8b8b8b;
background:#fff;
}

#category ul ul{
margin-top:5px;
display:none;
color:#8b8b8b;
background:#fff;
}

#category ul ul li{
 word-wrap: break-word;
 list-style-image: none;
 padding:10px 0px 10px 10px;
border-bottom:1px dotted #cccccc;
 }

.catalog
{
margin-left:12px;
float:left;
 width:948px;

}

.product-main
{
    width:236px;
    height:285px;
    float:left;
}

.product{
border-right:1px dotted #cccccc;
padding:0 15px;
}
    .product h2{
    color:#111017;
    text-align:center;
    font:bold 14px/1.3 Tahoma;
    margin:0 0 15px 0;
    }
    .product h3{
    color:#111017;

    text-align:center;
    font:bold 12px/1.3 Tahoma;
    margin:0 0 15px 0;
    }
    .product-img{

    text-align:center;  
    }

    .product-img img{   
    weight:114px;
    height:112px;   
    }

    .price{
    font:13px/1.3 "Arial", Arial,Helvetica, sans-serif;
    color:#0bb1e8;


    }

        .price span{
        font:13px/1.3 "Arial", Arial,Helvetica, sans-serif;
        color:#111017;
        text-align:center;

        }

        .price a{
        clear:both;
        float:right;    
        }
    .bot-dot
    {
    border-bottom:1px dotted #cccccc;
    margin:20px;
    }

.product-main:nth-child(4n) .product
{
border-right:none;
}
.product-main:last-child .product
{
border-right:none;
}
.product-main:nth-child(4n) .bot-dot
{
margin: 20px 0 20px 20px;
}
.product-main:nth-child(4n+1) .bot-dot
{
margin: 20px 20px 20px 0px;
}

If i used standart pictures and description (like picture 2) - i have good appearance of the site. 如果我使用标准图片和说明(如图片2)-我的网站外观不错。 But when I use the data from the database, the block catalog moves down the left and there is a large space between the first and second products. 但是,当我使用数据库中的数据时,块目录向左移动,第一产品和第二产品之间有很大的空间。

{* products_list.tpl *}
{load_presentation_object filename="products_list" assign="obj"}
{* Начало списка товаров *}
<div class="catalog">
{if $obj->mrTotalPages > 1}
<p>
Page {$obj->mPage} of {$obj->mrTotalPages}
{if $obj->mLinkToPreviousPage}
<a href="{$obj->mLinkToPreviousPage}">Previous</a>
{else}
Previous
{/if}
{if $obj->mLinkToNextPage}
<a href="{$obj->mLinkToNextPage}">Next</a>
{else}
Next
{/if}
</p>
{/if}
{if $obj->mProducts}
    {section name=k loop=$obj->mProducts}


    <div class="product-main">
        <div class="product">

            <div class="product-img"><a href="{$obj->mProducts[k].link_to_product}">
                <img src="{$obj->mProducts[k].image}"
                alt="{$obj->mProducts[k].name}"/></a></div>
            <h2><a href="{$obj->mProducts[k].link_to_product}">{$obj->mProducts[k].name}</a></h2>
            <h3>{$obj->mProducts[k].description}</h3>
            <p class="price">{$obj->mProducts[k].price} <span>грн. </span><a href="#">ADD</a></p>
            </div>
    <p class="bot-dot"></p>
        </div>
    </div>
    {/section}
{/if}
{* Конец списка товаров *}

May be a problem with the code in this template, i don't know. 我不知道这个模板中的代码可能有问题。 Please, help me, it's my first project, so i can't understand where the problem. 请帮帮我,这是我的第一个项目,所以我不明白问题出在哪里。

图片错误

右图

You have an extra closing div in your code. 您的代码中还有一个额外的结束div。 This may be causing your problem. 这可能是造成您的问题的原因。

You have: 你有:

<div class="product-main">
    <div class="product">

        <div class="product-img"><a href="{$obj->mProducts[k].link_to_product}">
            <img src="{$obj->mProducts[k].image}"
                 alt="{$obj->mProducts[k].name}"/></a>
       </div>
        <h2><a href="{$obj->mProducts[k].link_to_product}">{$obj->mProducts[k].name}</a></h2>

        <h3>{$obj->mProducts[k].description}</h3>

        <p class="price">{$obj->mProducts[k].price} <span>грн. </span><a href="#">ADD</a></p>
    </div>
    <p class="bot-dot"></p>
</div>
</div>

should be: 应该:

<div class="product-main">
    <div class="product">

        <div class="product-img"><a href="{$obj->mProducts[k].link_to_product}">
            <img src="{$obj->mProducts[k].image}"
                 alt="{$obj->mProducts[k].name}"/></a>
        </div>
        <h2><a href="{$obj->mProducts[k].link_to_product}">{$obj->mProducts[k].name}</a></h2>

        <h3>{$obj->mProducts[k].description}</h3>

        <p class="price">{$obj->mProducts[k].price} <span>грн. </span><a href="#">ADD</a></p>
    </div>
    <p class="bot-dot"></p>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM