仅用css+HTML实现图片切换效果

备注:最好在firefox或chrome运行,在IE效果没出现  -。-

效果图:

仅用css+HTML实现图片切换效果_第1张图片


-----images.html-----





How to Create An Image Slider With Pure CSS3



    

CSS3 Image Slider

1 2 3 4 5

-----images.css-----

@CHARSET "UTF-8";
body {
    background-image:url("./images/sdl (31).png");
    background-attachment: fixed;
}
h1 {
    font: bold 35px/60px Helvetica, Arial, Sans-serif;
    text-align: center; color: #eee;
    text-shadow: 0px 2px 6px #333;
}
#images {
    width: 400px;
    height: 600px;
    overflow: hidden;
    position: relative;
    margin: 20px auto;
}
#images img {
    width: 400px;
    height: 600px;
    position: absolute;
    top: 0;
    left: -400px;
    z-index: 1;
    opacity: 1;
    transition: all linear 500ms;
    -o-transition: all linear 500ms;
    -moz-transition: all linear 500ms;
    -webkit-transition: all linear 500ms;
}
#images img:target {
    left: 0;
    z-index: 9;
    opacity: 1;
}
#images img:first-child {
    left: 0;
}
#slider {
    width: 150px;
    height: 30px;
    margin: 20px auto;
}
#slider a {
    text-decoration: none;
    background: #45b97c;
    border: 1px solid #C6E4F2;
    padding: 4px 6px;
    color: #222;
    margin: 20px auto;
}
#slider a:hover {
    background: #C6E4F2;
}

这个html很简单,就设置了两个div,一个放置img,一个设置下面的12345图标,当点击1~5的时候,会链接到相应的图片,而图片的切换效果最终还是由#imagesimg和#images img:target的属性来设置的。

你可能感兴趣的:(CSS)