关于学习css这件事

2024-03-18 23:40
文章标签 学习 css frontend 这件

本文主要是介绍关于学习css这件事,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.VW

vw是视口宽度,是个相对单位.

1vw=1/100屏幕的宽度

vw和1%的区别

01.vw永远是以视口的宽度为准,在375的设计稿下,1vw永远是3.75px

02.百分比以父盒子为准,假如父盒子是200px,则1%是2px

2.应用

我们可以用vw相关知识做一个bilibili页面布局 : 

首先我们引入 :

 

标题图标文件

<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">

字体图标文件

<link rel="stylesheet" href="./fonts/iconfont.css">

@font-face {font-family: iconfont;src: url(./iconfont.eot);src: url(./iconfont.eot#iefix) format("embedded-opentype"), url(./iconfont.woff) format("woff"), url(./iconfont.ttf) format("truetype"), url(./iconfont.svg#iconfont) format("svg")
}.iconfont {font-family: iconfont!important;font-size: 4.26667vw;font-style: normal;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale
}.like2:before {content: "\e636"
}.Blocked:before {content: "\e635"
}.dianying:before {content: "\e634"
}.huancun:before {content: "\e631"
}.qingxidu:before {content: "\e632"
}.dianzan:before {content: "\e633"
}.Like:before {content: "\e630"
}.History:before {content: "\e68d"
}.fanju:before {content: "\e62f"
}.ic_up:before {content: "\e741"
}.notice:before {content: "\e62e"
}.loading:before {content: "\eee3"
}.guanbi:before {content: "\e62d"
}.icon_fenqudaohang_paihangbang:before {content: "\e737"
}.gengduo1:before {content: "\e602"
}.live:before {content: "\e62c"
}.ic_vip_badge:before {content: "\e62b"
}.ic_popular:before {content: "\e62a"
}.general_pulldown_s:before {content: "\e6eb"
}.general_pullup_s:before {content: "\e6ec"
}.icon_comment:before {content: "\e629"
}.icon_download:before {content: "\e626"
}.icon_share:before {content: "\e627"
}.icon_fav:before {content: "\e628"
}.general_complete:before {content: "\e625"
}.ic_add1:before {content: "\e624"
}.ic_female:before {content: "\e623"
}.ic_male:before {content: "\e622"
}.info_warning:before {content: "\e621"
}.ic_userlevel_3:before {content: "\e61a"
}.ic_userlevel_2:before {content: "\e61b"
}.ic_userlevel_5:before {content: "\e61c"
}.ic_userlevel_4:before {content: "\e61d"
}.ic_userlevel_1:before {content: "\e61e"
}.ic_userlevel_6:before {content: "\e61f"
}.error:before {content: "\e620"
}.icon_xinxi_pinglunshu:before {content: "\e618"
}.icon_xinxi_yuedushu:before {content: "\e619"
}.icon_shipin_danmushu:before {content: "\e616"
}.icon_shipin_bofangshu:before {content: "\e617"
}.ic_search_tab:before {content: "\e615"
}.Navbar_logo:before {content: "\e614"
}

首页的css文件

<link rel="stylesheet" href="./css/index.css">

* {margin: 0;padding: 0;box-sizing: border-box;-webkit-font-smoothing: antialiased;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
body {font-family: Helvetica Neue, Tahoma, Arial, PingFangSC-Regular, Hiragino Sans GB, Microsoft Yahei, sans-serif;
}
a {color: #333;text-decoration: none;
}
img {vertical-align: middle;width: 100%;height: 100%;
}
ul {list-style: none;
}
.ellipsis-2 {overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;
}
.Mhead {width: 100%;height: 22.4vw;position: fixed;left: 0;top: 0;z-index: 888;background-color: #ffffff;
}
.Mhead .Mnavbar {width: 100%;height: 11.73333333vw;padding: 0 3.2vw 0 4.8vw;display: flex;justify-content: space-between;align-items: center;
}
.Mhead .Mnavbar .logo i {color: #fb7299;font-size: 7.46666667vw;
}
.Mhead .right {display: flex;align-items: center;
}
.Mhead .right .search i {color: #ccc;font-size: 5.86666667vw;
}
.Mhead .right .face {width: 6.4vw;height: 6.4vw;margin-left: 5.33333333vw;margin-right: 4vw;
}
.Mhead .right .face img {border-radius: 50%;
}
.Mhead .right .download {width: 19.2vw;height: 6.4vw;
}
.Mhead .ChannelMene {width: 100%;height: 10.66666667vw;display: flex;border-bottom: 1px solid #f3f3f3;
}
.Mhead .ChannelMene .tabs {flex: 1;overflow: hidden;
}
.Mhead .ChannelMene .tabs .TabsList {height: 10.66666667vw;display: flex;
}
.Mhead .ChannelMene .tabs .TabsList a {white-space: nowrap;height: 10.66666667vw;line-height: 10.66666667vw;padding: 0 4.26666667vw;font-size: 3.73333333vw;
}
.Mhead .ChannelMene .tabs .TabsList .line {position: absolute;left: 4.26666667vw;bottom: 0;width: 7.46666667vw;height: 0.53333333vw;background-color: #fb7299;
}
.Mhead .ChannelMene .select {position: relative;z-index: 66;width: 10.66666667vw;height: 10.66666667vw;text-align: center;line-height: 10.66666667vw;
}
.Mhead .ChannelMene .select i {font-size: 5.33333333vw;color: #aaa;
}
.Mbody {margin-top: 22.66666667vw;
}
.Mbody .VideoList {padding: 0px 1.33333333vw;display: flex;flex-wrap: wrap;
}
.Mbody .VideoList a {width: 50%;height: 40.26666667vw;padding: 2.13333333vw 1.33333333vw;
}
.Mbody .VideoList a .pic {position: relative;width: 45.33333333vw;height: 25.86666667vw;
}
.Mbody .VideoList a .pic .count {position: absolute;left: 0;bottom: 0;width: 45.86666667vw;height: 7.2vw;padding: 1.33333333vw 1.6vw;display: flex;justify-content: space-between;align-items: center;
}
.Mbody .VideoList a .pic .count span {font-size: 3.2vw;color: #ffffff;
}
.Mbody .VideoList a .pic .count i {font-size: 3.2vw;
}
.Mbody .VideoList a p {font-size: 3.2vw;color: #212121;margin-top: 1.6vw;
}
.Mfooter {position: fixed;left: 0;bottom: 8vw;width: 100%;height: 9.6vw;
}
.Mfooter .openapp {width: 93.6vw;height: 9.86666667vw;background-color: #fb7299;margin: 0 auto;border-radius: 4.8vw;text-align: center;line-height: 9.86666667vw;font-size: 3.73333333vw;color: #ffffff;
}
.Mfooter .openapp span {margin-left: 2.66666667vw;
}

将素材图片放在一个文件夹里面 : 

 

 

 

 

全局html代码 : 

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>哔哩哔哩 (゜-゜)つロ 干杯~-bilibili</title><!-- 移动端适配 --><meta name="viewport"content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,viewport-fit=cover"><!-- 引入标题图标 --><link rel="shortcut icon" href="./favicon.ico" type="image/x-icon"><!-- 字体图标 --><link rel="stylesheet" href="./fonts/iconfont.css"><!-- 引入首页的css文件 --><link rel="stylesheet" href="./css/index.css">
</head><body><div class="Mhead"><!-- 头部导航栏 --><div class="Mnavbar"><!-- 左边盒子 --><a class="logo"><i class="iconfont Navbar_logo"></i></a><!-- 右边盒子 --><div class="right"><a href="#" class="search"><i class="iconfont ic_search_tab"></i></a><!-- 用户头像 --><a href="#" class="face"><img src="./images/login.png" alt=""></a><!-- 下载 --><div class="download"><img src="./images/download.png" alt=""></div></div></div><!-- 频道列表 --><div class="ChannelMene"><!-- tab栏 --><div class="tabs"><!-- 超大的盒子 --><div class="TabsList"><a href="#">首页</a><a href="#">动画</a><a href="#">番剧</a><a href="#">国创</a><a href="#">音乐</a><a href="#">舞蹈</a><a href="#">游戏</a><a href="#">知识</a><a href="#">科技</a><a href="#">运动</a><!-- 线 --><div class="line"></div></div></div><!-- 下拉框 --><div class="select"><i class="iconfont general_pulldown_s"></i></div></div></div><!-- 内容 --><div class="Mbody"><div class="VideoList"><a href="#"><div class="pic"><img src="./images/1.jpg" alt=""><!-- 计算盒子 --><div class="count"><span><i class="iconfont icon_shipin_bofangshu"></i> 124.3万</span><span><i class="iconfont icon_shipin_danmushu"></i> 185</span></div></div><p class="ellipsis-2">同样是喜欢cosplay的两个人,走到一起不容易,希望这对定制的油纸伞能让你们不忘初心,彼此坚定!</p></a><a href="#"><div class="pic"><img src="./images/1.jpg" alt=""><!-- 计算盒子 --><div class="count"><span><i class="iconfont icon_shipin_bofangshu"></i> 124.3万</span><span><i class="iconfont icon_shipin_danmushu"></i> 185</span></div></div><p class="ellipsis-2">同样是喜欢cosplay的两个人,走到一起不容易,希望这对定制的油纸伞能让你们不忘初心,彼此坚定!</p></a><a href="#"><div class="pic"><img src="./images/1.jpg" alt=""><!-- 计算盒子 --><div class="count"><span><i class="iconfont icon_shipin_bofangshu"></i> 124.3万</span><span><i class="iconfont icon_shipin_danmushu"></i> 185</span></div></div><p class="ellipsis-2">同样是喜欢cosplay的两个人,走到一起不容易,希望这对定制的油纸伞能让你们不忘初心,彼此坚定!</p></a><a href="#"><div class="pic"><img src="./images/1.jpg" alt=""><!-- 计算盒子 --><div class="count"><span><i class="iconfont icon_shipin_bofangshu"></i> 124.3万</span><span><i class="iconfont icon_shipin_danmushu"></i> 185</span></div></div><p class="ellipsis-2">同样是喜欢cosplay的两个人,走到一起不容易,希望这对定制的油纸伞能让你们不忘初心,彼此坚定!</p></a><a href="#"><div class="pic"><img src="./images/1.jpg" alt=""><!-- 计算盒子 --><div class="count"><span><i class="iconfont icon_shipin_bofangshu"></i> 124.3万</span><span><i class="iconfont icon_shipin_danmushu"></i> 185</span></div></div><p class="ellipsis-2">同样是喜欢cosplay的两个人,走到一起不容易,希望这对定制的油纸伞能让你们不忘初心,彼此坚定!</p></a><a href="#"><div class="pic"><img src="./images/1.jpg" alt=""><!-- 计算盒子 --><div class="count"><span><i class="iconfont icon_shipin_bofangshu"></i> 124.3万</span><span><i class="iconfont icon_shipin_danmushu"></i> 185</span></div></div><p class="ellipsis-2">同样是喜欢cosplay的两个人,走到一起不容易,希望这对定制的油纸伞能让你们不忘初心,彼此坚定!</p></a><a href="#"><div class="pic"><img src="./images/1.jpg" alt=""><!-- 计算盒子 --><div class="count"><span><i class="iconfont icon_shipin_bofangshu"></i> 124.3万</span><span><i class="iconfont icon_shipin_danmushu"></i> 185</span></div></div><p class="ellipsis-2">同样是喜欢cosplay的两个人,走到一起不容易,希望这对定制的油纸伞能让你们不忘初心,彼此坚定!</p></a><a href="#"><div class="pic"><img src="./images/1.jpg" alt=""><!-- 计算盒子 --><div class="count"><span><i class="iconfont icon_shipin_bofangshu"></i> 124.3万</span><span><i class="iconfont icon_shipin_danmushu"></i> 185</span></div></div><p class="ellipsis-2">同样是喜欢cosplay的两个人,走到一起不容易,希望这对定制的油纸伞能让你们不忘初心,彼此坚定!</p></a><a href="#"><div class="pic"><img src="./images/1.jpg" alt=""><!-- 计算盒子 --><div class="count"><span><i class="iconfont icon_shipin_bofangshu"></i> 124.3万</span><span><i class="iconfont icon_shipin_danmushu"></i> 185</span></div></div><p class="ellipsis-2">同样是喜欢cosplay的两个人,走到一起不容易,希望这对定制的油纸伞能让你们不忘初心,彼此坚定!</p></a><a href="#"><div class="pic"><img src="./images/1.jpg" alt=""><!-- 计算盒子 --><div class="count"><span><i class="iconfont icon_shipin_bofangshu"></i> 124.3万</span><span><i class="iconfont icon_shipin_danmushu"></i> 185</span></div></div><p class="ellipsis-2">同样是喜欢cosplay的两个人,走到一起不容易,希望这对定制的油纸伞能让你们不忘初心,彼此坚定!</p></a></div></div><!-- 底部 --><div class="Mfooter"><div class="openapp"><i class="iconfont Navbar_logo"></i><span>打开App,看你感兴趣的视频</span></div></div>
</body></html>

最后所展示的布局效果如下 : 

这篇关于关于学习css这件事的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/824064

相关文章

从入门到精通详解LangChain加载HTML内容的全攻略

《从入门到精通详解LangChain加载HTML内容的全攻略》这篇文章主要为大家详细介绍了如何用LangChain优雅地处理HTML内容,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录引言:当大语言模型遇见html一、HTML加载器为什么需要专门的HTML加载器核心加载器对比表二

前端如何通过nginx访问本地端口

《前端如何通过nginx访问本地端口》:本文主要介绍前端如何通过nginx访问本地端口的问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、nginx安装1、下载(1)下载地址(2)系统选择(3)版本选择2、安装部署(1)解压(2)配置文件修改(3)启动(4)

HTML中meta标签的常见使用案例(示例详解)

《HTML中meta标签的常见使用案例(示例详解)》HTMLmeta标签用于提供文档元数据,涵盖字符编码、SEO优化、社交媒体集成、移动设备适配、浏览器控制及安全隐私设置,优化页面显示与搜索引擎索引... 目录html中meta标签的常见使用案例一、基础功能二、搜索引擎优化(seo)三、社交媒体集成四、移动

HTML input 标签示例详解

《HTMLinput标签示例详解》input标签主要用于接收用户的输入,随type属性值的不同,变换其具体功能,本文通过实例图文并茂的形式给大家介绍HTMLinput标签,感兴趣的朋友一... 目录通用属性输入框单行文本输入框 text密码输入框 password数字输入框 number电子邮件输入编程框

HTML img标签和超链接标签详细介绍

《HTMLimg标签和超链接标签详细介绍》:本文主要介绍了HTML中img标签的使用,包括src属性(指定图片路径)、相对/绝对路径区别、alt替代文本、title提示、宽高控制及边框设置等,详细内容请阅读本文,希望能对你有所帮助... 目录img 标签src 属性alt 属性title 属性width/h

CSS3打造的现代交互式登录界面详细实现过程

《CSS3打造的现代交互式登录界面详细实现过程》本文介绍CSS3和jQuery在登录界面设计中的应用,涵盖动画、选择器、自定义字体及盒模型技术,提升界面美观与交互性,同时优化性能和可访问性,感兴趣的朋... 目录1. css3用户登录界面设计概述1.1 用户界面设计的重要性1.2 CSS3的新特性与优势1.

HTML5 中的<button>标签用法和特征

《HTML5中的<button>标签用法和特征》在HTML5中,button标签用于定义一个可点击的按钮,它是创建交互式网页的重要元素之一,本文将深入解析HTML5中的button标签,详细介绍其属... 目录引言<button> 标签的基本用法<button> 标签的属性typevaluedisabled

HTML5实现的移动端购物车自动结算功能示例代码

《HTML5实现的移动端购物车自动结算功能示例代码》本文介绍HTML5实现移动端购物车自动结算,通过WebStorage、事件监听、DOM操作等技术,确保实时更新与数据同步,优化性能及无障碍性,提升用... 目录1. 移动端购物车自动结算概述2. 数据存储与状态保存机制2.1 浏览器端的数据存储方式2.1.

基于 HTML5 Canvas 实现图片旋转与下载功能(完整代码展示)

《基于HTML5Canvas实现图片旋转与下载功能(完整代码展示)》本文将深入剖析一段基于HTML5Canvas的代码,该代码实现了图片的旋转(90度和180度)以及旋转后图片的下载... 目录一、引言二、html 结构分析三、css 样式分析四、JavaScript 功能实现一、引言在 Web 开发中,

CSS place-items: center解析与用法详解

《CSSplace-items:center解析与用法详解》place-items:center;是一个强大的CSS简写属性,用于同时控制网格(Grid)和弹性盒(Flexbox)... place-items: center; 是一个强大的 css 简写属性,用于同时控制 网格(Grid) 和 弹性盒(F