html改变下拉框的大小,调整屏幕大小时,HTML导航栏下拉框内容无法正确调整大小...

2 个答案:

答案 0 :(得分:2)

如下所示修改媒体查询

.dropdown-content {

padding: 1vh 1vw;

right:10px;

}

a.dropdown-content {

padding: 1vh 1vw;

width: 98%;

}

.dropdown-content a {

padding: 5vh 2.9vw;

}

body {

background-color: blue;

}

p {

color: white;

font-size: 20px;

display: inline;

padding: 20px;

font-family: arial;

}

.navbar {

list-style-type: none;

margin: 0;

padding: 0;

overflow: hidden;

background-color: rgb(10,10,10);

top: 0;

}

.navcont {

margin: 0;

position: relative;

float: left;

}

.navcont a, .dropbtn {

margin: 0;

position: relative;

display: block;

color: white;

font-size: 20px;

text-align: center;

padding: 5vh 7vw;

text-decoration: none;

border-right: 1px solid rgb(50,50,50);

border-left: 1px solid rgb(50,50,50);

}

.navcont a:hover {

transition-duration: 0.3s;

background-color: rgb(30,30,30);

}

.navcont a:active {

background-color: rgb(9,194,36);

}

.sticky {

position: sticky;

position: -webkit-sticky;

top: 0;

z-index:3

}

.dropdown:hover .dropbtn {

transition-duration: 0.3s;

background-color: red;

}

li.dropdown {

display: inline-block;

}

.dropdown-content {

display: none;

position: absolute;

background-color: #f9f9f9;

box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);

z-index: 1;

}

.dropdown-content a {

color: black;

padding: 5vh 7.4vw;

text-decoration: none;

display: block;

text-align: left;

}

.dropdown-content a:hover {

background-color: #f1f1f1

}

.dropdown:hover .dropdown-content {

display: block;

}

@media (max-width:650px) {

.navcont a {

padding: 3vh 3vw;

}

.dropdown-content {

padding: 1vh 1vw;

right:10px;

}

a.dropdown-content {

padding: 1vh 1vw;

width: 98%;

}

.dropdown-content a {

padding: 5vh 6.8vw;

}

}

@media screen and (max-width: 600px) {

.navcont a {

padding: 3vh 3vw;

}

.dropdown-content {

padding: 1vh 1vw;

right:10px;

}

a.dropdown-content {

padding: 1vh 1vw;

width: 98%;

}

.dropdown-content a {

padding: 5vh 2.9vw;

}

.dropbtn {

padding: 3vh 3vw;

}

div.tr_about {

width: 60%;

}

div.tl_about {

width: 37.5%;

}

}

答案 1 :(得分:0)

符合您要求的PFB代码

body {

background-color: blue;

}

p {

color: white;

font-size: 20px;

display: inline;

padding: 20px;

font-family: arial;

}

.navbar {

list-style-type: none;

margin: 0;

padding: 0;

overflow: hidden;

background-color: rgb(10,10,10);

top: 0;

}

.navcont {

margin: 0;

position: relative;

float: left;

width: 24% !important;

}

.navcont a, .dropbtn {

margin: 0;

position: relative;

display: block;

color: white;

font-size: 20px;

text-align: center;

padding: 5vh 7vw;

text-decoration: none;

border-right: 1px solid rgb(50,50,50);

border-left: 1px solid rgb(50,50,50);

}

.navcont a:hover {

transition-duration: 0.3s;

background-color: rgb(30,30,30);

}

.navcont a:active {

background-color: rgb(9,194,36);

}

.sticky {

position: sticky;

position: -webkit-sticky;

top: 0;

z-index:3

}

.dropdown:hover .dropbtn {

transition-duration: 0.3s;

background-color: red;

}

li.dropdown {

display: inline-block;

}

.dropdown-content {

display: none;

position: absolute;

background-color: #f9f9f9;

box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);

z-index: 1;

}

.dropdown-content a {

color: black;

padding: 5vh 7.4vw;

text-decoration: none;

display: block;

text-align: left;

}

.dropdown-content a:hover {

background-color: #f1f1f1

}

.dropdown:hover .dropdown-content {

display: block;

}

@media screen and (max-width: 600px) {

.navcont a {

padding: 3vh 3vw;

}

.dropdown-content {

padding: 3vh 3vw;

}

a.dropdown-content {

padding: 3vh 3vw;

width: 100%;

}

.dropbtn {

padding: 3vh 3vw;

}

div.tr_about {

width: 60%;

}

div.tl_about {

width: 37.5%;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值