目录
一、问题分析及解决办法
二、重点总结
三、完整代码
四、最终效果
一、问题分析及解决办法
问题产生原因:在编写代码时没有给包裹文本的父盒子设置宽度,导致当浏览器页面缩小到一定程度时(即父盒子宽度缩小到一定程度),文本内容因为父盒子宽度不够而被挤到下一行排列显示。
解决办法:给包裹文本的父盒子设置宽度(即网页版心宽度)。
二、重点总结
1、头部如何布局
第一步 设置头部版心宽度;
第二步 将头部分成两个部分,一个左浮动和另一个右浮动。
2、版心横幅、登录区如何布局?
先给横幅(绿色线)设置宽度(版心宽度)和高度,然后设置横幅背景图片;
最后,给登录模块(蓝色线)设置右浮动 即可贴在版心右侧。
三、完整代码
* {
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
}
.w {
width: 990px;
margin: 0 auto;
}
header {
height: 80px;
}
header li:first-of-type {
float: left;
}
header li:last-of-type {
float: right;
}
h1 {
float: left;
margin-top: 10px;
}
header p {
float: left;
margin: 30px 0 0 20px;
}
a>i {
display: inline-block;
vertical-align: middle;
width: 18px;
height: 14px;
background: url(./images/q-icon.png) no-repeat;
margin-right: -1px;
}
header li:last-of-type a {
position: relative;
top: 48px;
color: #999;
font-size: 12px;
font-family: "\5b8b\4f53";
}
header li>a:hover {
color: #E4393C;
text-decoration: underline;
}
/* 主体区 */
main>section {
height: 39px;
line-height: 39px;
background-color: #FFF8F0;
}
main>section>p {
font-size: 12px;
color: #999;
text-align: center;
font-family: "\5b8b\4f53";
}
.iconfont {
vertical-align: middle;
font-size: 23px;
}
main>p>a {
color: #333;
}
main>section>p>a:hover {
color: #333;
}
/* 中间红色区 */
main>div {
height: 475px;
background-color: #e93854;
}
.banner {
height: 475px;
background: url(./images/background.png) no-repeat;
}
.banner>article {
float: right;
width: 346px;
margin-top: 10px;
background-color: white;
}
article>p {
height: 39px;
line-height: 39px;
color: #999;
font-size: 12px;
text-align: center;
font-family: "\5b8b\4f53";
background-color: #FFF8F0;
}
article>ul {
height: 54px;
line-height: 54px;
border-bottom: 1px solid #F4F4F4;
}
article ul>li {
float: left;
}
article ul>li>a {
display: inline-block;
width: 172px;
font-size: 18px;
line-height: 18px;
text-align: center;
}
article ul>li:first-child>a {
border-right: 1px solid #F4F4F4;
color: #666666;
}
article ul>li:last-child>a {
color: #e4393c;
font-weight: 700;
}
article ul>li>a:hover {
text-decoration: none;
color: #E4393C;
font-weight: 700;
}
/* 表单form */
#loginname,
#pwd {
width: 267px;
height: 40px;
box-sizing: border-box;
border: 1px solid #BBBBBB;
outline: none;
text-indent: 12px;
}
form p>label>span {
display: inline-block;
vertical-align: middle;
width: 40px;
height: 40px;
background-color: red;
box-sizing: border-box;
border: 1px solid #BBBBBB;
margin-right: -6px;
}
form p:first-child {
margin: 33px 0 20px 20px;
}
form p:first-child>label>span {
background: url(./images/pwd-icons-new.png) no-repeat;
}
form p:nth-child(2) {
margin-left: 20px;
}
form p:nth-child(2)>label>span {
background: url(./images/pwd-icons-new.png) no-repeat -48px 0;
}
form p:nth-child(3)>a {
float: right;
font-size: 12px;
color: #666666;
margin: 20px 21px 21px 0;
}
form p:nth-child(3)>a:hover {
color: #E4393C;
text-decoration: underline;
}
/* 红色长条“登录” */
form p:nth-child(4)>a {
display: inline-block;
width: 305px;
height: 30px;
line-height: 30px;
margin: 0 0 31px 21px;
text-align: center;
border: 2px solid #e85356;
background-color: #e4393c;
font-size: 20px;
color: white;
}
form p:nth-child(4)>a:active {
border: 2px solid #4D90FE;
}
form p:nth-child(4)>a:hover {
text-decoration: none;
}
/* qq 微信 */
section {
height: 50px;
line-height: 50px;
border-top: 1px solid #F4F4F4;
}
section a {
font-size: 12px;
color: #666666;
}
section>a:first-child>i {
width: 19px;
height: 18px;
background: url(./images/QQ-weixin.png);
margin: -4px 2px 0 21px;
}
/* qq、微信中间竖线 */
section>.line {
color: #ccc;
font-size: 12px;
padding: 0 6px;
}
section>a:nth-of-type(2)>i {
margin: -4px 2px 0 0;
width: 19px;
height: 18px;
background: url(./images/QQ-weixin.png) no-repeat -19px 0;
}
section>a:nth-of-type(3) {
float: right;
margin-right: 21px;
font-size: 14px;
color: #B61D1D;
}
section>a:nth-of-type(3)>i {
width: 16px;
height: 16px;
background: url(./images/pwd-icons-new.png) no-repeat -104px -75px;
margin-top: -4px;
}
/* 底部 */
footer>div {
font-size: 12px;
color: #666;
text-align: center;
}
.links {
margin: 21px 0 14px 0;
}
.links>a {
margin: 0 9px;
color: #666666;
}
a:hover {
color: #E4393C;
text-decoration: underline;
}
依据《网络安全法》,为保障您的账户安全和正常使用,请尽快完成手机号验证! 新版
href="#">《京东隐私政策》
Copyright © 2004-2022 京东JD.com 版权所有
四、最终效果
友情链接:
Copyright © 2022 卡塔尔世界杯排名_98世界杯决赛 - dylfjc.com All Rights Reserved.