html - 内部内容将 div 向下推

标签 html css

我有一个关于 div 的问题。当我将内容添加到内部 div 时,我在父 div 中有多个 div。内部 div 被向下推?

我想知道为什么?因为我所有的margins和padding都是加default 0;

感谢您的宝贵时间。

https://jsfiddle.net/3w50gj28/

<div class="boxes">
<div class="box">
    <h3>MyBMW Login</h3>
    <form class="" action="index.html" method="post">
        <input type="text" name="email" placeholder="Emailadres">
        <input type="password" name="password" placeholder="Wachtwoord">
    </form>
</div>
<div class="box">

</div>
<div class="box">

</div>
<div class="box">

</div>


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.boxes {
margin-top: 25px;
width: 100%;
position: relative;
text-align: center;

.box {
    display: inline-block;
    width: 300px;
    max-height: 400px;
    min-height: 233px;
    padding: 15px;
    border: 1px solid #e6e6e6;
    overflow-wrap: break-word;
    background-color: #fff;
    margin-right: 20px;;
}

最佳答案

div 是 block 级元素, block 级元素总是在新行开始并占据可用的全部宽度

关于html - 内部内容将 div 向下推,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43020666/

相关文章:

jquery - 无法更改 Slick Carousel 中的 nextArrow 和 prevArrow

javascript - 带圆 Angular 的图像

css - 使用 Flexbox 收缩包装并居中包含内联 block 子元素的元素

HTML/CSS : Make Border-right height dynamic

jQueryUI 可丢弃和可排序 - 无法更改顺序和一些我无法修复的错误

html - Bootstrap 垂直对齐列内容与移动优化

Javascript 或 Jquery 检测页面刷新并重定向到错误页面 - 避免重复数据提交

javascript - 一键刷新2个div Jquery

java - 带有动态信息的工具提示弹出窗口

html - 是否有新的标准网页宽度?多少像素?