关于学习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

相关文章

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

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

CSS实现元素撑满剩余空间的五种方法

《CSS实现元素撑满剩余空间的五种方法》在日常开发中,我们经常需要让某个元素占据容器的剩余空间,本文将介绍5种不同的方法来实现这个需求,并分析各种方法的优缺点,感兴趣的朋友一起看看吧... css实现元素撑满剩余空间的5种方法 在日常开发中,我们经常需要让某个元素占据容器的剩余空间。这是一个常见的布局需求

CSS Anchor Positioning重新定义锚点定位的时代来临(最新推荐)

《CSSAnchorPositioning重新定义锚点定位的时代来临(最新推荐)》CSSAnchorPositioning是一项仍在草案中的新特性,由Chrome125开始提供原生支持需... 目录 css Anchor Positioning:重新定义「锚定定位」的时代来了! 什么是 Anchor Pos

CSS中的Static、Relative、Absolute、Fixed、Sticky的应用与详细对比

《CSS中的Static、Relative、Absolute、Fixed、Sticky的应用与详细对比》CSS中的position属性用于控制元素的定位方式,不同的定位方式会影响元素在页面中的布... css 中的 position 属性用于控制元素的定位方式,不同的定位方式会影响元素在页面中的布局和层叠关

HTML5 getUserMedia API网页录音实现指南示例小结

《HTML5getUserMediaAPI网页录音实现指南示例小结》本教程将指导你如何利用这一API,结合WebAudioAPI,实现网页录音功能,从获取音频流到处理和保存录音,整个过程将逐步... 目录1. html5 getUserMedia API简介1.1 API概念与历史1.2 功能与优势1.3

全面解析HTML5中Checkbox标签

《全面解析HTML5中Checkbox标签》Checkbox是HTML5中非常重要的表单元素之一,通过合理使用其属性和样式自定义方法,可以为用户提供丰富多样的交互体验,这篇文章给大家介绍HTML5中C... 在html5中,Checkbox(复选框)是一种常用的表单元素,允许用户在一组选项中选择多个项目。本

HTML5 搜索框Search Box详解

《HTML5搜索框SearchBox详解》HTML5的搜索框是一个强大的工具,能够有效提升用户体验,通过结合自动补全功能和适当的样式,可以创建出既美观又实用的搜索界面,这篇文章给大家介绍HTML5... html5 搜索框(Search Box)详解搜索框是一个用于输入查询内容的控件,通常用于网站或应用程

CSS3中的字体及相关属性详解

《CSS3中的字体及相关属性详解》:本文主要介绍了CSS3中的字体及相关属性,详细内容请阅读本文,希望能对你有所帮助... 字体网页字体的三个来源:用户机器上安装的字体,放心使用。保存在第三方网站上的字体,例如Typekit和Google,可以link标签链接到你的页面上。保存在你自己Web服务器上的字

Go学习记录之runtime包深入解析

《Go学习记录之runtime包深入解析》Go语言runtime包管理运行时环境,涵盖goroutine调度、内存分配、垃圾回收、类型信息等核心功能,:本文主要介绍Go学习记录之runtime包的... 目录前言:一、runtime包内容学习1、作用:① Goroutine和并发控制:② 垃圾回收:③ 栈和

html 滚动条滚动过快会留下边框线的解决方案

《html滚动条滚动过快会留下边框线的解决方案》:本文主要介绍了html滚动条滚动过快会留下边框线的解决方案,解决方法很简单,详细内容请阅读本文,希望能对你有所帮助... 滚动条滚动过快时,会留下边框线但其实大部分时候是这样的,没有多出边框线的滚动条滚动过快时留下边框线的问题通常与滚动条样式和滚动行