zoukankan      html  css  js  c++  java
  • css按钮定位在div底部

      如图,黄色按钮沉在div底部:

      

      这种场景会经常遇到,比如头部固定,底部固定,或者侧边栏固定等,虽然很简单,但是好记性不如烂笔头,作为一个后端开发,在转全栈的路上css还是有点蛋疼的。

    #dataExplain {
            position: fixed;
            background-color: white;
        }
        .dataExplainBtn {
            width: 100%;
            position: absolute;
            bottom: 0px;
            transform: translateX(-50%);
        }

      如上代码便可,父级div给个定位,子级按钮再给个绝对定位就可。这里我父级div给的固定定位是结合我自己的业务需求,不一定非要设置为固定定位,父级div设置为固定定位也是起效的。

      css没啥特别好说的,bottom和transform两个属性的作用是让按钮沉底并居中。

      以上。

  • 相关阅读:
    HDU
    洛谷- P1306 斐波那契公约数
    HDU
    HDU
    POJ3321
    SPOJ
    HDU
    POJ 1236 Network of Schools
    POJ-3169 Layout (差分约束+SPFA)
    POJ-1062 昂贵的聘礼 (最短路)
  • 原文地址:https://www.cnblogs.com/sunshine-wy/p/12807487.html
Copyright © 2011-2022 走看看