当前位置: 首页 > 知识库问答 >
问题:

引导中的行中的列未填充页面宽度

司马彦
2023-03-14

我有一个网站的部分,有2行内容器,两行有3列的类col-sm-4和col-md-4。两行每列都有1个图像。所有图像在300px宽时大小完全相同。顶部行显示准确,底部行浓缩了3列,并在右侧留下了大面积的宽阔空间。使用检查器时,顶部行列显示为col-md-4类,但底部行列显示为col-sm-4类。我不确定这是不是原因。我还应该提到,顶部行列在每个图像下面都有段落。当仅在1列中将完全相同的段落内容添加到底部行时,问题就解决了,但我不希望这里有段落。我检查了引导CSS和我自己的,试图找到一些风格上的痛处

HTML:

<div class="wrapper">
        <div class="row customer-options">
            <div class="button-container">
                <div class="col-sm-4 col-md-4">
                    <img class="img-circle img-responsive img-center" src="images/button-icon-map2.png" alt="">
                    <h2>Title 1</h2>
                    <p>These marketing boxes are a great place to put some information. These can contain summaries of what the company does, promotional information, or anything else that is relevant to the company. These will usually be below-the-fold.</p>
                </div>
                <div class="col-sm-4 col-md-4">
                    <img class="img-circle img-responsive img-center" src="images/button-icon-pref2.png" alt="">
                    <h2>Title 2</h2>
                    <p>The images are set to be circular and responsive. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
                </div>
                <div class="col-sm-4 col-md-4">
                    <img class="img-circle img-responsive img-center" src="images/button-icon-add2.png" alt="">
                    <h2>Title 3</h2>
                    <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
                </div>
            </div>
        </div><!-- /.row -->
    </div><!--wrapper-->

    <hr>

    <div class="wrapper">
        <div class="row tap">
            <div class="tap-container">
                <div class="col-sm-4 col-md-4">
                    <img class="img-circle img-responsive img-center" src="images/beer-tap.png" alt="">
                    <h2><a href="">About</a></h2>
                </div>
                <div class="col-sm-4 col-md-4">
                    <img class="img-circle img-responsive img-center" src="images/beer-tap.png" alt="">
                    <h2><a href="">Services</a></h2>
                </div>
                <div class="col-sm-4 col-md-4">
                    <img class="img-circle img-responsive img-center" src="images/beer-tap.png" alt="">
                    <h2><a href="">Contact</a></h2>
                </div>
            </div>
        </div><!-- /.row -->
    </div><!--wrapper-->

CSS:

.wrapper {
    display: table;
}

.button-container {
    padding-right: 15px;
    padding-left: 15px;
}

.customer-options {
    background-color: #848487;
    padding-top: 20px;
    height:100vh;
    display: table-cell;
    vertical-align: middle;
}

.tap {
    background-color: #848487;
    padding-top: 20px;
    height:100vh;
    display: table-cell;
    vertical-align: middle;
    text-align: center;
}

.tap-container {
    padding-right: 15px;
    padding-left: 15px;
}

.customer-options h2 {
    text-align: center;
}

共有1个答案

聂永怡
2023-03-14

显示表格和表格单元格优先于响应图像。表格适合其内容,然后img将填充新宽度。您可能会找到一种方法来实现垂直对齐,但我建议您放弃表系统,并正确使用bootstrap的网格系统。然后可以使用FlexBox获得垂直对齐。

http://jsfiddle.net/28qq8fm3/

<style>
    .customer-options {
        background-color: #848487;
        padding-top: 20px;
        vertical-align: middle;
    }
    .tap {
        background-color: #848487;
        padding-top: 20px;
        vertical-align: middle;
        text-align: center;
    }
    .customer-options h2 {
        text-align: center;
    }
</style>

<div>
    <div class="row customer-options">
        <div class="col-sm-4 col-md-4">
            <img class="img-circle img-responsive img-center" src="https://beccasheppard.files.wordpress.com/2011/09/football.jpg" alt="">
             <h2>Title 1</h2>

            <p>These marketing boxes are a great place to put some information. These can contain summaries of what the company does, promotional information, or anything else that is relevant to the company. These will usually be below-the-fold.</p>
        </div>
        <div class="col-sm-4 col-md-4">
            <img class="img-circle img-responsive img-center" src="https://beccasheppard.files.wordpress.com/2011/09/football.jpg" alt="">
             <h2>Title 2</h2>

            <p>The images are set to be circular and responsive. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
        </div>
        <div class="col-sm-4 col-md-4">
            <img class="img-circle img-responsive img-center" src="https://beccasheppard.files.wordpress.com/2011/09/football.jpg" alt="">
             <h2>Title 3</h2>

            <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
        </div>
    </div>
    <!-- /.row -->
</div>
<!--wrapper-->
<hr>
<div>
    <div class="row tap">
        <div class="col-sm-4 col-md-4">
            <img class="img-circle img-responsive img-center" src="http://www.cozadschools.net/wp-content/uploads/2015/02/football.png" alt="">
             <h2><a href="">About</a></h2>

        </div>
        <div class="col-sm-4 col-md-4">
            <img class="img-circle img-responsive img-center" src="http://www.cozadschools.net/wp-content/uploads/2015/02/football.png" alt="">
             <h2><a href="">Services</a></h2>

        </div>
        <div class="col-sm-4 col-md-4">
            <img class="img-circle img-responsive img-center" src="http://www.cozadschools.net/wp-content/uploads/2015/02/football.png" alt="">
             <h2><a href="">Contact</a></h2>

        </div>
    </div>
    <!-- /.row -->
</div>
<!--wrapper-->
 类似资料:
  • 我首先创建了一个全宽的动画边框渐变,然后我想像在Adobe XD上所做的那样创建两个相邻的大容器,但是我不能增加容器的宽度。 我已经截图了一些: Adobe XD参考 集装箱问题Pic 谢谢. 代码如下: home.jsx home.css null null

  • 使用Bootstrap 5,我如何使列根据其内容具有灵活的宽度,但所有列仍然填充行的全部宽度? 如果我使用,那么列的宽度都是相同的。如果我使用,那么列就不会填充行的宽度。 如有任何建议,将不胜感激。谢谢你。

  • 2. 另外,我还面临一个问题,当我在Websphere application server上部署应用程序并以ServerName/ProjectName访问链接时,它会给出一个错误,说明 因此我被迫以ServerName/ProjectName/index.jsp的身份访问应用程序--它运行良好!我不能理解这个问题,因为它不显示在我的本地机器上,只有当我部署它在服务器上。请在我的web.xml下

  • 我有一个用SceneBuilder生成的TableView,所有列都是从其他视图导入的FXML,直到没有问题为止,但列没有填充宽度。 我试图用scene builder和FXML来解决这个问题,但没有运气,所有的大小都是计算出来的。 我尝试用一个change listener对其进行编码,它在每次窗口改变大小以适应列的大小时都会进行检查。 这样可以工作,并且列的大小调整到适当的宽度(基本上我得到了

  • 我用TabLayout设置了ViewPager2,以便通过滑动或单击选项卡来切换片段。我所知道的问题是,我的碎片并没有占据所有的空间,我在底部有一个无法滑动的空白空间。我怎样才能把我的碎片填满那个空间? 编辑:我认为我的问题与我试图在另一个片段中加载我的视图寻呼机这一事实有关。我将我的代码复制到一个新项目中,而不是将我的代码加载到一个片段中,而是将它加载到主活动中,并且它已经工作了。在片段中加载视

  • 我刚刚回到学习引导,html和css。到目前为止,我有三张不同宽度的卡片,使用自举网格水平卡片模板。我的问题是,我希望我的布局是相同的每张卡片,标题和段落应该是相同的距离在每个和fav/info按钮从标题相同的距离。此外,我设法让前两列接近,但不知何故,最后一列和最大一列的图像和标题之间有奇怪的超大行间距。我该怎么做呢? 我试图手动调整每张卡中元素的位置,但很难让它们保持一致,这也让我的代码变得一