我的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>