Html 在没有绝对定位的情况下,将两个元素与DIV的相对侧对齐

Html 在没有绝对定位的情况下,将两个元素与DIV的相对侧对齐,html,css,Html,Css,我试图创建一个包含两个元素的DIV,a和a。它们应该位于容器的左右两侧。我使用子元素上的绝对位置成功地做到了这一点: #header2{ position: relative; padding: 0.4em; color: white; background-color: #CC3333; min-height: 100px; } h2{ position: absolute; display:inline; } #button{

我试图创建一个包含两个元素的DIV,a和a。它们应该位于容器的左右两侧。我使用子元素上的绝对位置成功地做到了这一点:

#header2{
    position: relative;
    padding: 0.4em;
    color: white;
    background-color: #CC3333;
    min-height: 100px;
}

h2{
    position: absolute;
    display:inline;
}


#button{
    position: absolute;
    text-decoration: none;
    vertical-align: middle;
    padding: .1em;
    width:100px;
    height: 80%;
    margin-right: 5px;
    right: 0;
}
现在我发现这些元素在不适合小屏幕时会重叠。我理解这是因为绝对位置,这使得这些元素忽略了布局流。因此,我试图找到一种方法来对齐相对两侧的元素,并保持div的布局流程,以使其更灵活。

一种方法是调整它们。但请记住。

为什么不能在header2上设置最小宽度?