0

I downloaded the project from the server to my pc (localhost). Every time I make a change to the css this change is not loaded on the site (localhost).

I tried changing my browser and clear browser cache. I installed the plugin (Autoptimize) to clear the website css cache.

.section_news {
    display: inline-block;
    width: 100%;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.section_news .news_content {
    color: red;
    text-align: center;
}

.section_news .news_content .title {
    color: red;
    color: blue;
}

Changes are not visible when I reload the web site. I checked if the code was loaded at all: https://ibb.co/jT7LX6n

Nina
  • 57
  • 8
  • Hi! I would try disabling Autoptimize while you work on your CSS if you didn't already. It seems like the plugin has lots of options for inlining CSS and injecting styles directly into the HTML document, so perhaps this is preventing you from seeing your changes? – Cody MacPixelface Aug 15 '19 at 06:42
  • Ii installed the plugin just because of this problem.means after i saw the problem then I installed – Nina Aug 15 '19 at 07:02

2 Answers2

0

What specific class you are styling? This line?

   .section_news .news_content .title {
        color: red;
        color: blue;
    }

It should contain only one color. It is either color: red; or color: blue;

Also, Try to Cmd + Shift + r (on a mac) OR Ctrl + F5 (on windows).

And check if your stylesheet source link has variable like:

<link rel="stylesheet" type="text/css" href="css/stylesheet.css?ver=5.2.2" />

so the changes you have made to your css file doesn't take effect. You may change it from ver=5.2.2 to ver=5.2.3

UPDATE

Your local style sheet was not loading because the url of the website you have downloaded was not changed. The website that you are running locally is still using the style sheet of the live website.

You can choose one of the following solutions.

  1. If you are Using Xampp, you can host your domain virtually IF domain is using http only.

Add this Code in C:\xampp\apache\conf\extra\httpd-vhosts.conf

<VirtualHost *:80>
 DocumentRoot "C:/xampp/htdocs" //your file path
 ServerName your-domain.com
 ServerAlias www.your-domain.com
 <Directory "c:/xampp/htdocs">
 Order allow,deny
 Allow from all
 </Directory>
</VirtualHost>

Then go to C:\Windows\System32\drivers\etc\hosts then add this line

127.0.0.1  www.your-domain.com
  1. OR this way if domain is using https:

How do I use https (SSL) in XAMPP while using virtual hosts

ANOTHER option is to update your URL on your database: Note: make a backup first of your database Change site URL and WordPress URL in Localhost

Or use a plugin like this https://wordpress.org/plugins/velvet-blues-update-urls/

little_coder
  • 564
  • 3
  • 13
  • sry for ```css color: red; color: blue; ``` but that is not a problem. Ctrl + F5 (on windows) it's not helping. ```html ``` - I dont have this code in header.php – Nina Aug 15 '19 at 07:06
  • @nina Can you screenshot the view-source of the page? Also try to restart your Apache server. – little_coder Aug 15 '19 at 07:20
  • Your style sheet source is pointing to live web url `www.meditalis.rs`. You have option to change your url from `www.meditalis.rs` to your locahost web url. Or Create a virtual host, then add your domain name `www.meditalis.rs` here is a guide https://stackoverflow.com/questions/16430574/how-do-i-use-https-ssl-in-xampp-while-using-virtual-hosts – little_coder Aug 15 '19 at 07:50
  • @Nina I added some solutions. You may check my answer. – little_coder Aug 15 '19 at 08:07
  • Add the code I have written above without comment `#`. Then change the desired value for `DocumentRoot`, `ServerName` , `ServerAlias` – little_coder Aug 15 '19 at 09:06
  • Omg this work, can anyone explain to me how this is possible. Thank you very much !!! – Nina Aug 15 '19 at 09:10
  • @Nina Using xampp, you can virtually host your site with your desired domain name. From `localhost/mydomain/` to `www.mydomain.com`. And without changing the domain url on your database, we will command our local web server to use the same domain url locally. So instead of loading the style sheet of the live website, your local web server will now read and load the style sheet in your local site. Hope you understand my explanation. – little_coder Aug 16 '19 at 06:00
0

The ?ver=5.2.2 in the CSS reference might cause caching issues for you. This is a parameter that normally is injected by Wordpress if the theme author loads the CSS file with the wp_enqueue_style() function.

As suggested in a similar question, you could try putting a function like this inside your functions.php:

function trim_css_version($src) {
    if (strpos($src, 'ver=')) {
        $src = remove_query_arg('ver', $src);
    }
    return $src;
}
add_filter('style_loader_src', 'trim_css_version', 9999);

This will hopefully remove the ?ver=x.x.x from your document, and also prevent unwanted browser caching.

Cody MacPixelface
  • 1,348
  • 10
  • 21
  • thank you very much for helping me! did i do this right: https://ibb.co/31YGzdx .I ask because there are still no changes – Nina Aug 15 '19 at 07:29
  • Did it change the line in your HTML to this? `` (without the `?ver=5.2.2`) – Cody MacPixelface Aug 15 '19 at 07:32
  • maybe i found a problem.When I click on link (style.css) in page source: this happens: https://ibb.co/1MxNYzp – Nina Aug 15 '19 at 07:36
  • Hmm... It's difficult to tell what the real problem is here. Are you sure that your local Wordpress-installation is using the local database and files? I would expect the source code to have links to `http://localhost/` and not the actual domain? – Cody MacPixelface Aug 15 '19 at 07:40
  • I just noticed another problem.when I try to approach localhost/mysite/wp-admin i will be transferred to ```css https://www.mysite/wp-admin .``` – Nina Aug 15 '19 at 07:48
  • Ok. I think we can assume there are some connections between your localhost site and the remote site that should not be there, and this is perhaps the root of the problem. When I need to make a local copy of a Wordpress site I use a plugin like https://wordpress.org/plugins/duplicator/ to make sure all references to the remote site is changed. I would suggest trying this to have a "clean start". Good luck! :) – Cody MacPixelface Aug 15 '19 at 07:56
  • Ok, I downloaded clean wordpress from web and install again. Now my web links looks good: https://ibb.co/rbr6Dz5 . Now I can access to localhost/meditalis/wp-admin. But page (css) is still unchanged. I can open localhost/meditalis/style.css: https://ibb.co/BtPmS9X ... Is the problem something else? no more css related errors: https://ibb.co/QYmgXhT – Nina Aug 15 '19 at 09:01