{"id":1928,"date":"2012-12-16T18:26:16","date_gmt":"2012-12-16T18:26:16","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=1928"},"modified":"2012-12-16T18:26:16","modified_gmt":"2012-12-16T18:26:16","slug":"css-image-rollover-with-example","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/css-image-rollover-with-example\/","title":{"rendered":"CSS Image Rollover with Example"},"content":{"rendered":"<p>If you would like to create rollover effect by using only CSS i.e. a <strong>pure CSS Image Rollover effect<\/strong>, then this article is for you. In this article by using a simple example, I am going to show how to create Rollover effect for an image by simply using CSS and without any javascript or jQuery.<\/p>\n<h2>How to create CSS Image Rollover Effect?<\/h2>\n<p>Let&#8217;s look at the demo first:<\/p>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=1928\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<p><strong>Before Rollover:<\/strong><\/p>\n<p><a href=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/uploads\/2012\/05\/img_default.png\" class=\"broken_link\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"jQuery Image Rollover Effect - Before Rollover\" alt=\"\" src=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/uploads\/2012\/05\/img_default-150x150.png\" width=\"150\" height=\"150\" \/><\/a><\/p>\n<p><strong>After Rollover:<\/strong><\/p>\n<p><a href=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/uploads\/2012\/05\/img_roll.png\" class=\"broken_link\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"jQuery Image Rollover Effect - After Rollover\" alt=\"\" src=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/uploads\/2012\/05\/img_roll-150x150.png\" width=\"150\" height=\"150\" \/><\/a><\/p>\n<h3>Example of Image Rollover using CSS<\/h3>\n<p>Let&#8217;s assume that you have a main &#8220;container&#8221; div that contains both the images i.e the image that needs to be shown by default and the roll over image as well. Take a look a the simple, easy to understand HTML &amp; CSS code below:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\"&gt;\n&lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"&gt;\n&lt;head&gt;\n&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/&gt;\n&lt;title&gt;Example of Image Rollover using pure CSS&lt;\/title&gt;\n\n&lt;style type=\"text\/css\"&gt;\n.container {\nwidth: 300px;\n}\n\n.container .img_rollover {\nwidth: 300px;\ndisplay: none;\n}\n\n.container:hover .img_rollover {\ndisplay: block;\n}\n\n.container:hover .img_default {\ndisplay: none;\n}\n&lt;\/style&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n\n&lt;div class=\"container\"&gt;\n&lt;img src=\"images\/1.jpg\" width=\"300\" height=\"300\" class=\"img_default\"&gt;\n&lt;img src=\"images\/2.jpg\" width=\"300\" height=\"300\" class=\"img_rollover\"&gt;\n&lt;\/div&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=1928\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<h5>Simple, isn&#8217;t it?<\/h5>\n<p>Do you know of any other ways to make <strong>CSS Image Rollover Effect<\/strong>? Feel free to suggest by commenting below.<\/p>\n<p>P.S: \u00a0If you would like to find out how to achieve Image Rollover effect using jQuery, then read my article on\u00a0<a title=\"jQuery Image Rollover effect with example\" href=\"https:\/\/theextremewebdesigns.com\/blog\/tutorial-jquery-image-rollover\/\" target=\"_blank\">jQuery Image Rollover effect with example<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you would like to create rollover effect by using only CSS i.e. a pure CSS Image Rollover effect, then this article is for you. In this article by using a simple example, I am going to show how to create Rollover effect for an image by simply using CSS and without any javascript or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":276,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[18,13],"tags":[52],"class_list":["post-1928","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css-tips-and-tricks","category-tips-and-tricks","tag-css-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-v6","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/1928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=1928"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/1928\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=1928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=1928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=1928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}