2017-05-07 32 views
0

任何人都可以请告诉我为什么按钮标记不在div内工作?

#ss { 
 
    background-color: black; 
 
    width: 1500px; 
 
    height: 80px; 
 
    overflow-x: 0; 
 
    margin-top: -8px; 
 
    margin-left: -200px; 
 
    opacity: 0.5; 
 
} 
 

 
#as { 
 
    background-color: red; 
 
    width: 70px; 
 
    height: 40px; 
 
} 
 

 
#bd { 
 
    background-color: grey; 
 
    background-image: url("use.jpg"); 
 
}
<body id="bd"> 
 

 
    <div id="ss"> 
 

 
    <button id="as"> Click me </button> 
 

 
    </div> 
 

 
</body>

按钮标签没有在div容器内工作,IDK的原因,它的工作原理股利外,但不是在它里面..

+0

您还应该添加到您的html代码 – 2017-05-07 12:48:15

+0

\t <体ID = “BD”> \t

\t \t
\t –

+0

由于不当格式化,从提问代码disapperard。所以我没有看到 – 2017-05-07 12:50:45

回答

0

你的按钮是页面的边界作为外您添加负x-轴余量到div

UPDATE:

保证金从身体移除。

body { 
 
    margin: 0; 
 
} 
 

 
#ss { 
 
    background-color: black; 
 
    width: 1500px; 
 
    height: 80px; 
 
    overflow-x: 0; 
 
    margin-top: -8px; 
 
    /*margin-left: -200px; */ // this causes the issue 
 
    opacity: 0.5; 
 
} 
 

 
#as { 
 
    background-color: red; 
 
    width: 70px; 
 
    height: 40px; 
 
} 
 

 
#bd { 
 
    background-color: grey; 
 
    background-image: url("use.jpg"); 
 
}
<body id="bd"> 
 

 
    <div id="ss"> 
 

 
    <button id="as"> Click me </button> 
 

 
    </div> 
 

 
</body>

+0

非常感谢。它的工作,但现在有另一个问题,顶栏不按我想要的方式工作。我的意思是屏幕左侧和酒吧之间有空间。我想将它设置为全宽。 –

+0

将“margin:0”添加到主体 – 2017-05-07 12:57:02

+0

好吧,现在就开始工作吧。谢谢xx –

相关问题