ct-icon-boxes that contains all the icon boxes. According to the Nielsen Norman group, icons need a text label to clarify their meaning. Once these thumbnails are clicked, their larger versions get displayed. However, this solution will require two lines. You can begin by having some clickable thumbnails in place. At first, you might be tempted to add a pair of event listeners such as onmouseenter and onmouseleave to mimic the behavior of the CSS hover effect. This is because icons by themselves may not be descriptive enough for the users so we also provide text to make it clear what the link is about. This hover effect can be effectively used to create a clean lightbox effect by using CSS only. Notice that we have an icon and a descriptive heading with an h3 tag under the icon for each link. Doing this will mean that you need the rest of your page to also be 'hoverable' so when you touch outside of the image it recognizes that info-slide:hover has ended.
#Html css hover effects only when clicked code#
Copy and paste the code below and feel free to customize the layout and the number of links as you need: Change your div background to an actual image tag within the div or create a dummy link around the entire div, it will then register as a hover when you touch the image. Replace the # in the onclick attribute with the link address you want to put. Let's start by including the necessary Bootstrap and FontAwesome source links in the HTML file:īelow we have the code for a Bootstrap container box with three links.
We need to set the cursor to pointer so that when users hover over the link, the cursor will change from an arrow to a hand, making it clear the element is clickable. This is especially important for color-blind users as they can't distinguish colors, they need other indicators for links. We also wrote about a few related subjects like CSS text animation, HTML and CSS menu, HTML and CSS tabs, CSS checkbox examples, CSS search box designs, Bootstrap login form templates, CSS hover effects and HTML and CSS forms. Since we're not using any a tags for the links and instead relying on Javascript's onclick function, we also need to indicate links by changing the cursor. If you enjoyed reading this article on CSS image effects, you should check out this one about CSS border animation. This is why links using icon fonts and SVG images are much more practical: With PNG and JPEG image files, you need to provide two sets of images with different colors for each icon, one for regular state and one for the hover state. If you're using SVG instead of FontAwesome, you can change the color easily with the fill property. All you have to do is change their color property in your CSS file.
Icon fonts are ideal to work with when you want to change the link colors easily. In this tutorial, we're using FontAwesome icons. Using hover effects to change the icon and background color is a good way to indicate they are clickable. When designing icon links we need to make it obvious they are clickable. In the earlier days of the web, only text and blue color were used to indicate links. In modern web design, we can be more creative when designing links such as using icons but we need to ensure that the usability of the links doesn't suffer. They are the elements that people interact with the most. Hyperlinks are the most fundamental building blocks of the web.