完成任务五
代码在代码链接中都有展示,这里只写写前端时碰到的坑
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{
width: 45.5%;
height: 2.5rem;
margin: 0 3%;
/* 设置圆角 */
border-radius:0.5rem;
}
footer button:nth-of-type(1){
/* 设置位置 */
position: fixed;
bottom: 0;
left: 0;
/* 边框颜色 */
border: 0.2rem solid #68CDD6;
/* 背景透明 */
background-color:transparent;
/* 点击后 显示的外框 */
outline:none;
}
footer button:nth-of-type(2){
/* 设置位置 */
position: fixed;
bottom: 0;
right: 0;
margin-left: 0;
/* 按钮背景色 */
background-color: #68CDD6;
/* 默认 显示的外框 */
border:none;
/* 点击后 显示的外框 */
outline:none;
}
评论