Flipped CSS
By sanqi, also known as Halikidiki: August
Now I am myself, and I am sure that all web designers will mouse over one image at a time when they want to change its design life to another (commonly used contact ). The most common way to achieve this is to use JavaScript and have a lot of tutorials. However, you (if you are like me) pause a tutorial, jump to the end of the line to get the code, and then just copy and paste it on your website. Now, this job and everything, you don't understand why it works. Or, if anything goes wrong, how can you solve it? Turning CSS is simpler and does not require anything unless CSS and HTML (or even not pre-configured ).
This tutorial will guide you through how to place the anchor tag on the linked image and then move the mouse over the image when the image is constantly changing.
This is an example. I want to tell you how to do this:
Below is how
The following steps explain how to achieve this effect.
Open the HTML file and you want a CSS tumble (or use this HTML code if you only want to experiment with the effect ):
-
<Html>
-
<Head>
-
<Title> CSS rolovers </title>
-
<Style type = "text/css">
-
@ Import "rolover.css ";
-
</Style>
-
</Head>
-
-
<Body>
-
<Div>
-
<A href = "#" id = "example"> Home </a>
-
</Div>
-
</Body>
-
</Html>
-
You don't have to worry about any code (you should easily understand it all anyway) outside of the anchoring tag, what is the internal style tag.
Save your HTML file.
Open FrontPage/production/notepad (whether you like it) and paste the CSS:
-
# Example {
-
Height: 20px;
-
Width: 158px;
-
Text-indent: Pixel px;
-
Overflow: hidden;
-
Background: url(kirupa1.gif) top left no-repeat;
-
Display: block;
-
}
-
-
# Example: hover {
-
Background-position: bottom left;
-
}
-
For this tutorial, please file rolover.css and save it in the same directory as your HTML file.
Now, this is the use of JavaScript from different majorly. There are two images for you, one is the original state and one is the transition state. When you use CSS to flip the car, you need to put all the images in the same image, like this:
The saved image kirupa1.gif is stored in the HTML + CSS file in the same directory. Then view your HTML file and voila!
Now the time goes through this code!
# What is the so-called ID and class, but only one HTML file can be used.
The size of kirupa1.gif is 40px of 158px. However, half of the height is an image that we don't want to see (so far). We will be 20 px in height, as well as the background we developed later, with the highest position.
For CSS that cannot be viewed by the browser (yes, I know...), you should always include enabling and disabling the anchor between some texts. For CSS that can be viewed by browsers, we must get rid of this text. Therefore, we have determined a large number of text indentation and set overflow to hide. Self-explanation.
The # In the last two rows, for example, (), is only a so-called background image. It is told that it is placed above it and should not be repeated.
The second is # for example: hover over-say basically when the mouse moves to this factor style like this.
All of this has not changed. It is to display the top 20 pixels to display the bottom 20 pixels, effective image switching.
Good job! You have successfully created some pure CSS rollover! This is much simpler than using JavaScript, because it does not need to load the image when the second mouse roll exceeds your need to use JavaScript pre-installed image.