A
A
Alexander Proshchenkov2018-07-05 12:43:49
Django
Alexander Proshchenkov, 2018-07-05 12:43:49

Why is css only applied to the parent template?

Css styles are applied only to base_generic.html, index.htnl inherits this template, but styles are not applied to it. Why?
base_generic:

<!DOCTYPE html>
<html lang="en">
<head>
  
  {% block title %}<title>Base</title>{% endblock %}


  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  
  {% load static %}
  <link rel="icon" type="image/png" href="{% static 'img/favicon.png' %}" />
  {% block static %}<link rel="stylesheet" href="{% static 'css/styles.css' %}">{% endblock %}
</head>

<body>

  <div class="container">

    {% block sidebar %}
    {% endblock %}

    <div class="pt-3">{% block content %}{% endblock %}</div>
  </div>
  
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>

index.htnl:
{% extends "base_generic.html" %}

{% block content %}

<h3 class="list">Домашняя страница</<h3><p></p>

{% endblock %}

css:
.list{
  font-size: 34px;
}
.navbar-brand {
  font-size: 1.5rem;
}
.navbar-brand :hover{
  text-decoration: underline;
}
.nav-item :hover{
  text-decoration: underline;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Web Dentist, 2018-07-05
@Keltor

Link to the repository in the studio.

A
Astrohas, 2018-07-05
@Astrohas

Move Load static to the top, and rename if the block is static to something else

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question