我的html代碼非常簡單,只是爲了測試css max-width和flexbox顯示。我的目標是將按鈕寬度設置爲190px,但不起作用。如果我刪除我的.header中的顯示CSS,它將工作。 請解釋我這裏有什麼問題? 感謝在子div最大寬度不起作用(父div有flex顯示)
這裏是我的html代碼:
.header {
padding:0;
background-color: #16325C;
height: 60px;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.header ul {
list-style:none;
margin:0;
padding:0;
}
.menu {
-webkit-align-self: center;
-ms-flex-item-align: center;
align-self: center;
width: 100%;
display: inline-block;
}
.menu > .dropdown {
display: block;
max-width: 190px;
}
.menu > .dropdown > button {
background-color: white;
width: 100%;
text-align: left;
color: #16325C;
}
<div class="header">
<ul class="left">
<li class="menu">
<div class="dropdown">
<button>
Text
</button>
</div>
</li>
</ul>
</div>