如何将一个div放在另一个div中?
谢谢!
答案 0 :(得分:1)
这里有一些基本的语法问题:
您应该停止使用div
来封装图片代码,而是使用HTML5中的figure
代码。
您应该(由 Hevlastka 评论)删除<img>
标记中定义的大小,并在CSS中定义仅。< / p>
您已设置max-width
而未设置基于IE浏览器的width
<style>
。
使用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)