当前位置:K88软件开发文章中心编程语言Css/Css3Css/Css301 → 文章内容

比较两段html代码运行效率

减小字体 增大字体 作者:wangsdong     来源:asp编程网  发布时间:2018-12-30 8:50:23

第一段:
<
style>

.a,.b,.c,.d
{background:transparent url(2.jpg)
width:100px
height:100px
}
.a
{
background-position: 0 0

}
.b
{
background-position: -200px -100px

}
.c
{
background-position: -300px -100px

}
.d
{
background-position: -400px -100px

}

 
<
/style>

 
<
div class="
a"
>
<
/div>
<
br>

 
<
div class="
b"
>
<
/div>
<
br>

 
<
div class="
c"
>
<
/div>
<
br>

 
<
div class="
d"
>
<
/div>
<
br>

第二段:
<
style type="
text/css"
>

.a
{
background-position: 0 0

background:transparent url(2.jpg)
width:100px
height:100px

}
.b
{
background:transparent url(2.jpg)
width:100px
height:100px

background-position: -200px -100px

}
.c
{
background:transparent url(2.jpg)
width:100px
height:100px

background-position: -300px -100px

}
.d
{
background:transparent url(2.jpg)
width:100px
height:100px

background-position: -400px -100px

}
 
<
/style>

 
<
div class="
a"
>
<
/div>
<
br>

 
<
div class="
b"
>
<
/div>
<
br>

 
<
div class="
c"
>
<
/div>
<
br>

 
<
div class="
d"
>
<
/div>
<
br>

功能是一样的,只是使用的CSS的方法不一样罢了。第一种效率会更高些。



比较两段html代码运行效率