CSS3 Loading Bar
发布于
大漠
CSS3制作一个类似于文件Loading的效果,在这里没有写动画效果,主要考虑文件加载对应的文本,css实现效果会有难度。在这个DEMO中主要运用了四个知识点:第一是google font api,用来制作特殊的英文字体效果;第二个是使用CSS的渐变,制作了渐变的面板效果;第三使用box-shadow,制作面板之类的描边效果;第四就是使用border-radius制作圆角效果。
HTML Code:
<div class="loading"> <h2>Copying</h2> <div class="loading-bar"> <div class="metro"><span></span></div> <div class="metro-des">1 MB of 35 MB</div> </div> </div>
CSS Code:
/*loading Bar*/ .loading{ width: 415px; margin: 20px auto; border: 1px solid #000; border-radius: 5px; box-shadow: 0 3px 3px rgba(0,0,0,0.22); background-color: rgb(45,42,42); /* Old browsers */ /* IE9 SVG, needs conditional override of 'filter' to 'none' */ background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzJkMmEyYSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMzZTNmNDAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); background-image: -moz-linear-gradient(top, rgba(45,42,42,1) 0%, rgba(62,63,64,1) 100%); /* FF3.6+ */ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(45,42,42,1)), color-stop(100%,rgba(62,63,64,1))); /* Chrome,Safari4+ */ background-image: -webkit-linear-gradient(top, rgba(45,42,42,1) 0%,rgba(62,63,64,1) 100%); /* Chrome10+,Safari5.1+ */ background-image: -o-linear-gradient(top, rgba(45,42,42,1) 0%,rgba(62,63,64,1) 100%); /* Opera 11.10+ */ background-image: -ms-linear-gradient(top, rgba(45,42,42,1) 0%,rgba(62,63,64,1) 100%); /* IE10+ */ background-image: linear-gradient(to bottom, rgba(45,42,42,1) 0%,rgba(62,63,64,1) 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2d2a2a', endColorstr='#3e3f40',GradientType=0 ); /* IE6-8 */ } .loading h2 { padding: 5px 10px; font-size: 20px; text-shadow: -2px -3px 0 rgba(0, 0, 0, 0.3); border-bottom: 1px solid black; box-shadow: 0 2px 0 rgba(255, 255, 255, 0.13),inset 0 2px 0 rgba(255,255,255,0.13); background-color: rgb(50,50,50); /* Old browsers */ /* IE9 SVG, needs conditional override of 'filter' to 'none' */ background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzMyMzIzMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMyMzIzMjMiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); background-image: -moz-linear-gradient(top, rgba(50,50,50,1) 0%, rgba(35,35,35,1) 100%); /* FF3.6+ */ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(50,50,50,1)), color-stop(100%,rgba(35,35,35,1))); /* Chrome,Safari4+ */ background-image: -webkit-linear-gradient(top, rgba(50,50,50,1) 0%,rgba(35,35,35,1) 100%); /* Chrome10+,Safari5.1+ */ background-image: -o-linear-gradient(top, rgba(50,50,50,1) 0%,rgba(35,35,35,1) 100%); /* Opera 11.10+ */ background-image: -ms-linear-gradient(top, rgba(50,50,50,1) 0%,rgba(35,35,35,1) 100%); /* IE10+ */ background-image: linear-gradient(to bottom, rgba(50,50,50,1) 0%,rgba(35,35,35,1) 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#323232', endColorstr='#232323',GradientType=0 ); /* IE6-8 */ border-radius: 5px 5px 0 0; } .loading-bar { padding: 15px; } .metro { border: 1px solid #000; border-radius: 5px; height: 20px; box-shadow: 0 2px 0 rgba(255, 255, 255, 0.13); margin-bottom: 10px; background: #292929; } .metro span { display: block; height: 20px; width: 35%; border-radius: 5px; background-color: rgb(75,117,204); /* Old browsers */ /* IE9 SVG, needs conditional override of 'filter' to 'none' */ background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzRiNzVjYyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iIzRiNzVjYyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUxJSIgc3RvcC1jb2xvcj0iIzMwNjFjNCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMzMDYxYzQiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); background-image: -moz-linear-gradient(top, rgba(75,117,204,1) 0%, rgba(75,117,204,1) 50%, rgba(48,97,196,1) 51%, rgba(48,97,196,1) 100%); /* FF3.6+ */ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(75,117,204,1)), color-stop(50%,rgba(75,117,204,1)), color-stop(51%,rgba(48,97,196,1)), color-stop(100%,rgba(48,97,196,1))); /* Chrome,Safari4+ */ background-image: -webkit-linear-gradient(top, rgba(75,117,204,1) 0%,rgba(75,117,204,1) 50%,rgba(48,97,196,1) 51%,rgba(48,97,196,1) 100%); /* Chrome10+,Safari5.1+ */ background-image: -o-linear-gradient(top, rgba(75,117,204,1) 0%,rgba(75,117,204,1) 50%,rgba(48,97,196,1) 51%,rgba(48,97,196,1) 100%); /* Opera 11.10+ */ background-image: -ms-linear-gradient(top, rgba(75,117,204,1) 0%,rgba(75,117,204,1) 50%,rgba(48,97,196,1) 51%,rgba(48,97,196,1) 100%); /* IE10+ */ background-image: linear-gradient(to bottom, rgba(75,117,204,1) 0%,rgba(75,117,204,1) 50%,rgba(48,97,196,1) 51%,rgba(48,97,196,1) 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4b75cc', endColorstr='#3061c4',GradientType=0 ); /* IE6-8 */ } .metro-des { color: #a49f9f; text-shadow: -1px -2px 0 rgba(0, 0, 0, 0.3); }
如需转载,烦请注明出处:https://www.fedev.cn/demo/css3-loading-bar.html
Jordan Flight Luxe