gpt4 book ai didi

html - Div 添加滚动条即使溢出 : hidden

转载 作者:行者123 更新时间:2023-11-28 02:01:33 25 4
gpt4 key购买 nike

我想要做的是拥有一个全屏背景,上面有一个径向图像,没有滚动条。现在它有点管用。我的意思是,即使有 overflow: hidden,带有径向渐变 (img) 的 div 也会添加一个滚动条。

html { 
background: url(background.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover
}


#glow{
width:1043px;
height:763px;
position:absolute;
left:50%;
top:50%;
background-image: url('outer_glow.png');
margin-left:-543px; /* Negative half the width*/
margin-top:-381px; /* Negative half the height */
overflow: hidden;
}

我想要做的是,如果图像径向太大而无法将其切掉并居中。但目前它仍然在我的浏览器中显示一个竖线。下面的 html

<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="styleit.css" rel="stylesheet">
<title>Title</title>
</head>
<body>
<div id="glow"></div>
</body>
</html>

最佳答案

这里的问题是您没有考虑到 DOM 树中的最后一个节点是 body 元素。

实际情况是,当您调整窗口大小时,主体发现其子项比自身大,因此显示滚动条。

尝试将此添加到您的 CSS:

body {
overflow: hidden;
}

关于html - Div 添加滚动条即使溢出 : hidden,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13664007/

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