黑马程序员技术交流社区
标题:
【成都校区】 京东主页移动版笔记一篇,跟着老师思路走
[打印本页]
作者:
晴阳暴打远灯狗
时间:
2019-4-9 14:49
标题:
【成都校区】 京东主页移动版笔记一篇,跟着老师思路走
<!-- header -->
<
header
>
<!-- 思路,header四个部分,分别占百分比,8 10 57 25,用li标签包含 -->
<
ul
>
<
li
>
<
img
src
=
"images/close.png"
alt
=
""
>
</
li
>
<
li
>
<
img
src
=
"images/logo.png"
alt
=
""
>
</
li
>
<
li
>
打开京东App,购物更轻松
</
li
>
<
li
>
立即打开
</
li
>
</
ul
>
</
header
>
<!-- 固定搜索框 -->
<!-- search -->
<
div
class
=
"search-wrap"
>
<!-- 思路,
1,分成三个部分
2,左右两个部,固定宽度,定位保持
3,中间用外边距margin分割,内部再套定位盒子 -->
<
div
class
=
"search-btn"
></
div
>
<
div
class
=
"search"
>
<
div
class
=
"jd"
>
<!-- <img src="images/jd.png" alt=""> -->
</
div
>
<
div
class
=
"sx"
></
div
>
<
input
type
=
"text"
placeholder
=
"小家电超级品类日,每满299减30"
>
<
div
class
=
"fdj"
></
div
>
</
div
>
<
div
class
=
"search-login"
>登录</
div
>
</
div
>
<!-- 滚动栏 -->
<
div
class
=
"banner"
>
<!-- 思路
1.设置图片
2.调整图片大小与屏幕宽度对齐
-->
<
img
src
=
"upload/banner.dpg"
alt
=
""
>
</
div
>
<!-- 家电品类日 -->
<
div
class
=
"plr"
>
<!-- 思路
1.三个a标签
2.宽度分为3份,分别占33.33%,左浮动 -->
<
a
href
=
"#"
>
<
img
src
=
"upload/pic11.dpg"
alt
=
""
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/pic22.dpg"
alt
=
""
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/pic33.dpg"
alt
=
""
>
</
a
>
</
div
>
<!-- nav部分 -->
<
nav
>
<
a
href
=
"#"
>
<
img
src
=
"upload/nav1.webp"
alt
=
""
>
<
span
>京东超市</
span
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/nav1.webp"
alt
=
""
>
<
span
>京东超市</
span
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/nav2.webp"
alt
=
""
>
<
span
>京东超市</
span
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/nav1.webp"
alt
=
""
>
<
span
>京东超市</
span
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/nav1.webp"
alt
=
""
>
<
span
>京东超市</
span
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/nav1.webp"
alt
=
""
>
<
span
>京东超市</
span
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/nav1.webp"
alt
=
""
>
<
span
>京东超市</
span
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/nav1.webp"
alt
=
""
>
<
span
>京东超市</
span
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/nav3.webp"
alt
=
""
>
<
span
>京东超市</
span
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/nav1.webp"
alt
=
""
>
<
span
>京东超市</
span
>
</
a
>
</
nav
>
<!-- news部分 -->
<
div
class
=
"news"
>
<!-- 思路
1.分三部分,50% 25% 25%
2.后两个部分设置左边框
3.设置盒子模式为CSS3盒子 -->
<
a
href
=
"#"
>
<
img
src
=
"upload/new1.dpg"
alt
=
""
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/new2.dpg"
alt
=
""
>
</
a
>
<
a
href
=
"#"
>
<
img
src
=
"upload/new3.dpg"
alt
=
""
>
</
a
>
</
div
>
/* 设置body的属性,最大,最小宽度 */
*
{
margin
:
0
;
}
/* * {
margin: 0;
padding: 0;
} */
body
{
position
:
relative
;
width
:
100
%
;
max-width
:
640
px
;
min-width
:
350
px
;
margin
:
0
auto
;
}
header
{
width
:
100
%
;
height
:
45
px
;
line-height
:
45
px
;
background-color
:
#333
;
text-align
:
center
;
}
img
{
vertical-align
:
middle
;
}
a
{
text-decoration
:
none
;
}
ul
{
padding
:
0
;
}
input
{
border
:
none
;
outline
:
none
;
}
header
ul
li
{
float
:
left
;
list-style
:
none
;
}
header
ul
li
:nth-child
(
1
) {
width
:
8
%
;
}
header
ul
li
:nth-child
(
1
)
img
{
width
:
10
px
;
height
:
10
px
;
}
/* header ul li:nth-child(1)::after {
content: '';
display: block;
width: 10px;
height: 10px;
background: url(../images/close.png) no-repeat;
background-size: 10px 10px;
} */
header
ul
li
:nth-child
(
2
) {
width
:
10
%
;
}
header
ul
li
:nth-child
(
2
)
img
{
width
:
30
px
;
height
:
30
px
;
}
header
ul
li
:nth-child
(
3
) {
width
:
57
%
;
text-align
:
center
;
color
:
#fff
;
}
header
ul
li
:nth-child
(
4
) {
width
:
25
%
;
background-color
:
orangered
;
text-align
:
center
;
color
:
#fff
;
}
/* search-wrap */
.search-wrap
{
position
:
fixed
;
/* 设置为固定定位后,要设置最大最小宽度,否则,宽度会与整个浏览器对齐 */
max-width
:
640
px
;
min-width
:
350
px
;
width
:
100
%
;
height
:
44
px
;
overflow
:
hidden
;
}
.search-btn
,
.search-login
{
position
:
absolute
;
top
:
0
;
width
:
40
px
;
height
:
40
px
;
line-height
:
40
px
;
}
.search-btn
{
left
:
0
;
}
.search-btn::after
{
content
:
''
;
display
:
block
;
width
:
20
px
;
height
:
18
px
;
margin
:
14
px
0
0
14
px
;
background
:
url
(
../images/s-btn.png
)
no-repeat
;
background-size
:
20
px
18
px
;
}
.search-login
{
right
:
0
;
margin-right
:
5
px
;
color
:
#fff
;
}
.search
{
position
:
relative
;
margin
:
0
50
px
;
height
:
30
px
;
margin-top
:
7
px
;
background-color
:
#fff
;
border-radius
:
20
px
;
}
/*
.jd img {
width: 20px;
} */
.jd::after
{
content
:
''
;
display
:
block
;
position
:
absolute
;
top
:
8
px
;
left
:
13
px
;
width
:
20
px
;
height
:
20
px
;
background
:
url
(
../images/jd.png
)
no-repeat
;
background-size
:
20
px
;
}
/* 小竖线 */
.sx
{
position
:
absolute
;
top
:
6
px
;
left
:
40
px
;
width
:
1
px
;
height
:
20
px
;
background-color
:
#ccc
;
}
/* 放大镜 */
.fdj
{
/* 二倍精灵图思路,精灵图首先在firework等比缩小一半,再找相应图片 */
position
:
absolute
;
top
:
8
px
;
left
:
50
px
;
width
:
20
px
;
height
:
18
px
;
background
:
url
(
../images/jd-sprites.png
)
no-repeat
-81
px
0
;
background-size
:
200
px
;
}
/* 收缩框 */
.search
input
{
position
:
absolute
;
top
:
5
px
;
left
:
75
px
;
width
:
73
%
;
}
/* banner */
.banner
img
{
width
:
100
%
;
}
/* 家电品类日 */
.plr
a
{
float
:
left
;
width
:
33.33
%
;
}
.plr
a
img
{
width
:
100
%
;
}
/* nav部分 */
nav
a
{
float
:
left
;
width
:
20
%
;
margin
:
10
px
0
;
text-align
:
center
;
}
nav
a
img
{
width
:
40
px
;
}
nav
a
span
{
display
:
block
;
color
:
#333
;
}
/* news部分 */
.news
{
width
:
100
%
;
}
.news
a
{
float
:
left
;
/* 加边框后,盒子撑大,加css3盒子 */
box-sizing
:
border-box
;
}
.news
a
:nth-child
(
1
) {
width
:
50
%
;
}
.news
a
:nth-child
(
n+2
) {
width
:
25
%
;
border-left
:
1
px
solid
#ccc
;
}
.news
a
img
{
width
:
100
%
;
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2