有什么想法可以让页面中的元素全屏显示吗?
例如,div 还是 img?
“全屏”是指它应该占据用户屏幕的所有空间,就像我们使用全屏模式观看视频一样。我不想显示浏览器窗口的任务栏/菜单栏。
有什么想法吗?
div.fullscreen{
display:block;
/*set the div in the top-left corner of the screen*/
position:absolute;
top:0;
left:0;
/*set the width and height to 100% of the screen*/
width:100%;
height:100%;
background-color:red
}
我试过上面的代码,但它不是我想要的,它只是占用了浏览器内容区域的所有空间,而不是用户计算机屏幕。
最佳答案
HTML 元素不能超出浏览器文档窗口的边界。菜单和工具栏位于文档窗口(浏览器窗口的子窗口)之外,因此您无法“访问”它们。
我认为唯一的解决方案是使用 JavaScript 触发全屏模式。
此答案显示了如何做到这一点:How to make the window full screen with Javascript (stretching all over the screen)
关于html - 在网页中使一个元素全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5194828/