Home > database >  styles.css file is not working. how to solve the problem?
styles.css file is not working. how to solve the problem?

Time:10-18

I made a website and got to the point where you need to connect styles.css, but after all the manipulations, my site has not changed and no design has been connected. I tried to rewrite css and html, tried different tips, but nothing helped me. any ideas? I would be grateful for any advice!

  • 1part base.html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>{{title}}</title>
    <link type="text/css" href="{% static 'women/css/styles.css' %}" rel="stylesheet" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="shortcut icon" href="{% static 'women/images/main.ico' %}" type="image/x-icon"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<table  border=0 cellpadding="0" cellspacing="0">
<tr><td valign=top>
{% block mainmenu %}
        <div >
            <ul id="mainmenu" >
            <li ><a href="#"><div ></div></a></li>
{% for m in menu %}
    {% if not forloop.last %}
            <li><a href="#">{{m.title}}</a></li>
    {% else %}
            <li ><a href="#">{{m.title}}</a></li>
    {% endif %}
{% endfor %}
            </ul>
            <div ></div>
        </div>
{% endblock mainmenu %}```

I've added screenshots below if anyone needs them.

[1][1]
[2][2]
[3][3]
[4][4]

- PS I have already tried these options, gives an error 

```<link type="text/css" href="{% static 'women/css/styles.css' %}" rel="stylesheet" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="shortcut icon" href="{% static 'women/images/main.ico' %}" type="image/x-icon"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">```

  [1]: https://i.stack.imgur.com/3exw2.png
  [2]: https://i.stack.imgur.com/ye5k7.png
  [3]: https://i.stack.imgur.com/ZKSs6.png
  [4]: https://i.stack.imgur.com/eQRvd.png

CodePudding user response:

Don't know if its the same issue but I find clearing the cache can fix styling issues (ctrl f5)

CodePudding user response:

Check static dirs in settings.py and correct static dirs, because it may cause issues in connecting with dirs.

[for reference I am giving you settings of static dirs below]

settings.py

 STATIC_URL = "/static/"
 STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
 MEDIA_URL = "/media/"
 MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media")

If the settings are okay then remember whenever you change something in CSS browser doesn't Change CSS directly you need to make a hard reset your browser's tab by pressing

Ctrl   shift   R

CodePudding user response:

Make sure to collectstatic after you make changes in files of your static folder.

python manage.py collectstatic
  • Related