CS-Cart provides a great deal of flexibility when it comes to customizing the visual presentation of your online store. One of the key tools for achieving this customization is the Custom CSS (Cascading Style Sheets) feature in the Theme editor tool. It comes in handy when default settings of the Theme editor for fonts, colors, and backgrounds are not enough.
If you are new to CSS, you can check out the following tutorials:
- CSS Beginner Tutorial gives you enough information to get familiar with CSS and start working with it;
- CSS Tutorial is a more detailed guide for experienced users.
In this article, we will look at the Custom CSS capabilities in CS-Cart using the Bright theme, the default CS-Cart theme, as an example. The CSS rules you will encounter in this article may not work in your store if you use a different theme.
Custom CSS allows store owners to modify the appearance of various elements within the storefront of their site.
Here are some examples of what you can change:
Change color of specific elements, for example, cart or profile icons
/* Change cart icon color to red */ .ty-icon.ty-icon-moon-commerce.ty-minicart__icon { color: #ff0000; } /* Change profile icon color to red */ .ty-icon.ty-icon-moon-user { color: red; }
Change font size and weight of specific elements
/* Change font and color for the table titles in cart */ th.ty-cart-content__title { font-family: Arial, Helvetica, sans-serif; font-size: 16px; font-weight: normal; color: #4e4ebb; }
Increase or decrease gaps between elements
/* Remove gaps before and after homepage banners */ .homepage-banners .owl-theme { margin: 0; }
Increase or decrease the size of the elements
/* Change width of the logo */ .ty-logo-container { width: 150px; }
Add borders to the elements
/* Change borders of the product thumbnails in the list */ .ty-grid-list__image { border: 2px dashed #cb7da4; }
Customize the look of the elements according to the viewport size. The elements of your site may look different if you set specific styles for them using the @media rule.
/* Change the number of columns in the Vendors block for mobile devices */ @media screen and (max-width: 480px) { .ty-mainbox-simple-body .ty-grid-vendors .ty-column5 { width: 50%; } }
It is important to mention that Custom CSS does not apply to the CS-Cart admin panel, as it is isolated from the storefront. Changes in the admin panel require specific modifications.
Any styles you write in the Custom CSS section take precedence over default styles, allowing for convenient modifications without altering core files. When the page loads, CSS rules are applied sequentially; hence, rules defined in the Theme editor tool overwrite default ones.
You can define a CSS selector using DevTools, for example, in Google Chrome as well as in other browsers. It is an essential tool for web developers, here is how you can use it effectively:
Sometimes your CSS rule may not work because it conflicts with other rules. The !important
declaration can force a style to apply. However, overusing it can lead to messy and hard-to-maintain code. It makes it difficult to troubleshoot or extend your styles later, as you may find yourself needing additional !important tags to override existing styles.
As an alternative you can enhance the specificity of your CSS rules by using more targeted selectors, which can often resolve conflicts without needing the !important
rule.
For example, you want to change the color of the block headings in footer:
.ty-footer-general__header {
color: blue;
}
But your rule does not work because the color of the text was set in a more specific rule. You can specify the selector for your rule by adding a class from a parent element:
.ty-footer-menu .ty-footer-general__header {
color: blue;
}
In CS-Cart, elements of the layout page often use the same classes which makes it difficult to define a selector for your custom CSS rule that should work only for a specific element.
The User-defined CSS class field is the feature that allows you to assign unique classes to specific elements within your store and helps to create targeted styles that do not affect other components. For instance, if you want to change the appearance of just one product block or menu item while keeping the default styles for the rest, adding a unique class makes it possible.
You can find the User-defined CSS class field on the editing page of a block, grid, section, menu item, and profile field.
Here is an example of how you can use this field. Imagine that you want to add a border to your Hot deals product block. You need to do the following:
/* Adds a red border to the grid */
.hot-deals-grid {
border: 5px solid #e73c18;
padding: 0 20px;
margin-bottom: 10px;
}
If you find that your website is displaying without any styles after adding a CSS rule, it is likely due to a mistake in your code.
To fix this issue, navigate to the Website → Themes → Templates page of your admin panel and open the [theme_name] → styles → data → [theme_stye_name].css file.
You can also access this file in your installation files, it is located at design/themes/[theme_name]/styles/data/[theme_style_name].css
.
Once you have opened the file, carefully review the CSS code to identify the error. You can either correct the mistake or remove the problematic rule entirely. After making the necessary changes, save the file and refresh your website to see if the styles are applied correctly.
You may also need to clear the cache of your site by clicking on the Clear cache button on the Website → Themes page of your admin panel.
CS-Cart has its own microformats. They are used as specific CSS classes to determine which JavaScrip code should be executed for a specific HTML element.
You can read about microformats in the separate article.
Questions & Feedback
Have any questions that weren't answered here? Need help with solving a problem in your online store? Want to report a bug in our software? Find out how to contact us.