问题:我试图让所有元素对齐并适合一个 div 而不会溢出。如果父 div 设置为溢出:隐藏,为什么有些 div 会突出?我怎样才能解决这个问题?
示例:http: //jsfiddle.net/YNS8b/
谢谢!
代码:
<div id = "top_bar" >
<div id="top_left_button" >border</div>
<div class="trapezoid-border"></div>
<div class="trapezoid"> border </div>
</div>
#top_bar{
background-color: #000;
border-bottom: 1px solid #666;
color: #222;
position:fixed;
left:0px;
top: 0px;
width:100%;
overflow:hidden;
height: 50%;
font-weight: normal;
white-space: nowrap;
color: white;
z-index:20;
line-height: 45px;
min-width:320px;
max-width: 320px;
max-height:48px;
border-radius: 5px;
text-shadow: rgba(0,0,0,0.6) 0px -1px 0px;
}
#top_bar:after {
content: '';
width: 10%;
display: inline-block;
font-size: 0;
line-height: 0
}
.trapezoid{
vertical-align: middle;
position:absolute;
border-bottom: 60px solid #446DB2;
border-left: 45px solid transparent;
border-top-left-radius:30px;
*border-top-right-radius:15px;
*border-bottom-right-radius:3px;
height: 0;
width: 50px;
display: inline-block;
right:1px;
z-index: 100;
}
.trapezoid-border{
vertical-align: middle;
position:absolute;
border-bottom: 60px solid rgba(225, 225, 225, 0.5); /* Color Changed will be pseudo-border color */
border-left: 45px solid transparent;
border-top-left-radius:30px;
*border-top-right-radius:15px;
*border-bottom-right-radius:3px;
height: 0;
width: 53px; /* Extra 3 pix when compared to .trapezoid class width */
display: inline-block;
right:1px;
}
#top_left_button {
color: white;
height: 100%;
overflow:hidden;
display: inline-block;
text-align: center;
vertical-align: middle;
}
#top_left_button{
width: 20%;
border-right: 2px solid #666;
background-color: #446DB2
}