<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abdallah Muhammed</title>
    <description>The latest articles on DEV Community by Abdallah Muhammed (@abdallahifox).</description>
    <link>https://dev.to/abdallahifox</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F340868%2F54b345ab-7c9e-4440-826a-3ae7ea54481b.jpg</url>
      <title>DEV Community: Abdallah Muhammed</title>
      <link>https://dev.to/abdallahifox</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abdallahifox"/>
    <language>en</language>
    <item>
      <title>Button Hover Effect Using HTML/CSS</title>
      <dc:creator>Abdallah Muhammed</dc:creator>
      <pubDate>Sat, 12 Dec 2020 20:33:36 +0000</pubDate>
      <link>https://dev.to/abdallahifox/button-hover-effect-using-html-css-30c</link>
      <guid>https://dev.to/abdallahifox/button-hover-effect-using-html-css-30c</guid>
      <description>&lt;h3&gt;
  
  
  let's make a button hover effect.
&lt;/h3&gt;

&lt;p&gt;first, use a button tag is very important for the behavior. &lt;/p&gt;

&lt;p&gt;please don't use &amp;lt; a &amp;gt; tag for buttons. they have different meanings and behavior. &lt;/p&gt;

&lt;p&gt;&amp;lt; a &amp;gt; tag is used for link responses not for actions like &amp;lt; button &amp;gt; tags.&lt;/p&gt;

&lt;p&gt;&amp;lt; a &amp;gt; used for navigation, user can click it to open in a new tab, all that I want to tell you, &lt;/p&gt;

&lt;p&gt;don't use &amp;lt; a &amp;gt; tags for make an action use &amp;lt; button &amp;gt; tags for that, and now let's start to make our &lt;/p&gt;

&lt;p&gt;beautiful button effect.&lt;/p&gt;

&lt;h3&gt;
  
  
  let's make our body HTML Tage :
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GFShkyKQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2xtev0k3ydnl9hgg5zmm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GFShkyKQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2xtev0k3ydnl9hgg5zmm.png" alt="Alt Text" width="342" height="95"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should be able to use &amp;lt; button &amp;gt; everywhere, but if you want something, and Now Let's Make The Stylesheet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Styleseet
&lt;/h3&gt;

&lt;p&gt;1- let's make the CSS for a button with the regular style, we pass the position relative to the button because we will make the span absolute later to make our effect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jaxf3dXj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bu1t5s4emf8hg9c2d13j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jaxf3dXj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bu1t5s4emf8hg9c2d13j.png" alt="Alt Text" width="267" height="110"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;you should have a regular style like this :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dPWY2xLW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0uccigly7m6m409y0e3s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dPWY2xLW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0uccigly7m6m409y0e3s.png" alt="Alt Text" width="303" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- we need to focus on the &amp;lt; span &amp;gt; tag  it will take all the work, let's give it some style&lt;br&gt;
  &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5tFCuygh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ueveekowg0ujcbxj1qmf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5tFCuygh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ueveekowg0ujcbxj1qmf.png" alt="Alt Text" width="295" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;we give it a &lt;strong&gt;display: block&lt;/strong&gt; to respect all the height and width of our button, we need to make sure that,&lt;/p&gt;

&lt;p&gt;our span has the full width and height of the &amp;lt; button &amp;gt; tag when we &lt;strong&gt;hover&lt;/strong&gt; it.&lt;/p&gt;

&lt;p&gt;3- next, we need to make a beautiful effect that when we &lt;strong&gt;hover&lt;/strong&gt; the Button or the &amp;lt; span &amp;gt; tag,&lt;/p&gt;

&lt;p&gt;we get the beautiful effect, let's make the &lt;strong&gt;before&lt;/strong&gt; And &lt;strong&gt;after&lt;/strong&gt; to the span.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cH3OAuSI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/73go6sa98tvapv6ol011.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cH3OAuSI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/73go6sa98tvapv6ol011.png" alt="Alt Text" width="290" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;now&lt;/strong&gt; we have the position &lt;em&gt;absolute&lt;/em&gt; for the &lt;strong&gt;before&lt;/strong&gt; &amp;lt; span &amp;gt; tag with 50% &lt;strong&gt;width&lt;/strong&gt; and&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;z-index&lt;/strong&gt; -1 to make sure that the effect uder the title of the &amp;lt; span &amp;gt; tag, &lt;strong&gt;transform:scaleX&lt;/strong&gt; and &lt;strong&gt;transform-origin&lt;/strong&gt; for the direction of the &lt;em&gt;before&lt;/em&gt; effect&lt;/p&gt;

&lt;p&gt;the &lt;strong&gt;transition&lt;/strong&gt; for the smooth effect&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nuA_ZkvE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8tvklrqyjhhop6qlbu8u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nuA_ZkvE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8tvklrqyjhhop6qlbu8u.png" alt="Alt Text" width="240" height="145"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: the &lt;em&gt;scaleX&lt;/em&gt; = &lt;strong&gt;1&lt;/strong&gt; in The photo we will put it = &lt;strong&gt;0&lt;/strong&gt; in the first and when we hover the &lt;strong&gt;before&lt;/strong&gt; it will change to &lt;strong&gt;1&lt;/strong&gt; With a small &lt;strong&gt;transition&lt;/strong&gt; effect&lt;/p&gt;

&lt;p&gt;4- let's make the &lt;strong&gt;after&lt;/strong&gt; effect too, the same with the &lt;strong&gt;before&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q4NuPrU9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ry4xbz570bspszve2vmw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q4NuPrU9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ry4xbz570bspszve2vmw.png" alt="Alt Text" width="332" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5- let's make The &lt;strong&gt;NOTE&lt;/strong&gt; and make the &lt;em&gt;after&lt;/em&gt; and &lt;em&gt;before&lt;/em&gt; hover effect&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--visNiMEv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g74gxlmmj35fxdhu4fv0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--visNiMEv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g74gxlmmj35fxdhu4fv0.png" alt="Alt Text" width="320" height="145"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;all&lt;/strong&gt; what we need is to change the &lt;strong&gt;scaleX&lt;/strong&gt; and make a nice transition. &lt;/p&gt;

&lt;h2&gt;
  
  
  Finally,
&lt;/h2&gt;

&lt;p&gt;we did it, in the end, you should have a nice and smooth effect button link this : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://codepen.io/abdallahifox/pen/NJGoVV?editors=1100"&gt;https://codepen.io/abdallahifox/pen/NJGoVV?editors=1100&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The-End
&lt;/h3&gt;

&lt;p&gt;I made it with HTML/CSS, but it can be achieved with any Framework as well. I hope your main take away will be thinking of a button effect how to make the effect, not the code itself.&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>design</category>
    </item>
  </channel>
</rss>
