为什么 CSS :hover 伪类不起作用?

问题描述 投票:0回答:1

我是初学者,我尝试设计一个导航栏。我需要在悬停时放大项目的大小。我为此编写了 css 代码,但它不起作用。所以我需要你的帮助

下面提到我写的CSS代码

.header1 {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    margin-top: 0;
    
    position: relative;
    ;
    height: 115px;
}

.nav {
    list-style-type: none;
    margin: 0;
    padding-left: 100px;
    overflow: hidden;


}

.nav li {
    display: inline;
    padding: 30px;
    color: aliceblue;
    font-family: DejaVu Sans Mono, monospace;
    font-size: 30px;
    font-weight: bold;
    
}

h1 {
    padding-left: 0px;
    margin-left: 0px;
    color: aliceblue;
    font-family: DejaVu Sans Mono, monospace;
    font-size: 30px;
}

body {
    background-image:url('bg3.jpg');
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center top;
    background-attachment: fixed;
    margin: 0;
}

.header1:hover {
    background-color: black;

}

li :hover {
    transform:scale(1,2)
}

我需要在悬停时缩放列表项!

html css hover html-lists
1个回答
1
投票

你需要删除 li 和 :hover 之间的空格,如下所示:

li:hover {
    transform:scale(1,2)
}
© www.soinside.com 2019 - 2024. All rights reserved.