温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CSS中如何使用Frasbox创建等高度定价表

发布时间:2021-07-28 16:54:12 来源:亿速云 阅读:121 作者:Leah 栏目:web开发

本篇文章为大家展示了CSS中如何使用Frasbox创建等高度定价表,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

One

Two

Three

Four

Five

Six

Seven

Eight

Nine

Ten

Eleven

Twelve

Thirteen

Fourteen

Fifteen

Sixteen

Seventeen

Eighteen

Nineteen

Twenty

Twenty-one

Twenty-two

<div class=“价值连城”>

    <ul class="theplan" &#62;

        <li class="title"><b>2nd Place</b><br />Herman Miler</li>

        <li><b>Weight:</b> 55 lbs</li>

        <li><b>Max Weight:</b> 330 lbs</li>

        <li><a class="pricebutton"href="#"><span class="icon-tag"></span> Check Out</a></li>

    </ul>

    <ul class="theplan" &#62;

        <li class="title"><b>1st Place</b><br />Argomax Chair</li>

        <li><b>Material:</b> Nylon w/ Breathable Glass Fiber</li>

        <li><b>Head Rest:</b> Yes</li>

         &#34;

         &#34;

        <li><a class="pricebutton"href="#"><span class="icon-tag"></span> Check Out</a></li>

    </ul>

    <ul class="theplan" &#62;

        <li class="title"><b>3rd Place</b><br />Eurotech Mesh</li>

        <li class="ethighlight"><b>Dimensions:</b> 24.8W x 47.3H</li>

         &#34;

        <li><a class="pricebutton"href=""><span class="icon-tag"></span> Check Out</a></li>

    </ul>

</div>

如你所见,每一个UL.theplan元素包含不同数量的Li条目。目标是使每个UL的高度相同,并且每个定价计划的最后一个LI条目在最底部对齐。

我找到的最简单的方法是什么?使用CSS FrasBox并设置每个ULflex-direction:column因此,他们垂直扩张,以匹配最长的弯曲儿童的身高。我将在下面更详细地解释。

CSS

这里是等高线定价表的CSS。我删除了不重要的部分,所以你可以把重点放在重要的事情上:

One

Two

Three

Four

Five

Six

Seven

Eight

Nine

Ten

Eleven

Twelve

Thirteen

Fourteen

Fifteen

Sixteen

Seventeen

Eighteen

Nineteen

Twenty

Twenty-one

Twenty-two

Twenty-three

Twenty-four

Twenty-five

Twenty-six

Twenty-seven

Twenty-eight

Twenty-nine

Thirty

Thirty-one

Thirty-two

Thirty-three

Thirty-four

Thirty-five

Thirty-six

Thirty-seven

Thirty-eight

Thirty-nine

Forty

Forty-one

Forty-two

Forty-three

Forty-four

Forty-five

Forty-six

Forty-seven

Forty-eight

Forty-nine

Fifty

Fifty-one

Fifty-two

Fifty-three

.pricingdiv{

    显示:flex;

    flex-wrap: wrap;

    证明内容:中心;

}

.pricingdiv ul.theplan{

    列表样式:无;

    margin: 0;

    Padding:0;

    显示:flex;

    FLEX-Direction:Column;

    宽度:260px;/* width of each table */

    margin-right: 20px;/* spacing between tables */

    margin-bottom: 1em;

    边框:1PX固体灰;

    Transition:all 5s;

}

.pricingdiv ul.theplan:hover{ /*当鼠标悬停在定价表*//

    变换:量表(1.05);

    Transition:all 5s;

    z-index: 100;

    P.O.Box-Shadow:0 10px gray;

}

.pricingdiv ul.theplan:last-of-type{ *在最后一张表中删除右边空白*

    margin-right: 0;

}

/*very last LI within each pricing UL */

.pricingdiv ul.theplan li:last-of-type{

    Text-align:Center;

    margin-top: auto;/*align last LI (price botton li) to the very bottom of UL */

@media only screen and (max-width: 600px) {

    这个计划{

        border-radius: 0;

        宽度:100%;

        margin-right: 0;

     }

    PrigIdIVUL.计划:悬停{

        变换:无;

        盒影:无;

     }

    

    PrICIGIDEV A.Price按钮{

        显示:块;

     }

}

首先,将父DIV容器设置为display:flex,并允许Flex儿童以水平方向包装并水平居中。flex-wrap: wrapjustify-content: center. 所有的儿童UL元素被认为是屈曲儿童。

对于每个由UL元素组成的定价表,i flex-direction:column. 默认情况下,Flex儿童在水平轴上播放。通过设置方向:,我强迫Flex儿童的所有默认行为发生在垂直平面上,包括金奖。默认相等高度屈曲儿童 .

在每个UL定价表中对齐最后的LI

因此,DIV内的所有单独的定价表现在都是相同的高度,但仍然需要一个重要的改进,使所有的东西看起来都很漂亮。我希望调用Actudio按钮,它包含在每个UL的最后一个Li中,以与表的最底部对齐。

要做到这一点包括2个步骤。首先,我将每个UL定价表也设置为FrasBox容器本身。display: flex)一旦完成,我就可以使用margin属性将特定子元素与它的对等体对齐,例如对于水平Flex子块的左对齐或右对齐,或者在这种情况下,垂直Flex子、顶部或底部。

为了使最后一个Li元素处于底部对齐,添加的魔法成分是margin-top: auto在这些元素里面:

One

Two

Three

Four

.pricingdiv ul.theplan li:last-of-type{

    Text-align:Center;

    margin-top: auto;/*align last LI (price botton li) to the very bottom of UL */

}

上述内容就是CSS中如何使用Frasbox创建等高度定价表,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI