我使用 HTML 和 Django 来创建一个 Web 应用程序。我需要将 div 放在屏幕的右侧。它正在这样做,但它低于其他小部件。它看起来像这样:
我圈出的地方是div所在的位置,但它需要在顶部的右侧。
这是我的 HTML 文件:
{% load static %}
{% load crispy_forms_tags %}
{{object.destination}} in {{trip_length}} days
{% block content %}
{{object.destination}} in {{trip_length}} days
Find Places
Find Hotels
{% if place_results_name %}
{{place_results_name}}
Place description...
{% endif %}
{% endblock %}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
这里是响应式设计(使用了col-md)所以,全屏打开看看:
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" /> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <div class="row d-flex justify-content-between"> <!-- left side --> <div class="col-md-7"> <div class="row border"> <form class="p-4 mb-4"> <h2>Find Places</h2> <input type="text" class="form-control" /> <button class="btn btn-primary mt-2">find place</button> </form> </div> <!-- --> <br /> <!-- --> <div class="row border"> <form class="p-4 mt-4"> <h2>Find Places</h2> <input type="text" class="form-control" /> <button class="btn btn-primary mt-2">find place</button> </form> </div> </div> <!-- right side --> <div class="col-md-4 d-flex justify-content-center"> <img src="" alt="" style="width: 200px; height: 200px; background-color: lightgreen" /> </div> </div> </div> </body> </html>