<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 7 年前。
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 7 年前。
我有一个矩形的灰色 div,它应该包含一个标题(“示例文本”)和一个薄的绿松石突出显示(它也只是一个薄的矩形)。当我在另一个 div 中同时拥有绿松石 div 和 header 时,其中一个被强制退出。
首先,我该如何解决这个问题?另外,有没有更有效的方法让我在灰色 div 中突出绿松石色?
http://imgur.com/Sm8qy8J,kSuNEh5 (如果我有如图所示的 HTML)
http://imgur.com/Sm8qy8J,kSuNEh5#1 (如果我删除绿松石 div)
<div class="column w2">
<div id="headerbox">
<div class="highlightbox">
</div>
<h3>sample text</h3>
</div>
</div>
注意我在这里使用了一些 Sass CSS:
h3 {
font: $header-type-font;
font-family: $header-type-font;
color: $header-type-color;
text-align: center;
}
#headerbox {
background-color: $box-color;
height: $block-height;
width: 400px;
}
.highlightbox {
background-color: $highlight-color;
height: $block-height;
width: 20px;
}
最佳答案
将 float:left
添加到您的 highlightbox
类:
.highlightbox {
background-color: $highlight-color;
height: $block-height;
width: 20px;
float:left;
}
关于html - DIV 中未对齐的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31484625/