效果圖:
非常的簡(jiǎn)單赊抖,基礎(chǔ)乙嘀,主要使div進(jìn)行布局,需要考慮的是div內(nèi)文字的水平垂直居中,間斷的border-bottom
文字在div中水平居中一般就是text-align:center
而在垂直方向岳链,比較常用的是行高與盒子高度相同就能使內(nèi)部文字居中,不過(guò)是偽居中萌焰,還有一種居中是給盒子設(shè)置上或下的內(nèi)邊距padding,然后調(diào)整盒子的大小捧杉,使得padding的高度加上當(dāng)前盒子的高度加內(nèi)容高度等于原盒子高度
要達(dá)到間斷的下橫線,盒子增加一個(gè)margin,
<style>
*{
padding: 0;
margin: 0;
}
.courseList{
width: 300px;
height: auto;
border: 2px solid #ccc;
margin: 50px auto;
}
.courseList .course-title{
width: 100%;
height: 110px;
text-align: center;
background-color: #ddd;
padding-top: 70px;
}
.courseList .course-title h2{
font-size: 30px;
font-weight: bold;
color: crimson;
}
.courseList .courseItem{
margin: 0 20px;
border-bottom: 1px solid #ddd;
padding: 10px 5px 5px 5px;
line-height: 1.5em;
}
.courseList .courseItem span{
color: teal;
font-size: 16px;
}
.courseList .courseItem:last-child{
border-bottom: none;
}
.courseList .courseItem p:hover{
text-decoration: underline;
color: orange;
}
</style>
</head>
<body>
<div class="courseList">
<div class="course-title">
<h2>課程列表</h2>
</div>
<div class="courseItem">
<p>python入門(mén)與進(jìn)階</p>
<span>388元</span>
</div>
<div class="courseItem">
<p>javascript面試寶典</p>
<span>148元</span>
</div>
<div class="courseItem">
<p>安卓開(kāi)發(fā)必知必會(huì)</p>
<span>228元</span>
</div>
</div>