7.26 web前端-淘宝首页设计2

本文详细介绍了如何使用CSS层叠样式表对淘宝网页进行布局和样式设计,包括头部导航栏的下拉框实现,以及搜索栏的布局技巧。通过设置定位、浮动、边框和颜色等属性,实现了复杂界面的美化和交互效果。讲解了如header、ul、li、a、select、input、button等元素的样式应用,并提供了相应的代码示例。
摘要由CSDN通过智能技术生成

hello大家好,今天我来继续说说淘宝网页设计的后面部分,css层叠样式表的部分,在html写好后,界面是十分简洁的,无法实现任何布局,如下图所示:

 这时候我们需要给其施加层叠样式表用来排列布局,才能达到最终成品图效果,下面我们分成三个部分来写css层叠样式表:

1.头部

可以参照一下昨天发的html部分的代码,首先最简单的就是给两个在hbox中的ul盒子左浮动,让他们保证在上面header最大的一个盒子里面,然后给ul中的li设置左浮动,使其成为一行代码,再对其内容字体进行布局调整,头部的难点是导航栏部分有下拉框.

类似这种的下拉框后面一共有五个,这里我们用到的是定位相关的知识和overflow:hidden的相关知识, 在每个有下拉菜单的地方设置一个单独的盒子,吧内容用p标签包含在内部,设置好样式,第一个这种带滚动条的用到了overflow-y: scroll;然后给这个单独盒子的父元素设置一个相对定位,给每个盒子设定一个绝对定位,通过调整top值和left值来确定盒子最终所在的位置,然后给其高度设置为0,设定一个隐藏超出部分的overflow:hidden,然后设置一个hover,让鼠标移到上面下拉框的时候,给这个盒子一个高度值,就可以了,具体的头部css样式代码如下:

header {
  width: 100%;
  height: 36px;
  background-color: rgb(245, 245, 245);
}
li {
  list-style: none;
}
ul {
  padding-left: 0;
  margin: 0 0 0 0;
}
.hbox a {
  text-decoration: none;
  color: black;
  font-size: 12px;
  margin-left: 8px;
}
a:hover {
  color: red;
}
.hbox {
  height: 36px;
  width: 1210px;
  margin: 0 auto;
}
.hu1 {
  width: 370px;
  height: 36px;
  float: left;
}
.hu2 {
  position: relative;
  width: 580px;
  height: 36px;
  float: right;
}
.hu1 > li {
  float: left;
  height: 36px;
  line-height: 36px;
  width: 20%;
}
.hu2 > li {
  float: left;
  height: 36px;
  line-height: 36px;
  width: 13%;
}
.hbox p {
  font-size: 12px;
  margin: 0 0 0 0;
  padding-left: 8px;
}
header p:hover {
  background-color: rgb(244, 244, 244);
}
.hu2 p {
  height: 36px;
  line-height: 36px;
}

.hsbox1 {
  position: absolute;
  width: 270px;
  background-color: rgb(255, 255, 255);
  top: 36px;
  height: 0;
  overflow: hidden;
}
.hl1:hover + .hsbox1 {
  height: 200px;
  overflow-y: scroll;
}
.hsbox1:hover {
  height: 200px;
  overflow-y: scroll;
}
.hsbox1 > p {
  height: 36px;
  line-height: 36px;
}
.hsbox2 {
  position: absolute;
  width: 85px;
  background-color: rgb(255, 255, 255);
  top: 36px;
  height: 0;
  overflow: hidden;
}
.hl2:hover + .hsbox2 {
  height: 72px;
}
.hsbox2:hover {
  height: 72px;
}
.hsbox3 {
  position: absolute;
  width: 85px;
  background-color: rgb(255, 255, 255);
  top: 36px;
  left: 155px;
  height: 0;
  overflow: hidden;
}
.hl3:hover + .hsbox3 {
  height: 72px;
}
.hsbox3:hover {
  height: 72px;
}
.hsbox4 {
  position: absolute;
  width: 85px;
  background-color: rgb(255, 255, 255);
  top: 36px;
  left: 380px;
  height: 0;
  overflow: hidden;
}
.hl4:hover + .hsbox4 {
  height: 216px;
}
.hsbox4:hover {
  height: 216px;
}
.hsbox5 {
  position: absolute;
  width: 85px;
  background-color: rgb(255, 255, 255);
  top: 36px;
  left: 476px;
  height: 0;
  overflow: hidden;
}
.hl5:hover + .hsbox5 {
  height: 144px;
}
.hsbox5:hover {
  height: 144px;
}
.cebianlan {
  position: fixed;
  right: 0;
  top: 300px;
  width: 60px;
  height: 295px;
  border-top-left-radius: 20px;
  border-bottom-left-radius: 20px;
  background-color: #fff;
}
.cebianlan ul {
  list-style: none;
  margin-top: 25px;
}
.cebianlan li {
  width: 60px;
  height: 56px;
  margin-top: -10px;
  padding-top: 10px;
  text-align: center;
  margin-bottom: 10px;
}
.cebianlan ul a {
  text-decoration: none;
  color: #333;
}
.cebianlan li i {
  display: block;
  width: 60px;
  height: 24px;
  font-size: 23px;
  padding-bottom: 5px;
}
.cebianlan ul a span {
  font-size: 12px;
  display: block;
  width: 60px;
  height: 17px;
  margin-top: 3px;
}

2.搜索栏

搜索栏部分相对来说比较容易,用一个大盒子包裹着三个中盒子,然后给三个中盒子都左浮动 ,第一个盒子放淘宝的商标调整位置,最后一个盒子放二维码,中间的一个盒子再分为上下两个小盒子,因为上面搜索框的外边框需要用一个小盒子的边框border线做出来,这里用到的知识有选择框select和搜索框input,以及搜索按钮button,然后下面一个小盒子很简单,使用ul列表,给li左浮动,最后给整体设置偏移量微调一下就可以了,这一部分的css层叠样式表的代码如下:

.tsbox2 > a {
  font-size: 12px;
  color: black;
  text-decoration: none;
}
.tmbox2 > a:hover {
  color: red;
}
.topbox {
  width: 100%;
  height: 122px;
}
.tbbox {
  width: 1190px;
  height: 90px;
  margin: 0 auto;
  padding-top: 24px;
}
.tmbox1,
.tmbox2,
.tmbox3 {
  float: left;
}
.tsbox1 {
  background-color: white;
  padding-left: 12px;
  width: 738px;
  height: 40px;
  border: 2px solid rgb(255, 80, 0);
  border-radius: 20px;
  line-height: 38px;
}
.tsbox1 > select {
  border: 1px solid white;
}
#shurukuang {
  border: 0px;
}
#sousuo {
  width: 74px;
  height: 36px;
  background-color: rgb(255, 107, 0);
  border-radius: 20px;
  border: 0;
}
.tsbox2 {
  margin-left: 20px;
}
.tmbox1 {
  margin-top: -10px;
  margin-left: 50px;
  width: 15%;
}
.tmbox2 {
  margin-top: 18px;
  width: 70%;
}
.tmbox3 {
  margin-top: -8px;
  width: 10%;
}
.tsbox2 > a {
  display: inline-block;
  color: rgb(102, 102, 102);
  margin-left: 8px;
  padding-top: 8px;
}
.tsbox2 > a:hover {
  color: rgb(255, 68, 0);
}
#shurukuang {
  outline: none;
}
select {
  outline: none;
}

这两段的代码量还好,不是很多,希望大家可以配合昨天的文章观看一下,仔细理解每一个标签的意义和用法,这两部分内容做完,上半部分的内容就搞定了,那么今天就先说到这里,明天我会继续把这个项目说完,包含最重要最后的主体部分和轮播图以及侧边固定栏等知识,希望大家多多捧场,谢谢大家!

(ps:想要完整源码文件的朋友给个关注和动动你的小手点个攒,私聊我发送给你哦~)

  • 47
    点赞
  • 51
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
以下是求解多元多项式回归的 MATLAB 代码: ```matlab % 输入数据 x1 = [36.4 37.2 37.2 36.2 31.5 28.9 27.2 26.7 26.1 26.1 25.4 25.3 25.4]'; x2 = [50.0 52.0 49.0 51.0 68.0 74.0 83.0 82.0 88.0 88.0 90.0 88.0 87.0]'; x3 = [982.9 982.2 981.8 981.6 982.3 982.6 983.4 983.5 984.0 983.6 984.4 984.5 984.4]'; y = [-7.30 -7.36 -7.35 -7.33 -7.31 -7.30 -7.26 -7.22 -7.21 -7.23 -7.18 -7.17 -7.14]'; % 构建设计矩阵X X = [ones(size(x1)) x1 x2 x3 x1.^2 x1.*x2 x1.*x3 x2.^2 x2.*x3 x3.^2]; % 求解回归系数 beta = X \ y; % 构建预测模型 model = @(x1,x2,x3) beta(1) + beta(2)*x1 + beta(3)*x2 + beta(4)*x3 ... + beta(5)*x1.^2 + beta(6)*x1.*x2 + beta(7)*x1.*x3 ... + beta(8)*x2.^2 + beta(9)*x2.*x3 + beta(10)*x3.^2; % 预测并绘制拟合图 x1fit = min(x1):0.1:max(x1); x2fit = min(x2):0.1:max(x2); x3fit = min(x3):0.1:max(x3); [X1FIT,X2FIT,X3FIT] = meshgrid(x1fit,x2fit,x3fit); YFIT = model(X1FIT,X2FIT,X3FIT); figure; plot3(x1,x2,x3,'o',x1fit,x2fit,x3fit,'*'); hold on; mesh(X1FIT,X2FIT,X3FIT,YFIT); xlabel('x1'); ylabel('x2'); zlabel('x3'); title('拟合图'); % 绘制残差图 YFIT = model(x1,x2,x3); figure; plot(YFIT - y,'o'); xlabel('样本编号'); ylabel('残差'); title('残差图'); ``` 运行上述代码后,会先绘制拟合图,然后绘制残差图。拟合图中,蓝色的点表示原始数据,红色的点表示拟合值,可以看到拟合值与原始数据比较接近;残差图中,横轴表示样本编号,纵轴表示残差,残差的分布应该比较均匀,没有明显的规律。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

执笔绘江山

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值