
1.項目準備
1.1 項目目錄
網(wǎng)站根目錄
是指存放網(wǎng)站的第一層
文件夾,內(nèi)部包含當(dāng)前網(wǎng)站的所有素材
,包含HTML、CSS、圖片、JavaScript等等。
- 項目文件夾(如study)
-
images
文件夾:存放固定使用
的圖片素材,例如: logo、樣式修飾圖等等 -
uploads
文件夾:存放非固定使用
的圖片素材,例如:商品圖、宣傳圖需要上傳的圖片 -
css
文件夾:存放CSS 文件(link
標簽引入)-
base.css
:基礎(chǔ)公共樣式,例如:清除默認樣式、設(shè)置網(wǎng)頁基本樣 -
index.css
:首頁CSS樣式
-
-
index.html
:首頁HTML文件
-
項目文件夾拖拽到vscode里即可開始項目
網(wǎng)頁制作思路
1??布局思路:先整體再局部,從外到內(nèi),從上到下,從左到右
2??CSS 實現(xiàn)思路
??1.畫盒子,調(diào)整盒子范圍→寬高背景色
??2.調(diào)整盒子位置→flex布局、內(nèi)外邊距
??3.控制圖片、文字內(nèi)容樣式
2.頭部區(qū)域
2.1 頭部區(qū)域布局
通欄:寬度與瀏覽器窗口相同的盒子
標簽結(jié)構(gòu):通欄>版心> logo+導(dǎo)航+搜索+用戶
2.2 logo制作
logo功能:
單擊跳轉(zhuǎn)到首頁
-
搜索引擎優(yōu)化
:提升網(wǎng)站百度搜索排名
實現(xiàn)方法:
- 標簽結(jié)構(gòu):h1 > a>網(wǎng)站名稱(搜索關(guān)鍵字).
- CSS樣式:
logo a {
display: block;
width: 195px;
height: 41px;
background-image: ur1(../images/logo.png);
/*隱藏文字*/
font-size: 0;
<!-- logo -->
<div class="logo">
<h1><a href="#">學(xué)成在線</a></h1>
</div>
2.2 導(dǎo)航制作技巧(nav)
導(dǎo)航功能
- 單擊跳轉(zhuǎn)頁面
實現(xiàn)方法:
-
標簽結(jié)構(gòu);ul> li* 3 >a
-
優(yōu)勢:避免堆砌a標簽,網(wǎng)站搜索排名降級
-
布局思路
- li設(shè)置右側(cè)margin
- a設(shè)置左右padding
2.3搜索區(qū)域(search)
實現(xiàn)方法:
- 標簽結(jié)構(gòu): .search > input + a / button
CSS代碼文章來源:http://www.zghlxwxcb.cn/news/detail-832765.html
<style>
.search{
display: flex;
margin-left: 64px;
width: 412px;
height: 40px;
background-color: #f3f5f7;
border-radius: 20px;
padding-left: 19px;
padding-right: 12px;
}
.search input{
flex: 1;
border: 0;
background-color: transparent;
/* 去掉表單控件的焦點框 */
outline: none;
}
/*::placeholder選中就是 placeholder屬性文字樣式 */
.search input::placeholder{
font-size: 14px;
color: #999;
}
.search a {
align-self: center;
width: 16px;
height: 16px;
background-image: url(../images/search.png);
}
</style>
2.3用戶區(qū)域(user區(qū)域)
實現(xiàn)方法:
- 標簽結(jié)構(gòu): .user > a > img + span
CSS代碼
<style>
.user{
margin-left: 32px;
margin-top: 4px;
}
.user img{
/* vertical-align行內(nèi)塊和行內(nèi)垂直方向?qū)R方式 */
vertical-align: middle;
margin-right: 7px;
}
.user span{
font-size: 16px;
color: #666;
}
</style>
3.banner區(qū)域
3.1 總體布局
一個通欄+版心居中+背景圖+左右兩個盒子
CSS代碼
<style>
.banner{
width: 1920px;
height: 420px;
background-color: #0092cb;
}
.banner .wrapper {
display: flex;
justify-content: space-between;
height: 420px;
background-image: url(../uploads/banner.png);
}
</style>
3.2 左側(cè)側(cè)導(dǎo)航(left)
實現(xiàn)方法:
- 標簽結(jié)構(gòu):.left > ul > li*9 >a
- 布局思路
a默認狀態(tài):背景圖為白色右箭頭
CSS代碼
<style>
.banner .left{
padding: 3px 20px;
height: 420px;
width: 191px;
background-color: rgba(0,0,0,0.42);
}
.banner .left a{
display: block;
line-height: 46px;
height: 46px;
background: url(../images/right.png) no-repeat right center;
font-size: 16px;
color: #fff;
}
.banner .left a:hover{
background-image: url(../images/right-hover.png);
color: #00a4ff;
}
</style>
3.3 右側(cè)課程表(left)
實現(xiàn)方法:
- 標簽結(jié)構(gòu): .right > h3+.content
CSS代碼
<style>
.banner .right{
margin-top: 60px;
width: 218px;
height: 305px;
background-color: #209dd5;
border-radius: 10px;
}
.banner .right h3{
margin-right: 14px;
height: 48px;
line-height: 48px;
font-size: 15px;
color: #fff;
font-weight: 400;
}
.banner .right .content{
padding: 14px;
height: 257px;
background-color: #fff;
border-radius: 10px;
}
.banner .right dl{
margin-bottom: 12px;
border-bottom: 1px solid #e0e0e0;
}
.banner .right dt{
margin-bottom: 8px;
font-size: 14px;
line-height: 20px ;
font-weight: 700;
}
.banner .right dd{
margin-bottom: 8px;
font-size: 12px;
line-height: 16px;
}
.banner .right dd .span1{
color: #00a4ff;
}
.banner .right dd .span2{
color: #7d7d7d;
font-weight: 400;
}
.banner .right a{
display: block;
width: 190px;
height: 32px;
background-color: #00a4ff;
text-align: center;
line-height: 32px;
border-radius: 15px;
font-size: 14px;
color: #fff;
}
</style>
4.精品推薦區(qū)域(recommend)
實現(xiàn)方法:
標簽結(jié)構(gòu):.recommend > h3+ ul+ a.modify
CSS代碼
<style>
.recommend{
display: flex;
margin-top: 11px;
padding: 0px 20px;
height: 60px ;
width: 1200px;
line-height: 60px;
background-color: #fff;
box-shadow: 0px 1px 2px 0px rgba(211,211,211, 0.5);
}
.recommend h3{
font-size: 18px;
color: #00a4ff;
font-weight: 400;
}
.recommend ul{
/* 除去標題和修改興趣的尺寸,父級剩余尺寸都給ul. */
display: flex;
flex: 1;
}
.recommend ul li a{
padding: 0 24px;
border-right: 1px solid #e0e0e0;
font-size: 18px;
}
.recommend ul li:last-child a{
border-right: 0;
}
.recommend .modify{
font-size: 16px;
color: #00a4ff;
}
</style>
5.精品課程( course)
實現(xiàn)方法:
標簽結(jié)構(gòu):.hd +.bd
布局思路:盒子模型
CSS代碼
<style>
.course{
margin-top: 15px;
}
.hd{
display: flex;
justify-content: space-between;
height: 60px;
line-height: 60px;
}
.hd h3{
font-size: 21px;
font-weight: 400;
}
.hd .more{
background: url(../images/more.png) no-repeat right center;
padding-right: 20px;
font-size: 14px;
color: #999;
}
.bd ul{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.bd li{
margin-bottom: 14px;
width: 228px;
height: 271px;
background-color: palevioletred;
}
.bd li .pic{
height: 156px;
}
.bd li .text{
padding: 20px;
height: 115px;
background-color: #fff;
}
.bd li .text h4{
margin-bottom: 13px;
height: 40px;
font-size: 14px;
line-height: 20px;
font-weight: 400;
}
.bd li .text p{
font-size: 14px;
line-height: 20px;
color: #999;
}
.bd li .text p span{
color: orange;
}
.bd li .text p i{
font-style: normal;
}
</style>
6.前端開發(fā)工程師區(qū)域
CSS代碼
<style>
.hd ul{
display: flex;
}
.hd li{
margin-right: 60px;
font-size: 16px;
}
.hd li .active,.hd li a:hover{
color: #00a4ff;
}
.bd{
display: flex;
justify-content: space-between;
}
.bd .left{
width: 228px;
background-color: #f3f5f7;
}
.bd .right{
width: 957px;
background-color: #f3f5f7;
}
</style>
7.版權(quán)區(qū)域
左右分為2部分 左邊分為3部分 右邊用dt dd寫
CSS代碼
<style>
.footer {
margin-top: 60px;
padding-top: 60px;
height: 273px;
background-color: #fff;
}
.footer .wrapper{
display: flex;
justify-content: space-between;
}
.footer .left{
width: 440px;
background-color: #fff;
}
.footer .left p{
margin-top: 24px;
margin-bottom: 14px;
font-size: 12px;
line-height: 17px;
color: #666;
}
.footer .left .download{
display: block;
width: 120px;
height: 36px;
border: 1px solid #00a4ff;
text-align: center;
line-height: 34px;
font-size: 16px;
color: #00a4ff;
}
.footer .right{
display: flex;
}
.footer .right dl{
margin-left: 130px;
}
.footer .right dt{
margin-bottom: 12px;
font-size: 16px;
line-height: 23px;
}
.footer .right a{
font-size: 14px;
color: #666;
line-height: 24px;
}
</style>
完整代碼單獨展示在github中
前端小項目-學(xué)成在線文章來源地址http://www.zghlxwxcb.cn/news/detail-832765.html
到了這里,關(guān)于【前端實戰(zhàn)小項目】學(xué)成在線網(wǎng)頁制作的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!