如何将div放在另一个div中?

时间:2017-07-14 08:52:22

标签: html css

如何将一个div放在另一个div中?

谢谢!

2 个答案:

答案 0 :(得分:1)

这里有一些基本的语法问题:

  • 您应该停止使用div来封装图片代码,而是使用HTML5中的figure代码。

  • 您应该(由 Hevlastka 评论)删除<img>标记中定义的大小,并在CSS中定义。< / p>

  • 您已设置max-width而未设置基于IE浏览器的width <style>

    • IE10和IE11似乎不支持使用初始值覆盖最小宽度或最大宽度值。
    • IE7不支持输入按钮/提交按钮/重置按钮的最小宽度。
    • max-width不适用于IE中的表格单元格中的图像。
  • 使用cause issues 强烈推荐 esp。如果您不想使用javascript )。

  • 您应该尽量避免使用<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Title is REQUIRED in HTML head area</title> <style> div { text-align:center; } /* The picture and the div must be Centered inside their container! */ figure { border: 1px solid red; padding:20px; text-align:center; display:inline-block; margin:auto; } img { border: 1px solid black; width: 100%; max-width:640px; height: auto; margin:auto; } </style> </head> <body> <div> <figure> <img src="https://image.ibb.co/bE3eVF/my_Picture.jpg"> </figure> </div> </body> </html> 的习惯,而是将CSS放在自己的特定文件中,以便HTML文件调用。

编辑我曾经在IE 11和Edge上使用它的代码:

<form method='POST' action="/" enctype='multipart/form-data'>
 {% load widget_tweaks %}
 {% csrf_token %}
 {{ form.first_name |add_class:"customCSS1 customCSS2" }}
 {{ form.second_name |add_class:"form-control customCSS4" }}
</form>
{{ form.media.js }}

答案 1 :(得分:0)

添加Modernnizr.js正在解决问题。

<head>标记之间添加此内容。

<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js"></script>

并从CSS中删除display: table;

enter image description here