在页面中引入jquery和bootstrap相关文件。
1 2 3 4 | < link href = "css/bootstrap.min.css" rel = "stylesheet" > < link href = "css/font-awesome.min.css" rel = "stylesheet" > < script src = "js/jquery.min.js" ></ script > < script src = "js/bootstrap.min.js" ></ script > |
HTML结构
该CSS3垂直手风琴的HTML结构如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | < div class = "container" > < div class = "row" > < div class = "col-md-offset-3 col-md-6" > < div class = "panel-group" id = "accordion" role = "tablist" aria-multiselectable = "true" > < div class = "panel panel-default" > < div class = "panel-heading" role = "tab" id = "headingOne" > < h4 class = "panel-title" > < a role = "button" data-toggle = "collapse" data-parent = "#accordion" href = "#collapseOne" aria-expanded = "true" aria-controls = "collapseOne" > Section 1 </ a > </ h4 > </ div > < div id = "collapseOne" class = "panel-collapse collapse in" role = "tabpanel" aria-labelledby = "headingOne" > < div class = "panel-body" > < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. </ p > </ div > </ div > </ div > < div class = "panel panel-default" > < div class = "panel-heading" role = "tab" id = "headingTwo" > < h4 class = "panel-title" > < a class = "collapsed" role = "button" data-toggle = "collapse" data-parent = "#accordion" href = "#collapseTwo" aria-expanded = "false" aria-controls = "collapseTwo" > Section 2 </ a > </ h4 > </ div > < div id = "collapseTwo" class = "panel-collapse collapse" role = "tabpanel" aria-labelledby = "headingTwo" > < div class = "panel-body" > < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. </ p > </ div > </ div > </ div > < div class = "panel panel-default" > < div class = "panel-heading" role = "tab" id = "headingThree" > < h4 class = "panel-title" > < a class = "collapsed" role = "button" data-toggle = "collapse" data-parent = "#accordion" href = "#collapseThree" aria-expanded = "false" aria-controls = "collapseThree" > Section 3 </ a > </ h4 > </ div > < div id = "collapseThree" class = "panel-collapse collapse" role = "tabpanel" aria-labelledby = "headingThree" > < div class = "panel-body" > < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. </ p > </ div > </ div > </ div > </ div > </ div > </ div > </ div > |
CSS样式
然后通过下面的CSS3代码来对该垂直手风琴进行效果的美化。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | a:hover,a:focus{ text-decoration : none ; outline : none ; } #acc ordion:before{ content : "" ; width : 1px ; height : 80% ; background : #550527 ; position : absolute ; top : 20px ; left : 24px ; bottom : 20px ; } #acc ordion .panel{ border : none ; border-radius: 0 ; box-shadow: 0 2px 5px rgba( 0 , 0 , 0 , 0.15 ); margin : 0 0 12px 50px ; position : relative ; } #acc ordion .panel:before{ content : "" ; width : 2px ; height : 100% ; background : linear-gradient(to bottom , #688e26 0% , #ff816a 100% ); position : absolute ; top : 0 ; left : -2px ; } #acc ordion .panel-heading{ padding : 0 ; background : #fff ; position : relative ; } #acc ordion .panel-heading:before{ content : "" ; width : 15px ; height : 15px ; border-radius: 50px ; background : #fff ; border : 1px solid #550527 ; position : absolute ; top : 50% ; left : -48px ; transform: translateY( -50% ); } #acc ordion .panel-title a{ display : block ; padding : 15px 55px 15px 30px ; font-size : 20px ; font-weight : 600 ; color : #550527 ; border : none ; margin : 0 ; position : relative ; } #acc ordion .panel-title a:before, #acc ordion .panel-title a.collapsed:before{ content : "\f068" ; font-family : fontawesome; width : 25px ; height : 25px ; line-height : 25px ; border-radius: 50% ; font-size : 15px ; font-weight : normal ; color : #688e26 ; text-align : center ; border : 1px solid #688e26 ; position : absolute ; top : 50% ; right : 25px ; transform: translateY( -50% ); transition: all 0.5 s ease 0 s; } #acc ordion .panel-title a.collapsed:before{ content : "\f067" ; } #acc ordion .panel-body{ padding : 0 30px 15px ; border : none ; font-size : 14px ; color : #305275 ; line-height : 28px ; } |
特别申明:
本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com