喵了–Css文件内编写Javascript
这个这个。。。偶一直听说过,没在意也不清楚具体怎么写
今天看到一团代码,用的expression表示。偶表示这东西也没什么难度
下面来段瞅瞅,喵~~~![]()
#carousel_photo_container #pre {
width: expression(document.getElementById("carousel_photo").width/2 < 300 ? document.getElementById("carousel_photo").width/2 : "300px");
left: expression(document.getElementById("carousel_photo").width/2 < 300 ? 87+300-document.getElementById("carousel_photo").width/2 : "87px");
}
#carousel_photo_container #next {
width: expression(document.getElementById("carousel_photo").width/2 < 300 ? document.getElementById("carousel_photo").width/2 :"300px");
right: expression(document.getElementById("carousel_photo").width/2 < 300 ? 87+300-document.getElementById("carousel_photo").width/2 :"87px");
background-image: url(../images/cover.gif);
}
#carousel_photo {
padding: 5px;
border: 1px solid #990033;
max-width:600px;
height:auto;
_width:expression(this.width > 600 ? "600px" : this.width);
}
这单代码主要作用是根据图片的宽度来实现显示时候图片的宽度
| 分享到: | |
我当时也是第一次看到,确实没有什么难度,关键是需要的时候能用得上!