Hi all!
Wondering if you can add hover effects on each card of a list block? You can!
Here is the demo page (desktop only) where you can check the results: List hovered
5 hover effects will be treated below:
- Card background-color change
- Card downsize
- Card upsize
- Card border-color change
- Card border-radius change
All codes below are to be inserted in the header custom code of the page settings
Change “#list1” by your list block IDs
Always keep the !important
statement in the codes
Also, as a reminder for a row backgound-color change of the table block:
<style>
#table1 [role="row"]:hover [role="gridcell"] {
background-color: #f8f8f8 !important;
}
</style>
Refer to this thread: Table color changes on mouse-over
Let’s dive in for the specific case of the list blocks
For a “List with vertical cards and tag”
Let’s say you want to change the background-color, upsize the cards and change the border color on mouse-over:
<style>
#list1 .vertical-list-item:hover {
background-color: #FFFFFF !important;
transform: scale(1.02) !important;
border: 1px solid #000000 !important;
}
</style>
For a “Grid List” (new Beta block)
Let’s say you want to change the background-color, downsize the cards, change the border-color, change the border thickness and make the border squared instead of rounded, on mouse-over:
<style>
#list1 [data-testid="grid-item"]:hover {
background-color: #f8f8f8 !important;
transform: scale(0.98) !important;
border: 2px solid #000000 !important;
border-radius: 0 !important;
}
</style>
For a “List” (new Beta block)
Let’s say you want to change the background-color, upsize the cards and make the border squared instead of rounded (no border-color or thickness changes):
<style>
#list1 [role="listitem"]:hover {
background-color: #f8f8f8 !important;
transform: scale(1.02) !important;
border-radius: 0 !important;
}
#list1 [role="listitem"] *:hover { /*this part is important as role="listitem" is also referring to other elements inside the card. Here with the * all children elements are not concerned*/
transform: none !important;
border-radius: none !important;
}
For a “List with horizontal sliding cards”
Let’s say you want to change the background-color and downsize the cards on mouse-over:
#list1 .horizontal-list-item:hover {
background-color: #FFFFFF !important;
transform: scale(0.98) !important;
}
For a “List with small cards”
Let’s say you want to change the background-color and (heavily) upsize the cards on mouse-over:
<style>
#list1 .vertical-list-item:hover {
background-color: #f8f8f8 !important;
transform: scale(1.2) !important;
}
</style>
Reminder that <style> </style>
can be stated once in the code
For example let’s say you have 5 lists and each of these lists have a specific mouse-over effect. You should write the CSS code this way:
<style>
#list1 .vertical-list-item:hover {
background-color: #FFFFFF !important;
transform: scale(1.02) !important;
border: 1px solid #000000 !important;
}
#list2 [data-testid="grid-item"]:hover {
background-color: #f8f8f8 !important;
transform: scale(0.98) !important;
border: 2px solid #000000 !important;
border-radius: 0 !important;
}
#list3 [role="listitem"]:hover {
background-color: #f8f8f8 !important;
transform: scale(1.02) !important;
border-radius: 0 !important;
}
#list3 [role="listitem"] *:hover {
transform: none !important;
border-radius: none !important;
}
#list4 .horizontal-list-item:hover {
background-color: #FFFFFF !important;
transform: scale(0.98) !important;
}
#list5 .vertical-list-item:hover {
background-color: #f8f8f8 !important;
transform: scale(1.2) !important;
}
</style>
Also, a design best practice would be to avoid these mouse-over effects on mobile. Here is how to change the code to make it happen only on desktop:
<style>
@media (min-width: 769px) {
#list1 .vertical-list-item:hover {
background-color: #FFFFFF !important;
transform: scale(1.02) !important;
border: 1px solid #000000 !important;
}
#list2 [data-testid="grid-item"]:hover {
background-color: #f8f8f8 !important;
transform: scale(0.98) !important;
border: 2px solid #000000 !important;
border-radius: 0 !important;
}
#list3 [role="listitem"]:hover {
background-color: #f8f8f8 !important;
transform: scale(1.02) !important;
border-radius: 0 !important;
}
#list3 [role="listitem"] *:hover {
transform: none !important;
border-radius: none !important;
}
#list4 .horizontal-list-item:hover {
background-color: #FFFFFF !important;
transform: scale(0.98) !important;
}
#list5 .vertical-list-item:hover {
background-color: #f8f8f8 !important;
transform: scale(1.2) !important;
}
}
</style>