![45px 45px]()
本文介绍了如何自定义HTML的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 你好, i尝试自定义html菜单的高度,这与浏览器的总高度相同 但是我发现当我将菜单的高度设置为100% 这不是我想要的高度 我设置高度之前我做了一个标题栏 所以我发现我的html文件的高度等于标题栏的高度+网页浏览器高度的100% 当我尝试将高度设置为: 身高:100% - (标题栏高度值) 我的菜单值恢复正常大小 任何人都可以更正我的代码吗? 我将附上我的代码 b $ b 我尝试过: .titleBar { 身高:45; } .navMenu { 身高:100% - 45px ; }hello,i try to customize the height of my menu for html which are equally with the total height of my browserbut i found that when i set the height of my menu as 100%it was not the height i wantbefore i set the height i made a title barso i found that the height of my html file was equal to my height of title bar + 100% of the height of web browserwhen i try to set the height as :height : 100% - (value for the height of title bar )the value of my menu return to the normal sizecan anyone correct my code?I will attach my code belowWhat I have tried:.titleBar{height : 45;}.navMenu{height : 100% - 45px;}推荐答案基于的设置一些维度父容器的某个百分比,您必须首先设置父容器的维度。例如To set some dimension based on certain percentage of the parent container, you must set the dimension of the parent container first. e.g.<!DOCTYPE html><html><head><style>html, body {height: 100%;margin:0 }div { height:100%; background:green;}</style></head><body><div>Menu</div></body></html>或者,你可以使用vh参考: 1。 CSS单位 [ ^ ] 2. 视口单位:vw,vh,vmin,vmax - 网页设计周刊 [ ^ ]Refer:1. CSS Units[^]2. Viewport units: vw, vh, vmin, vmax - Web Design Weekly[^] 这篇关于如何自定义HTML的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-03 03:53