This code snippet places your filter reset button inline with the filter fields. To use this, your filter location needs to be set to fullwidth and placed above your archive loop. The CSS is heavily commented to help you adjust the location and spacing perfectly.
Place the Filter Reset Button inline with the Filter Fields
Details
Snippets Demo
Code
Description:
This snippet will place the reset button inline with your filter fields. Place the code in either your Theme Options, or the Custom CSS area in the Filter Module. To fine tune the location or spacing of the button adjust the margin-top, see the comments in the CSS code for more information.
Language: CSS
Where to add: Divi Module Advanced Tab
/* Desktop Styles (Default) */
/* Ensure the reset button is visible and reset margins/padding */
.reset-filters {
display: inline-block !important; /* Make sure the reset button is displayed as an inline block */
margin: 0; /* Remove any default margin */
padding: 0 20px; /* Adjust horizontal padding as needed for better spacing */
height: 40px; /* Match the height of the dropdowns for consistency */
line-height: 40px; /* Vertically center text within the button */
box-sizing: border-box; /* Include padding and border in the element's total width and height */
/* Adjust vertical position */
margin-top: -2px; /* Move the button slightly up or down by changing this value to align perfectly */
/* Alternatively, use transform for finer adjustments */
/* transform: translateY(-2px); */
}
/* Set the main filter container to use full width and align items */
#divi_filter {
display: flex; /* Use flexbox for easy alignment and layout */
flex-wrap: wrap; /* Allow items to wrap to the next line if needed */
align-items: center; /* Vertically center items within the container */
width: 100%; /* Take full width of the parent container */
box-sizing: border-box; /* Include padding and border in the element's total width */
margin: 0; /* Remove any default margin */
padding: 0; /* Remove any default padding */
}
/* Adjust the form to fill available space and align items */
#divi_filter form {
display: flex; /* Use flexbox to align the form elements */
flex: 1; /* Allow the form to grow and fill available space */
flex-wrap: wrap; /* Wrap elements if needed */
align-items: center; /* Vertically center items within the form */
margin: 0; /* Remove any default margin */
padding: 0; /* Remove any default padding */
}
/* Set each dropdown module to share space equally */
#divi_filter .divi-filter-containter .et_pb_module {
flex: 1; /* Allow each dropdown to grow and share available space equally */
min-width: 200px; /* Set a minimum width to ensure dropdowns are usable */
margin-right: 20px; /* Add space between each dropdown module */
box-sizing: border-box; /* Include padding and border in the element's total width */
}
/* Ensure the dropdowns have consistent height and vertical alignment */
.divi-filter-item select {
height: 40px; /* Match the height of the reset button for consistency */
margin: 0; /* Remove any default margin */
padding: 0 10px; /* Add horizontal padding for better usability */
box-sizing: border-box; /* Include padding and border in the element's total width */
}
/* Adjust the reset button container to align items */
#divi_filter .button_container {
display: flex; /* Use flexbox for alignment */
align-items: center; /* Vertically center the reset button within the container */
margin-left: 20px; /* Add space to the left of the reset button */
padding: 0; /* Remove any default padding */
/* Remove margin-left: auto; if it pushes the button too far right */
/* margin-left: auto; */
}
/* Remove any floating and alignment styles that may cause misalignment */
.button_container.align_reset_right {
float: none; /* Remove floating to prevent misalignment */
text-align: right; /* Align text to the right if needed */
margin: 0; /* Remove any default margin */
}
/* Optional: Adjust the title (label) alignment */
.et_pb_contact_field_options_title {
margin: 0 0 5px 0; /* Adjust margins to control spacing around the label */
line-height: normal; /* Set line height to normal for consistent spacing */
}
/* Media Queries for Responsive Design */
/* Media query for smaller screens */
@media (max-width: 768px) {
/* Stack elements vertically on smaller screens */
#divi_filter {
flex-direction: column; /* Change flex direction to stack elements vertically */
align-items: stretch; /* Stretch items to take full width */
}
#divi_filter form {
flex-direction: column; /* Stack form elements vertically */
}
#divi_filter .divi-filter-containter .et_pb_module {
margin-right: 0; /* Remove right margin to avoid overflow */
margin-bottom: 15px; /* Add space between dropdowns when stacked */
}
/* Center the reset button on smaller screens */
#divi_filter .button_container {
margin-left: 0; /* Remove left margin to center the button */
align-self: center; /* Center the reset button within its container */
margin-top: 10px; /* Add space above the reset button for better spacing */
width: 100%; /* Ensure the button takes full width if needed */
}
/* Adjust widths to ensure elements fill the container */
#divi_filter .divi-filter-containter .et_pb_module,
#divi_filter .button_container {
width: 100%; /* Make elements take full width of the container */
}
}
Related Snippets
Easy | CSS
Limit Height of Post/Product Images in Loop Templates (no crop)
Feb 07 2025
Easy | CSS
How to Align the Search Button in Divi Engine Filter: A Simple CSS Snippet
Aug 27 2024
Easy | CSSJavascript
Implementing a Lightbox for ACF Images in Your WordPress Site
Jul 10 2024
Easy | CSS
Numerical Indexing for Repeated Fields in the Divi Machine Repeater Module
Feb 29 2024
Easy | CSS
Make Your Divi Ajax Filter Sticky on Mobile Devices
Feb 21 2024
Explore more from Divi Engine
Divi Form Builder
From simple contact forms to complex frontend post or product creation, Divi Form Builder has you covered.
Divi Machine
Build complex websites that displays dynamic fields you can filter, search and so much more with the Divi Builder.
Divi BodyCommerce
A versatile toolkit for developers using Divi and WooCommerce together, designed to boost your e-commerce site and achieve greater conversion rates.
Divi Loop Extender
Unlock the Full Power of Divi 5 Loop Builder Add advanced sorting, filtering, and relationship logic right inside the Visual Builder.
Divi Membership
Monetize your Divi websites by transforming them into membership sites with seamless subscription management, user-friendly interfaces, and customizable membership tiers.
Divi Machine Accounts
Build an account area for your customers to edit their details, access wishlist, submitted posts and more. *Note: Requires Divi Machine installed and active
Divi Ajax Filter
Filter WooCommerce, Posts & Custom Posts without reloading the page.
Divi Mobile
Divi Mobile helps you create beautiful looking mobile menus without having to code.
Divi Nitro
Give your Divi website that extra boost of speed with our Divi Nitro plugin to enhance your customer's experience.
Divi Protect
Password protect the content of your Divi website with our Divi Protect plugin. Keep unwanted eyes out!
Divi Mega Menu
Improve the user experience of your Divi website with our Divi Mega Menu plugin by creating dynamic menus using the Divi Builder.