当我缩小浏览器窗口或以较小的分辨率访问它时,侧边栏会超过页脚。喜欢这个页面:
http://tithaty.com.br/?product_cat=mantas_peseiras
我已经尝试过我在网站上找到的所有建议,但没有任何对我有用。
如果我将浮动div的最小高度设置在它旁边" coluna_direita"到侧边栏的高度,但这并不理想,因为如果我添加另一个类别,侧边栏可能会改变高度。那么,有没有办法设置" coluna_direita"的最小高度? div动态变化到侧边栏的高度是什么?
或者任何其他更简单的解决方案都会很棒。
谢谢
编辑:这是一个自定义的Woocommerce模板
<div class="wrap_shop">
<?php
/**
* The Template for displaying product archives, including the main shop page which is a post type archive.
*
* Override this template by copying it to yourtheme/woocommerce/archive-product.php
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
get_header( 'shop' ); ?>
<?php
/**
* woocommerce_before_main_content hook
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
*/
do_action( 'woocommerce_before_main_content' );
?>
<div id="coluna_direita">
<div class="resultados">
<?php
/**
* woocommerce_archive_description hook
*
* @hooked woocommerce_taxonomy_archive_description - 10
* @hooked woocommerce_product_archive_description - 10
*/
do_action( 'woocommerce_archive_description' );
?>
</div> <!--resultados-->
<?php if ( have_posts() ) : ?>
<?php
/**
* woocommerce_before_shop_loop hook
*
* @hooked woocommerce_result_count - 20
* @hooked woocommerce_catalog_ordering - 30
*/
do_action( 'woocommerce_before_shop_loop' );
?>
<?php woocommerce_product_loop_start(); ?>
<?php woocommerce_product_subcategories(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php /*<div id="desejos"><?php echo do_shortcode( '[yith_wcwl_add_to_wishlist] ' ); ?></div> */ ?>
<?php endwhile; // end of the loop. ?>
<?php woocommerce_product_loop_end(); ?>
<?php
/**
* woocommerce_after_shop_loop hook
*
* @hooked woocommerce_pagination - 10
*/
do_action( 'woocommerce_after_shop_loop' );
?>
<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>
<?php wc_get_template( 'loop/no-products-found.php' ); ?>
<?php endif; ?>
<?php
/**
* woocommerce_after_main_content hook
*
* @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
?>
</div> <! -- coluna_direita -->
<div id="sidebarshop">
<div id="side_content">
<?php
/**
* woocommerce_sidebar hook
*
* @hooked woocommerce_get_sidebar - 10
*/
/*do_action( 'woocommerce_sidebar' ); */
?>
<?php get_sidebar( 'shop' ); ?>
</div> <!-- side_content-->
</div> <!-- sidebarshop -->
<?php get_footer( 'shop' ); ?>
</div>
答案 0 :(得分:0)
浮动正在引发问题。
不需要更改HTML结构的解决方案:
#container {
float: right;
width: 75%;
}
#sidebarshop {
margin-top: -5px;
width: 25%;
float: left;
background-color: #fff;
min-height: 100%; /** change from height to min-height **/
}
#coluna_direita {
/* width: 75%; - moved to container */
/* float: right; - moved to container */
padding-left: 20px;
min-height: 100%; /** change from height to min-height **/
margin-top: 15px;
}
如果您可以更改HTML结构,请使用flexbox:
HTML:
<div id="content" role="main">
<div id="sidebarshop"> <!-- move into #content -->
</div>
<div id="coluna_direita">
</div>
</div>
#content {
display: flex;
}
#sidebarshop {
margin-top: -5px;
width: 25%;
/* float: left; - Remove the float **/
background-color: #fff;
/* height: 100%; - Remove the height, so the sidebar will push the flexbox down when needed **/
}
#coluna_direita {
width: 75%;
/* float: right; - Remove the float **/
padding-left: 20px;
margin-top: 15px;
}