提问者:小点点

Div元素在网页上不显示/不可见


我正在编写一个基本的HTML CSS代码来尝试一些东西。在css中样式化一个div后,该div就从网页中消失了。

请帮帮忙。

下面是代码。代码非常基本。

谢谢!

null

.bx1 {
  bottom: 50;
  left: 40;
  position: fixed;
}

.box {
  width: 80%;
  height: 2000px;
  background: green;
  margin: 20px auto;
}
<div class="box"></div>
<div class="bx1">
  <h1>Hello</h1>
</div>

null


共1个答案

匿名用户

请不要留下底部和左侧的空白单位。


.bx1{
    bottom: 50px;
    left: 40px;
    position: fixed;
}


null

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style> 
.bx1{
bottom: 50px;
left: 40px;
width: 100px;
height: 100px;
position: fixed;
background: red;
}

.box{
width: 80%;
height: 2000px;
background: green;
margin: 20px auto;

}
</style>
</head>
<body>
    <div class="box"></div>
    <div class="bx1">
        <h1>Hello</h1>
    </div>
    
    
</body>
</html>