当前位置: 首页 > news >正文

web方向第一次考核内容

一.考核内容

Web组大一下考核之HTML、CSS
1.为什么要清除浮动(4),清除浮动的方法有哪些?(6)(至少两种)
2.怎么实现左边左边宽度固定右边宽度自适应的布局?(10)
3.讲讲flex:1;(10)
4.怎么实现移动端适配不同设备?(10)
5.制作页面
在这里插入图片描述
6.在这里插入图片描述
7.
在这里插入图片描述

8.在这里插入图片描述

二. 考核后的总结

1.

在网页的布局里,浮动常常使用,当父元素不直接设置高度,需要里面的子元素撑开时,子元素都设置了浮动脱离了标准流,会导致父元素没有高度,使得之后的标准流盒子影响整体的布局。
清除浮动的方法:

  • 最常用的方法是使用伪元素清除浮动,思想就是设置一个正常流的盒子,让该正常流的盒子撑开父盒子,避免之后的正常流盒子影响布局。

clearfix清除浮动

.clearfix:after{content:"";display:“block";height: 0px;clear:both;visibility: hidden;
}
  • 父元素触发 BFC:通过设置 overflow: hidden 或 overflow: auto 让父元素形成 BFC(块级格式化上下文),从而包裹浮动元素。有哪些属性可以激活bfc:浮动元素,定位元素(除了absolute,fixed),display:inline-block,overflow:hidden(只要不是visible)

2.

  • 使用flex布局,假设左右两个盒子排在一行,左边固定,右边的盒子给他添加flex:1属性,实现自适应的效果。
  • 使用overflow:hidden,给右边的盒子添加这一属性,让该盒子自己处于独立的渲染模式下(不设置宽度),左边的盒子设置了固定的宽度。
  • 使用margin-left:左边的盒子宽度,给右盒子添加浮动属性,使他们一行排列,则可以实现右边宽度自适应的效果。
    相应的dom结构
<div class="box1"></div>
<div class="box2"></div>
.box1 {float: left;width: 200px;height: 200px;background-color: pink;}.box2 {margin-left: 200px;height: 200px;background-color: purple;}

3.

flex:1是flex布局中的一个属性设置,如果大容器的每一个盒子都设置了这一个属性,则每一个盒子会平均分配大盒子的剩余宽度。
.container {
display: flex;
}
.item {
/* 所有子元素平分容器宽度 */
flex: 1;
}

4.

  • REM 适配

通过媒体查询动态设置根字体大小(基于设计稿宽度,如 750px),引入flexible.js外部文件,动态处理rem的大小。

  • Flexible 布局 + 媒体查询

使用 Flexbox 实现弹性布局。

针对不同屏幕尺寸设置媒体查询调整样式:

css
@media (max-width: 600px) {
body { font-size: 14px; }
}

  • VW/VH 单位

直接使用视口单位(1vw = 1% 视口宽度,也可以用vmin以视口宽高较小的一个为准)

  • 也可以使用bootstrap框架,栅栏式布局在四种屏幕宽度条件下搭配上媒体查询在屏幕缩放的过程中改变页面布局。

5.

  1. 页面分为头部,内容,尾部,头部和内容都可以使用flex布局,头部设置justify-content:space-between属性占据左右两部分。
  2. 内容可以给中间的盒子设置margin值,给每一个子盒子设置flex:1实现三栏布局。
    在这里插入图片描述

6.

  1. 这个要注意的是设置一个只能显示一个数字大小的外部盒子,套一个大的子盒子,根据子绝父相定位子盒子,设置一个动画改变它的top值。
<div class="box"><div class="contain"><div>0</div><div>1</div><div>2</div><div>3</div><div>4</div><div>5</div><div>6</div><div>7</div><div>8</div><div>9</div></div></div>
* {box-sizing: border-box;}.box {position: relative;display: inline-block;width: 30px;height: 50px;background-color: green;border-radius: 5px;overflow: hidden;}@keyframes move {from {top: 0;}to {top: -460px;}}.contain {position: absolute;top: 0;left: 0;width: 30px;height: 500px;margin: 0 auto;border-radius: 5px;font-size: 16px;text-wrap: wrap;text-align: center;animation: move 4s ease-in-out infinite alternate backwards;}.contain div {width: 100%;height: 50px;line-height: 50px;}.contain div:last-child {width: 100%;height: 25px;}

7.

这里的动画设置分为三部分,也就是三个关键帧,设置scaleY属性实现竖直方向的伸缩。

<div class="radio"><span></span><span></span><span></span><span></span><span></span><span></span><span></span> </div>
.radio {position: absolute;top: 0px;bottom: 0px;left: 0px;right: 0px;margin: auto;width: 175px;height: 100px;}.radio span {display: block;background: orange;width: 7px;height: 100%;border-radius: 14px;margin-right: 5px;float: left;}.radio span:nth-child(1) {animation: load 2.5s 1.4s infinite linear;}.radio span:nth-child(2) {animation: load 2.5s 1.2s infinite linear;}.radio span:nth-child(3) {animation: load 2.5s 1s infinite linear;}.radio span:nth-child(4) {animation: load 2.5s 0.8s infinite linear;}.radio span:nth-child(5) {animation: load 2.5s 0.6s infinite linear;}.radio span:nth-child(6) {animation: load 2.5s 0.4s infinite linear;}.radio span:nth-child(7) {animation: load 2.5s 0.2s infinite linear;}@keyframes load {0% {transform: scaleY(1);}50% {transform: scaleY(0.08);}100% {transform: scaleY(1);}}

8.

爱心怦怦跳

这个爱心的实现中每个线条是依次变长的,因此线条的开始的时间是不同的要设置延迟属性,这个爱心是对称形状的,因此对称线条的动画是相同的,只需要设置5个动画。
这里动画设置的点是关键帧可以简写,确保动画变完之后可以维持一段时间的状态等待之后的线条变化。

<div class="rad">爱心怦怦跳</div><div class="contain"><div class="space"></div><div class="space"></div><div class="space"></div><div class="space"></div><div class="space"></div><div class="space"></div><div class="space"></div><div class="space"></div><div class="space"></div></div>
body {height: 100vh;display: flex;justify-content: center;align-items: center;background-color: #000;}.rad {position: absolute;top: 60px;left: 50%;transform: translate(-50%, 0);text-align: center;line-height: 100px;font-weight: 600;font-size: 60px;color: transparent;background-clip: text;background-image: linear-gradient(to right, #ff8177 0%, #ff867a 0%, #ff8c7f 21%, #f99185 52%, #cf556c 78%, #b12a5b 100%);}.contain {position: absolute;top: 300px;display: flex;height: 200px;}.contain .space {flex: 1;margin: 0 12px;width: 20px;height: 20px;border-radius: 10px;}.contain .space:nth-child(1) {background-color: orange;animation: move1 5s infinite 0s linear;}.contain .space:nth-child(2) {background-color: skyblue;animation: move2 5s infinite .2s linear;}.contain .space:nth-child(3) {background-color: #bc3a3a;animation: move3 5s infinite .4s linear;}.contain .space:nth-child(4) {background-color: lightpink;animation: move4 5s infinite .6s linear;}.contain .space:nth-child(5) {background-color: yellow;animation: move5 5s infinite .8s linear;}.contain .space:nth-child(6) {background-color: lightpink;animation: move4 5s infinite 1.0s linear;}.contain .space:nth-child(7) {background-color: #bc3a3a;animation: move3 5s infinite 1.2s linear;}.contain .space:nth-child(8) {background-color: skyblue;animation: move2 5s infinite 1.4s linear;}.contain .space:nth-child(9) {background-color: orange;animation: move1 5s infinite 1.6s linear;}@keyframes move1 {30%,60% {height: 60px;transform: translateY(-30px);}80%,100% {height: 20px;transform: translateY(0);}}@keyframes move2 {30%,60% {height: 125px;transform: translateY(-60px);}80%,100% {height: 20px;transform: translateY(0);}}@keyframes move3 {30%,60% {height: 160px;transform: translateY(-75px);}80%,100% {height: 20px;transform: translateY(0);}}@keyframes move4 {30%,60% {height: 180px;transform: translateY(-60px);}80%,100% {height: 20px;transform: translateY(0);}}@keyframes move5 {30%,60% {height: 200px;transform: translateY(-45px);}80%,100% {height: 20px;transform: translateY(0);}}

相应的渲染效果

在这里插入图片描述

相关文章:

  • Linux免驱使用slcan,使用方法以Ubuntu为例
  • g++ a.cpp -o a ‘pkg-config --cflags --libs opencv4‘/usr/bin/ld: 找不到 没有那个文件或目录
  • [特殊字符] Next.js Turbo 模式不支持 @svgr/webpack 的原因与解决方案
  • Redis的list的底层原理
  • 后端通过nignx代理转发,提供接口供前端在防火墙外访问
  • Arduino入门教程​​​​​​​:4、打印字符到电脑
  • python中的模块化编程:日期模块、math算术模块、random模块
  • 国学IP行业实战洞察:聚焦创客匠人,解锁创始人IP与知识变现新路径
  • TDengine 如何从 2.x 迁移到 3.0
  • 用bilibili一个讲座视频,生成一本科普书籍
  • 苍穹外卖-day09
  • 湖北理元理律师事务所债务优化实务:平衡还款与生活的法律路径
  • (下)通用智能体与机器人Transformer:Gato和RT-1技术解析及与LLM Transformer的异同
  • uni-app项目实战笔记10--设置页面全局渐变线性渐变背景色
  • 上位机开发中的设计模式(3):装饰器模式
  • Flutter动画与交互:打造流畅用户体验的完整指南
  • QT集成Boost库
  • LeetCode - 34. 在排序数组中查找元素的第一个和最后一个位置
  • 【DSP笔记 · 第4章】算法的奇迹:快速傅里叶变换(FFT)如何改变世界
  • 理解C++中传引用和传值的区别
  • 网站建设与管理学的是什么/班级优化大师app下载
  • 图片搜集网站怎么做/百度推广后台登陆官网
  • 做网站还用注册商标吗/seo优化文章网站
  • 德州建设信息网站/西安seo关键词查询
  • 安徽网站开发/成品短视频app下载有哪些
  • 公司找人做网站/竞价网络推广培训