Javascript + CSS Implementation of image shutter effects ideas and code, javascriptcss
Those who have used Arcgis will surely have a deep memory of a roller shutter In Arcmap. They want to move it to their WebGIS system and share the same idea, I have also made some research on this kind of dazzling shutter effect.
If you see this effect, do you have a chicken? hey, don't worry. Listen to me.
First, container. Use two divs to display images of different periods. Next, set the style of the two containers. The Code is as follows:
#after{ position: absolute; top: 0px; left: 0px; background-image: url(../images/24.jpg); width: 940px; height: 529px; background-repeat: no-repeat; } #before{ position: absolute; top: 0px; left: 0px; border-right: 3px solid #f00; background-image: url(../images/23.jpg); width: 433px; height: 529px; background-repeat: no-repeat; max-width: 940px; }
In this way, the image is displayed on the web.
Next, implement the shutter effect. To implement shutter, the most important thing is to set the before width. How to set it is to get the mouse position, the Code is as follows:
function RollImage(evt){ var x=evt.pageX; console.log(x); $("#before").css("width",x+"px"); } /script>
In this way, the shutter effect is achieved. The source code is as follows:
Style.css
.beforeafter{ width: 940px; height: 529px; } #after{ position: absolute; top: 0px; left: 0px; background-image: url(../images/24.jpg); width: 940px; height: 529px; background-repeat: no-repeat; } #before{ position: absolute; top: 0px; left: 0px; border-right: 3px solid #f00; background-image: url(../images/23.jpg); width: 433px; height: 529px; background-repeat: no-repeat; max-width: 940px; }
Test.html
<Html lang = "zh-CN" xmlns = "http://www.w3.org/1999/xhtml">
Use javascript to implement the menu effect code
Can this be implemented directly with css? Why do you need to use js?
Do you want to click to display the sub-menu effect? Paste all the menus. I will give you
How to hide and display JAVASCRIPT and CSS
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "www.w3.org/..al.dtd">
<Html xmlns = "www.w3.org/5o/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
</Head>
<Body>
<Script language = "JavaScript">
<! --
Function show (obj ){
Obj. style. display = obj. style. display = "none "? "": "None ";
}
// -->
</SCRIPT>
<A href = "javascript:" onclick = "show (document. getElementById ('asd ')"> click me </a>
<Div id = "asd" style = "display: none"> I'm out, I'm leaving </div>
</Body>
</Html>
Test it and use it. Remember to add points.