html - 如何防止CSS block 元素影响父内联 block

标签 html css

我遇到了内联 block 父级中的元素问题。一个元素的子元素正在影响另一个元素。这很难解释,但在我的 fiddle 中很容易看到,右侧的 div 被推下。

我尝试过各种方法,但我确信有一个简单的解决方案。如有任何建议,我们将不胜感激。

http://jsfiddle.net/62asy/

HTML:

<div id="schedule"> 
            <div class="scheduleChoice">Leagues
                <select name="leagueList" id="leagueList" class="scheduleChoiceList">
                    <option value="0">Select a League</option>
                                    <option value="leagueId_246"> Aassss</option>

                                    <option value="leagueId_245"> aaa</option>
                                                    </select>
                <select name="teamList" id="teamList" class="scheduleChoiceList">
                </select>
                <div class="scheduleChoiceSubmit">Submit</div>
            </div>
            <div class="scheduleChoice">Arena
                <select name="arenaList" id="arenaList" class="scheduleChoiceList">
                    <option value="0">Select an Arena</option>
                                    <option value="arenaId_2"> ffffff</option>

                                    <option value="arenaId_1"> ffffff</option>
                                                    </select>
                <div class="scheduleChoiceSubmit">Submit</div>
            </div>                  
        </div>

CSS:

#schedule {
background-color: rgba(0, 0, 0, 0.44);
overflow: hidden;
text-align: center;
}
.scheduleChoice {
display: inline-block;
width: 25%;
background-color: rgba(190, 216, 255, 0.54);
height: 200px;
padding: 5px;
border-radius: 5px;
margin: 20px 25px;
}
.scheduleChoiceList {
width: 200px;
padding: 5px;
border-radius: 4px;
display: block;
margin: 10px auto;
}

最佳答案

添加垂直对齐顶部

.scheduleChoice {
  vertical-align: top;
}

编辑 fiddle

http://jsfiddle.net/62asy/1/

关于html - 如何防止CSS block 元素影响父内联 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24337085/

相关文章:

css - 需要使 DIV 显示为 float 页脚,在调整窗口大小时将保留在 iframe 前面

css - 我需要帮助让我的内容 div 容器环绕两个内部 div!

jquery - Bootstrap : navigation and content won't detect mobile

jquery - 在页面加载后,您如何不关注表单中的任何输入文本字段?

html - 表格多列宽

javascript - 拖放不属于同一容器的元素

html - 如何让两个按钮排成一行?

html - 为什么 iframing yahoo.com 可以没有任何滚动条,而 iframing google.com 会有滚动条?

html - 列出不从父级继承样式的元素

javascript - 在面板中添加关闭图标