The best CSS code of custom WordPress ? If so, we will show you some of the most common CSS scripts, you can use them to edit your WordPress website.
We know that there are many options that can be customized using plug -ins, theme options and default settings. But you can also use CSS code to edit various areas of the website. So let’s see why you might first need them to define your website.
Why use CSS code in WordPress to define the website?
Use CSS scripts or code in WordPress to change the visual appearance of the website. If you want
to perform specific design changes that are not included in the theme options or the default WordPress settings , the CSS script may be very helpful for you.
You can install the WordPress plug -in for custom Weight, which may slow its speed. The use of plug -in to make small changes to the website is not worth a decline in performance. So if you have basic coding knowledge, using CSS code is the best choice.
In order to ensure that you do not lose your website speed when you modify it, we strongly recommend that you use the CSS code to define your WordPress website. In addition, sometimes you may want to implement some
unique design on your website
. If you do not build a custom plug -in for it, CSS script is your only choice. The best CSS code of custom WordPress website
Although many CSS code can be used to customize the WordPress website, we will show you the best CSS script we find. When working at the front end of the WordPress website, they are the most commonly used code to classify and achieve excellent design of various problems.
However, the following script list is only used for demonstration purposes, they may not be able to run on your website Because of the use
Selector
related to the example website. In most cases, you need to edit the selector, so you need to have the basic knowledge of CSS to apply these scripts to your website. If you want to know more information about using developer tools to apply CSS scripts to WP websites, please check this article. In addition, you will find an additional part at the end, and you will learn the CSS script in WordPress in three different ways. Now, let’s use the script
1. Hide elements
This may be the most widely used CSS rule. It is very useful when you need to delete any elements at the front or back end.
1.1.
Hidden title: Bid head {display: none;}
1.2.
Hide the \”Add to Shopping Cars\” button
.SINGLE_ADD_TO_CART_BUTTTON.Button {Show: None;} 1.3.
.woocommerce -P bread crumbs {show: none;} Note:
It is not recommended to do this in some cases, because as long as you have a basic understanding of the browser console, you can change the hidden element to change Visible. For example, you may need to delete the form to fill in the user. Then you don’t want to use the CSS script to perform this operation, because anyone with basic knowledge can make them visible and send a form.
However, it provides a fast and simple solution for style or design issues. Use it without problems. If you need more help on how to hide and delete the \”Add to the shopping cart\” button, we also have detailed guidelines. Similarly, if necessary, you can also find more information about how to edit title and bread chips in our blogs in our blogs. 2. Mobile element
If you need to move certain elements to adjust the design of the page, you can use the following ways to easily move it to any direction:
# # # # [ qlwapp {bottom: 45px; left: 25px; position: relative;}
If the element has been positioned before, you may need to set
Position: Relative
in some cases.
Note:
This is only useful for small adjustments, and the element should not be removed from its container. You can use TOP, Right, BOTTOM, LEFT and assign each other.
3. CSS code of the mobile mode We can also only apply CSS applications For mobile devices. You can use media query to complete. They work like conditions. All CSS rules in media inquiry will be applied only when the screen size is lower than 768 pixels. The given screen width is taken from the recognized criteria for mobile devices, that is, 768 pixels. You can edit this value for larger or smaller screen size devices.
@Media only screen and (max-width: 768px) {div.masthead {display: internal block; width: 50%; side distance: automatic;}
4. Edit Text
CSS pseudo -selector is an excellent resource for custom WordPress website. With them wisely, we can also modify your website many. Therefore, we can also use these CSS code to define the text of your WordPress website.
: before
and : after pseudo selector device Allows us to insert \”pseudo -element\” before or after any other HTML elements. In this way, we can hide a text and replace it with any other text: P.Text {Visual: Hide;} p.text: {Visible: Visible; Content: \u0026 #39; Here is new text \u0026#39; show: block;} 5. Translation of using CSS code
We apply CSS rules according to the page language. Even if it is one of the translation plug -ins such as WPML or PolylangThe current LANG attribute will also always be on the main label of
\u0026 lt; html \u0026 gt; , which is output by the website HTML.
Therefore, if we use : before [ 123] The pseudo -selector, just like what you see in the previous example script, combined with : Lang ()
pseudo class, we will be able to translate any string on the website.
This is also suitable for multi -language websites. P.Text: LANG (EN) {Visual: Hidden;} p.text: LANG (EN) :: beFore {Visual: Visible; Content: \u0026#39; Translation text \u0026#39; Show: block;} 6. Add rolling bar
When you have some large content (such as list, picture library or part), the rolling bar can enhance the user experience of the website. They also help maintain posts and pages without too long.
This is particularly useful for use in the side bar or any other small component area. In addition, when the height exceeds the size, it can also help repair lost or chopped small components.
We can also insert the rolling bar in the post and page:
] The script will add a rolling bar to the list to make all documents shorter. UL {height: 370px; overflow -y: rolling;}
7. Use image as a CSS code for icons
You you You can use the CSS script to add any type of image and achieve it in several ways. But using a pseudo -selector
: BeFore
, we can add images and make it look like an icon.
Please upload the picture to the media library and use the permanent link of the picture as
URL (\u0026#39; Image-Link-Here \u0026#39;)
.ntry -Content \u0026 gt; p: nth-child (3) :: beface {content: url (\u0026#39; http:// localHost/Sampler/WP-CONTENT/UPLOADS/2022/03/Fish-ICon.png \u0026#39;);}
or we can use the real icon, or the same selector:
.ntry-confnt; p: nth-child (3) :: beface {font-family: \u0026 quot ; Font awesome 5 free \u0026 quot;; font thickness: 400; content: \”0F3\”;}
\u0026 lt; head \u0026 gt;
.
8. Change the font You can also use the CSS code to customize the font of the WordPress website. Similar to the icon, the font must also be loaded to the theme title so that we can use them. We can verify whether the font set is available by viewing the
\u0026 lt; head \u0026 gt;
section of the page.
Here, the Google font link has been added with the help of PHP script.
After you confirm that the icon or font set you want to use has been loaded to
\u0026 lt; head \u0026 gt;
html, you can be free on the entire website Use it H1, H2, H3, P, A, li {font-family: \u0026#39; hubballi \u0026#39; cursive;}
] Reward: Three methods to apply CSS to the WordPress website We provide you with the most commonly used CSS code to define your WordPress website. But you also need to know how to add them to your website. To this end, we will also show you a short tutorial as a reward in this article.
Therefore, there are 3 types of CS hereS is commonly used to apply to the WordPress website.
1. Theme customizer
To pass the theme through the theme Add the CSS script to the customizer, you only need to paste the CSS script to the theme customizer. It can usually be applied to small customization or repair. Turn to appearance \u0026 gt; custom \u0026 gt; additional CSS to open the style editor. Then paste your CSS script here.
Click the \”
release
\” button, the script here will be stored in the database. After preview, you will be able to see changes in the website.
2. Sub -theme CSS file
For this step, you must use programming or using one of the sub -theme plugins to create sub -themes for your website Essence Then, make sure that your website has a sub -theme of an event and add a CSS code in
style.css
file. If you also back up the entire website, it will be better because we will modify the fine core documents of your website.
Open your code editor and paste your script there, or use WP built -in editor on the appearance \u0026 gt; theme file editor
. Now, open the
style table or sub -theme style.css
.
This is where you should paste all the custom script. After adding the CSS code, click to update the file . But if it becomes a large file, creating one or more new files may be a good idea. 3. Functions.php file of sub -theme
You can also use the PHP function to insert the CSS style. All styles applied in this way will be inserted into the front.
Like the previous method, make sure that the theme of the child is activity for your website. Then, open
functions.php file from the theme editor and paste the following code here.
add_action (\u0026#39; wp_head \u0026#39;, \u0026#39; questionrs_headlink \u0026#39;); function quadlayers_headlink () {Echo \u0026#39; \u0026 lt; style \u0026 gt; .ntry-content \u0026 gt; p: nth-child (3) :: beFore {font-family: \u0026 quot; font awesome 5 free \u0026 quot; font thickness: 400; content: \”0F3\” \”\” ;} H1, H2, H3, P, A, Li {font-family: \”hubballi\”, cursive;} \u0026 lt;/style \u0026 gt; \u0026#39;}
The biggest advantage of using this method is You can apply PHP conditions to make full use of the powerful features of WP hooks and functions.
If you want to know more information about applying CSS to your website, please check our guidelines and understand how to apply CSS to WordPress.
Conclusion
These are the most commonly used CSS code for custom WordPress websites . We show you all the popular scripts. You can use these scripts to change the visual appearance of the website and add a unique design to it. All in all, we use CSS scripts to modify the following:
Hidden elements
CSS
Edit text [123
] Translation
Add rolling bar
- Use images as icons
- Change the font
- How to create a custom WordPress plug -in
These elements on WordPress website. To help you, we even show you several methods to apply CSS in WordPress.
In addition, if you want to know the CSS in WordPress, we also introduced CSS on a specific page or post. Similarly, the CSS script can even be used with the page construct. One of the most common examples is to use the CSS custom DIVI menu.
So what do you think of CSS to edit the WP website? Have you used them? Are they help? Please tell us in the comments.
At the same time, there are some articles that you may be interested in here:
Fix the problem of not loading the WordPress dashboard
How to create WordPress custom fields by programming