发表于: 2021-02-15 02:43:09

1 1254


完成任务五

代码在代码链接中都有展示,这里只写写前端时碰到的坑

1.flex两个元素的居中、最左显示

先将显示内容设置为默认的左排序,然后将需要居中的元素(这里是span)的margin左右为auto

因为这里是将span放到右边的那块居中(省去了返回按钮),所以需要往左边移动返回按钮的宽度

2.flex下的文字挤压

使用flex时,如果需要某一块的内容不会被右边文字挤压,需要设置 flex-shrink:0;

3.fixed固定按钮的位置

主div与按钮的固定定位不冲突,固定定位的按钮,每个都要在自己单独的button的css中,设置position: fixed;

left right也可以用百分比来表示距离的宽度

需要去算间隔,这里是每个按钮45.1%,外加每个宽度3%,加起来正好 100%


footer button{
    width45.5%;
    height2.5rem;
    margin0 3%;
    /* 设置圆角 */
    border-radius:0.5rem;
}

footer button:nth-of-type(1){
    /* 设置位置 */
    positionfixed;
    bottom0;
    left0;
    /* 边框颜色 */
    border0.2rem solid #68CDD6;
    /* 背景透明 */
    background-color:transparent;
     /* 点击后 显示的外框 */
     outline:none;
}

footer button:nth-of-type(2){
    /* 设置位置 */
    positionfixed;
    bottom0;
    right0;
    margin-left0;
    /* 按钮背景色 */
    background-color#68CDD6;
    /* 默认 显示的外框 */
    border:none;
    /* 点击后 显示的外框 */
    outline:none;
}

返回列表 返回列表
评论

    分享到