css - 宽度 : 100%; height: auto dont work properly

标签 css twitter-bootstrap

我正在使用 Wordpress 建立网站。我已将图像设置为带有 Bootstrap 的 slider 。我的 CSS 代码是:

min-width: 100%;
height: auto;
object-fit: contain;
overflow: hidden;

但它意外地拉伸(stretch)了自己。它显示它的高度比它应该的要大得多。它也降低了它的分辨率。

我的 index.php 代码是:

<div class="container">

    <div class="row">
        <div class="box">
            <div class="col-lg-12 text-center">
                <div id="carousel-example-generic" class="carousel slide">
                    <!-- Indicators -->
                    <ol class="carousel-indicators hidden-xs">
                        <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
                        <li data-target="#carousel-example-generic" data-slide-to="1"></li>
                        <li data-target="#carousel-example-generic" data-slide-to="2"></li>
                    </ol>

                    <!-- Wrapper for slides -->
                    <div class="carousel-inner">
                        <?php $minipost = new WP_Query(array(
                            'post_type' => 'cover-slider',
                            'posts_per_page' => 3
                        ));
                        $i = 1;
                        ?>

                    <?php while($minipost->have_posts()): $minipost->the_post();?>
                        <div class="item<?php if ($i == 1) echo ' active'; ?>">

                                <?php the_post_thumbnail(array('thumbnail', 'class' => ' img-responsive img-full'));?>

                        </div>  
                    <?php $i++; ?>
                    <?php endwhile;?>
                    </div>

                    <!-- Controls -->
                    <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
                        <span class="icon-prev"></span>
                    </a>
                    <a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
                        <span class="icon-next"></span>
                    </a>
                </div>

原图为

但在用作 slider 后显示....

最佳答案

将您的 css min-width: 100% 更改为 width: 100% 应该有效,因为 min-width 会强制图像缩小到其原始大小,而不是比它的可用空间。

由于缺少示例代码,我的回答基于预测。

关于css - 宽度 : 100%; height: auto dont work properly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36407034/

相关文章:

html - 学习 CSS : Why does this code work?

css - bootstrap3 折叠导航栏问题,导航栏标题溢出

css - 不能覆盖 Bootstrap 类?

javascript - 模态不从 ie9 中的顶部滑动

javascript - 你能动态地制作 SVG 动画吗?

html - 有什么方法可以使用 Angular Material 中的 mat-table 来编辑表格的特定列

html - li 在 Angular 中路由到不同的 html 页面时不会消失,为什么?

html - 禁用 Bootstrap 3 响应并将页面加载到 iframe

c# - ASP.NET 生成的输出不受 JQuery/Javascript 的影响

javascript - 如何在悬停时使按钮出现在div的底部