作者:hyl7758521_948 | 来源:互联网 | 2023-01-02 03:23
如何使 ul
in的 .menu-sub-col
宽度等于内容宽度?
https://fiddle.jshell.net/j9ujfL2n/3/
.menu {
position: absolute;
z-index: 90;
display: flex;
flex-direction: row;
top: 40px;
left: 0;
transition: transform 0.25s ease-in-out;
transform: translateY(-100%);
visibility: hidden;
}
.menu--visible {
transform: translateY(0);
visibility: visible;
}
.menu ul {
list-style-type: none;
padding: 0;
margin: 0;
}
.menu li {
cursor: pointer;
}
.menu-main {
background-color: #3E5AE2;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
height: max-content;
}
.menu-main li {
position: relative;
padding: 10px 20px;
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
color: rgba(255, 255, 255, 0.7);
font-size: 14px;
}
.menu-main li:hover {
color: #fff;
}
.menu-main li.active {
background-color: #4B67E8;
color: #fff;
}
.menu-main li.active:after {
content: '';
position: absolute;
right: -8px;
top: calc(50% - 8px);
width: 0;
height: 0;
border-style: solid;
border-width: 8px 0 8px 8px;
border-color: transparent transparent transparent #4B67E8;
clear: both;
}
.menu-main li i {
margin-right: 15px;
}
.menu-sub:not(:empty) {
padding: 20px 30px;
display: flex;
flex-direction: row;
background: #fff;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
}
.menu-sub-col {
padding-right: 25px;
}
.menu-sub-col:not(:last-child) {
border-right: 1px solid #eeeeee;
margin-right: 25px;
}
.menu-sub-col h4 {
color: #bdbdbd;
font-size: 12px;
text-transform: uppercase;
}
.menu-sub-col ul {
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-content: space-between;
max-height: 180px;
}
.menu-sub-col li {
flex: 1 1 auto;
font-size: 12px;
font-weight: 500;
padding: 5px 4px;
padding-left: 0;
opacity: 0.75;
}
.menu-sub-col li:hover {
color: #ffffff;
opacity: 1;
background: #4b67e9;
box-shadow: -10px 0px 0px #4b66ea, 10px 0px 0px #4b66ea;
transition: box-shadow 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
border-radius: 3px;
}
.menu-sub-col li i {
margin-right: 8px;
}