Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
327 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>

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

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...