Html 父对象中对齐的内联块元素

Html 父对象中对齐的内联块元素,html,css,Html,Css,我有一个1200px宽的容器和4个250px宽的内联块子级 我是否可以在家长的内部为他们辩护?例如,我希望第一个元素在左边没有边距,最后一个元素在右边没有边距,元素之间的边距相等 在容器上使用display flex .container { display:flex; /* make the container a flex container */ justify-content: space-between /* justify the flex items on the m

我有一个1200px宽的容器和4个250px宽的内联块子级


我是否可以在家长的内部为他们辩护?例如,我希望第一个元素在左边没有边距,最后一个元素在右边没有边距,元素之间的边距相等

在容器上使用display flex

.container { 
   display:flex; /* make the container a flex container */
   justify-content: space-between /* justify the flex items on the main axis */
}

有关更多详细信息,请参见,当然,使用flexbox:

HTML

<div class="parent">
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
</div>
了解更多关于

您也可以尝试:

HTML与上述内容相同

CSS

.parent{
    display:flex;
    flex-direction: row;
    justify-content: space-between;
}
.parent{
   display:table
}

.parent > .child{
   display: table-cell;
   float: none;
}

在容器上使用display flex
.container{display:flex;justify content:space between}
非常感谢!成功了