网页制作之HTML+CSS布局

CSS网页布局:

可以分为三种:1.固定布局  

2.流动布局 (是百分百布局)

 3.弹性布局(可用于移动APP开发)

元素基本样式:

1.行内样式:直接写在部分的标签里面

 
     每满千减百

2.内嵌样式 :写在部分,用标签包起来




    
    淘宝
    

3.外部样式:是在CSS写入样式,在html的部分用标签链接,注意地址一定要写正确,否则链接无效。




    
    京东
    
    

元素的样式可以混合使用 

图片标签

图像标签是自闭和标签,写法

图像标签的实现路径有三种:1.相对路径    2.绝对路径    3.远程路径

定位

定位分为三种:1.相对定位(占位置)

                            2.绝对定位(不占位置)

                            3.固定定位

相对定位和绝对定位使用较多,并且两者可以混合使用,一般是将绝对定位套进相对定位中使用,即给父元素使用相对定位,给子元素使用绝对定位。

搜索框

直接用标签表示

悬停伪类

用属性:hover表示,当鼠标放置需要悬停的文字或图片上时,会显示出所设置的属性样式,如字体颜色,子集,背景色等等

这里我们以固定布局,外部样式为例,以京东部分网页为模板来展示

html部分展示如下


CSS部分 

.two{
    position: relative;
    width: 1190px;
    height: 140px;
    margin: 0 auto;
}
.img{
    position: absolute;
    margin-top: -60px;
    width: 190px;
    height: 170px;
    background-color: white;
    background-size: 190px 170px;
    box-shadow: 0px -5px 15px silver;
    border-bottom: 1px solid silver;
}
.two_center{
    position: relative;
    margin-left: 320px;
    margin-top: 30px;
    width: 550px;
    height: 60px;
}
.two_center1{
    position: absolute;
    width: 550px;
    height: 35px;
    background-color: white;
}
.two_center1>input{
    width: 450px;
    height: 35px;
    outline: none;
    border-style: none;
    padding-left: 5px;
}
.two_center11{
    position: absolute;
    width: 40px;
    height: 35px;
    right: 60px;
    text-align: center;
    line-height: 35px;
}
.two_center11>i{
    font-size: 25px;
    color: #696969;
}
.two_center11>i:hover{
    color: red;
}
.two_center12{
    position: absolute;
    right: 0;
    width: 60px;
    height: 35px;
    text-align: center;
    line-height: 35px;
    background-color: #ff0000;
}
.two_center12>i{
    font-size: 25px;
    color: white;
}
.two_center2{
    display: inline-block;
    margin-top: 35px ;
    width: 550px;
    height: 25px;
}
.two_center2>span{
    margin-right: 6px;
    line-height: 25px;
    text-align: center;
    font-size: 12px;
}
.two_center2>span>a{
    text-decoration: none;
    color: #ababab;
}
.two_center2>span>a:hover{
    color: red;
}
.two_center3{
    margin-top: 30px;
    margin-left: 230px;
}
.two_center3>span {
    padding-right: 20px;
    font-size: 14px;
}
.two_center3>span a{
    text-decoration: none;
    color: black;
}
.two_center3>span a:hover{
    color: red;
}
.shuxian{
    display: inline-block;
    height: 10px;
    width: 1px;
    border-left: 1px solid #9b9b9b;
}
.two_right{
    position: absolute;
    margin-left: 580px;
    top: 0px;
    left: 0px;
    z-index: 10;
    width: 188px;
    height: 33px;
    border: 1px solid silver;
    background-color: white;
    text-align: center;
    line-height: 33px;
    font-size: 13px;
    color: #ff426f;
}
.two_right>i{
    font-size: 18px;
    margin-left: 5px;
}
.shuzi{
    position: relative;
    display: inline-block;
    top: -8px;
    width: 12px;
    height: 15px;
    border-radius: 50%;
    color: white;
    background-color: red;
    line-height: 15px;
    text-align: center;
}

需要注意的是,在保存文件的时候要注意路径是否一致,否则图片加载不出来,或者会出现样式混乱的情况。

你可能感兴趣的:(网页制作之HTML+CSS布局)