Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

css - Django HTML Always Showing As Off Center

My base.html file is showing up halfway across the screen and I can't figure out why... There is nothing in the CSS or the base.html that should be forcing it to the right, correct? Anything else I am not considering that may be centering it?

Screeshot enter image description here

Static CSS:

body {
    font-family: Arial, Helvetica, sans-serif;
    width:800px;
    margin:auto;
}

a { 
    color:#0000EE;
    text-decoration:none;
}

a:hover {  
    text-decoration:underline;
}

#user {float:right;}

base.html

{% load static %}

<html>
<head>
    <title></title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}">
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</head>
<body>
    <div id="header">
        {% if user.is_authenticated %}
        <div id="user">
            Hello {{ user }}, <a href="{% url 'logout' %}">Logout</a>
        </div>
        {% endif %}
    </div><!-- header -->

    <header style="width: 100%; float:left; margin:0px; padding: 0px; background-color: black; display: flex; flex-direction: row; position:fixed; z-index:9999">
        <div style="width:25%; font-family:graphik; font-size: 18px; color: white; padding: 5px 0px 7px 15px;background-color: black"><a href="http://127.0.0.1:7000/" style="color:white;text-decoration: none;font-weight:bolder">Title</a></div>
        <ul style="width:70%; font-family:graphik; list-style-type: none; margin-top: 5px; padding-top: 5px; color: white">
            <li style="display:inline-block; margin:0px 20px"><a href="http://127.0.0.1:7000/" style="color:white;text-decoration: none;">Link 1</a></li>

        </ul>
        <div class="img" style="width:5%; padding:5px; color: white;float: right">
            <img class="d-block w-100" style="padding:0px 17px ;height:30px" src="{% static 'polls/images/user-icon.png' %}" alt="First slide">
        </div>
    </header>

    <div id="content">
        {% block content %}
        {% endblock %}
    </div><!-- content -->
    <div id="footer">
    </div>
</body>
</html>
question from:https://stackoverflow.com/questions/65601201/django-html-always-showing-as-off-center

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...