gpt4 book ai didi

jquery - 如何使用 jquery 和 css vh 正确调整高度和宽度

转载 作者:行者123 更新时间:2023-11-28 15:23:38 25 4
gpt4 key购买 nike

我刚刚接触 CSS3 并且使用现有代码。请检查以下链接。

http://tinyurl.com/lncfmd4 |用户名 - vts 密码 - vts

我的问题是在 1920x1080 分辨率下,顶部栏的高度是 8vh,看起来不错。

但是使用 1360x768 时,顶部栏会缩小到更小,并且菜单无法正常显示。

下面是负责调整高度和宽度的JQuery,请问有什么解决办法吗?

function check_height(){
var t = $('#thidden').val();
var d = $('#dhidden').val();
var r = $('#rhidden').val();
var l = $('#lhidden').val();
var w = $('.right_header').width();
w = w+27;
var h = $('.footer').height();
h = h + 30;
if(t==0 && d==0 && r==0 && l==0){
$(".right_header").animate({"margin-top":"0vw","margin-right":"0vw","height":"64vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"0vw","margin-left":"0vw","height":"64vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"0vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"0vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"64vh","width":"71vw","margin-left":"16.75vw","margin-top":"8vh"},200);
$("#r_controls").animate({"right":w+"px","top":"37%"},200);
$("#l_controls").animate({"left":"16.75vw","top":"37%"},200);
$("#t_controls").animate({"left":"50%","top":"8vh"},200);
$("#d_controls").animate({"left":"50%","bottom":h+"px"},200);
}
if(t==0 && d==0 && r==0 && l==1){
$(".right_header").animate({"margin-top":"0vw","margin-right":"0vw","height":"64vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"0vw","margin-left":"-16.75vw","height":"64vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"0vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"0vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"64vh","width":"87.75vw","margin-left":"0vw","margin-top":"8vh"},200);
$("#r_controls").animate({"right":w+"px","top":"37%"},200);
$("#l_controls").animate({"left":"0vw","top":"37%"},200);
$("#t_controls").animate({"left":"50%","top":"8vh"},200);
$("#d_controls").animate({"left":"50%","bottom":h+"px"},200);
}

if(t==0 && d==0 && r==1 && l==0){
$(".right_header").animate({"margin-top":"0vw","margin-right":"-12.25vw","height":"64vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"0vw","margin-left":"0vw","height":"64vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"0vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"0vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"64vh","width":"83.25vw","margin-left":"16.75vw","margin-top":"8vh"},200);
$("#r_controls").animate({"right":"27px","top":"37%"},200);
$("#l_controls").animate({"left":"16.75vw","top":"37%"},200);
$("#t_controls").animate({"left":"50%","top":"8vh"},200);
$("#d_controls").animate({"left":"50%","bottom":h+"px"},200);
}
if(t==0 && d==0 && r==1 && l==1){
$(".right_header").animate({"margin-top":"0vw","margin-right":"-12.25vw","height":"64vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"0vw","margin-left":"-16.75vw","height":"64vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"0vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"0vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"64vh","width":"100vw","margin-left":"0vw","margin-top":"8vh"},200);
$("#r_controls").animate({"right":"27px","top":"37%"},200);
$("#l_controls").animate({"left":"0vw","top":"37%"},200);
$("#t_controls").animate({"left":"50%","top":"8vh"},200);
$("#d_controls").animate({"left":"50%","bottom":h+"px"},200);
}

if(t==0 && d==1 && r==0 && l==0){
$(".right_header").animate({"margin-top":"0vw","margin-right":"0vw","height":"92vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"0vw","margin-left":"0vw","height":"92vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"-30vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"0vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"92vh","width":"71vw","margin-left":"16.75vw","margin-top":"8vh"},200);
$('.FixedHeader_Cloned').hide();
$("#r_controls").animate({"right":w+"px","top":"50%"},200);
$("#l_controls").animate({"left":"16.75vw","top":"50%"},200);
$("#t_controls").animate({"left":"50%","top":"8vh"},200);
$("#d_controls").animate({"left":"50%","bottom":"30px"},200);
}

if(t==0 && d==1 && r==0 && l==1){
$(".right_header").animate({"margin-top":"0vw","margin-right":"0vw","height":"92vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"0vw","margin-left":"-16.75vw","height":"92vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"-30vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"0vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"92vh","width":"87.75vw","margin-left":"0vw","margin-top":"8vh"},200);
$('.FixedHeader_Cloned').hide();
$("#r_controls").animate({"right":w+"px","top":"50%"},200);
$("#l_controls").animate({"left":"0vw","top":"50%"},200);
$("#t_controls").animate({"left":"50%","top":"8vh"},200);
$("#d_controls").animate({"left":"50%","bottom":"30px"},200);
}

if(t==0 && d==1 && r==1 && l==0){
$(".right_header").animate({"margin-top":"0vw","margin-right":"-12.25vw","height":"92vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"0vw","margin-left":"0vw","height":"92vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"-30vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"0vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"92vh","width":"83.25vw","margin-left":"16.75vw","margin-top":"8vh"},200);
$('.FixedHeader_Cloned').hide();
$("#r_controls").animate({"right":"27px","top":"50%"},200);
$("#l_controls").animate({"left":"16.75vw","top":"50%"},200);
$("#t_controls").animate({"left":"50%","top":"8vh"},200);
$("#d_controls").animate({"left":"50%","bottom":"30px"},200);
}

if(t==0 && d==1 && r==1 && l==1){
$(".right_header").animate({"margin-top":"0vw","margin-right":"-12.25vw","height":"92vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"0vw","margin-left":"-16.75vw","height":"92vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"-30vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"0vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"92vh","width":"100vw","margin-left":"0vw","margin-top":"8vh"},200);
$('.FixedHeader_Cloned').hide();
$("#r_controls").animate({"right":"27px","top":"50%"},200);
$("#l_controls").animate({"left":"0","top":"50%"},200);
$("#t_controls").animate({"left":"50%","top":"8vh"},200);
$("#d_controls").animate({"left":"50%","bottom":"30px"},200);
}

if(t==1 && d==0 && r==0 && l==0){
$(".right_header").animate({"margin-top":"-3vw","margin-right":"0vw","height":"70vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"-3vw","margin-left":"0vw","height":"70vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"0vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"-8vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"70vh","width":"71vw","margin-left":"16.75vw","margin-top":"0vh"},200);
$("#r_controls").animate({"right":w+"px","top":"37%"},200);
$("#l_controls").animate({"left":"16.75vw","top":"37%"},200);
$("#t_controls").animate({"left":"50%","top":"0vh"},200);
$("#d_controls").animate({"left":"50%","bottom":h+"px"},200);
}

if(t==1 && d==0 && r==0 && l==1){
$(".right_header").animate({"margin-top":"-3vw","margin-right":"0vw","height":"70vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"-3vw","margin-left":"-16.75vw","height":"70vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"0vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"-8vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"70vh","width":"87.75vw","margin-left":"0vw","margin-top":"0vh"},200);
$("#r_controls").animate({"right":w+"px","top":"37%"},200);
$("#l_controls").animate({"left":"0vw","top":"37%"},200);
$("#t_controls").animate({"left":"50%","top":"0vh"},200);
$("#d_controls").animate({"left":"50%","bottom":h+"px"},200);
}

if(t==1 && d==0 && r==1 && l==0){
$(".right_header").animate({"margin-top":"-3vw","margin-right":"-12.25vw","height":"70vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"-3vw","margin-left":"0vw","height":"70vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"0vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"-8vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"70vh","width":"83.25vw","margin-left":"16.75vw","margin-top":"0vh"},200);
$("#r_controls").animate({"right":"27px","top":"37%"},200);
$("#l_controls").animate({"left":"16.75vw","top":"37%"},200);
$("#t_controls").animate({"left":"50%","top":"0vh"},200);
$("#d_controls").animate({"left":"50%","bottom":h+"px"},200);
}

if(t==1 && d==0 && r==1 && l==1){
$(".right_header").animate({"margin-top":"-3vw","margin-right":"-12.25vw","height":"70vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"-3vw","margin-left":"-16.75vw","height":"70vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"0vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"-8vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"70vh","width":"100vw","margin-left":"0vw","margin-top":"0vh"},200);
$("#r_controls").animate({"right":"27px","top":"37%"},200);
$("#l_controls").animate({"left":"0vw","top":"37%"},200);
$("#t_controls").animate({"left":"50%","top":"0vh"},200);
$("#d_controls").animate({"left":"50%","bottom":h+"px"},200);
}

if(t==1 && d==1 && r==0 && l==0){
$(".right_header").animate({"margin-top":"-3vw","margin-right":"0vw","height":"100vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"-3vw","margin-left":"0vw","height":"100vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"-30vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"-8vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"100vh","width":"71vw","margin-left":"16.75vw","margin-top":"0vh"},200);
$('.FixedHeader_Cloned').hide();
$("#r_controls").animate({"right":w+"px","top":"50%"},200);
$("#l_controls").animate({"left":"16.75vw","top":"50%"},200);
$("#t_controls").animate({"left":"50%","top":"0vh"},200);
$("#d_controls").animate({"left":"50%","bottom":"30px"},200);
}

if(t==1 && d==1 && r==0 && l==1){
$(".right_header").animate({"margin-top":"-3vw","margin-right":"0vw","height":"100vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"-3vw","margin-left":"-16.75vw","height":"100vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"-30vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"-8vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"100vh","width":"87.75vw","margin-left":"0vw","margin-top":"0vh"},200);
$('.FixedHeader_Cloned').hide();
$("#r_controls").animate({"right":w+"px","top":"50%"},200);
$("#l_controls").animate({"left":"0vw","top":"50%"},200);
$("#t_controls").animate({"left":"50%","top":"0vh"},200);
$("#d_controls").animate({"left":"50%","bottom":"30px"},200);
}

if(t==1 && d==1 && r==1 && l==0){
$(".right_header").animate({"margin-top":"-3vw","margin-right":"-12.25vw","height":"100vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"-3vw","margin-left":"0vw","height":"100vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"-30vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"-8vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"100vh","width":"83.25vw","margin-left":"16.75vw","margin-top":"0vh"},200);
$('.FixedHeader_Cloned').hide();
$("#r_controls").animate({"right":"27px","top":"50%"},200);
$("#l_controls").animate({"left":"16.75vw","top":"50%"},200);
$("#t_controls").animate({"left":"50%","top":"0vh"},200);
$("#d_controls").animate({"left":"50%","bottom":"30px"},200);
}

if(t==1 && d==1 && r==1 && l==1){
$(".right_header").animate({"margin-top":"-3vw","margin-right":"-12.25vw","height":"100vh","width":"12.25vw"},200);
$(".left_header").animate({"margin-top":"-3vw","margin-left":"-16.75vw","height":"100vh","width":"16.75vw"},200);
$(".footer").animate({"margin-bottom":"-30vh","height":"30vh","width":"100%"},200);
$("nav").animate({"margin-top":"-8vh","height":"8vh","width":"100%"},200);
$("#map-canvas").animate({"height":"100vh","width":"100vw","margin-left":"0vw","margin-top":"0vh"},200);
$('.FixedHeader_Cloned').hide();
$("#r_controls").animate({"right":"27px","top":"50%"},200);
$("#l_controls").animate({"left":"0vw","top":"50%"},200);
$("#t_controls").animate({"left":"50%","top":"0vh"},200);
$("#d_controls").animate({"left":"50%","bottom":"30px"},200);
}

setTimeout(function () {HomeJS._mapResize();}, 200);
}

最佳答案

关于jquery - 如何使用 jquery 和 css vh 正确调整高度和宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29847224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com