Div 重叠另一个 div
Div overlapping another div
我正在尝试使 div 正确显示在另一个 div 下方,而不是流入 it/overlap。我尝试了各种方法,但找不到使它正确显示的方法。这是演示:http://s1.mstclan.xyz/mstinfo
和CSS代码:
body,
html {
margin: 0;
height: 100%;
width: 100%;
font-family: 'Roboto Slab';
background: #262627;
color: #FFF;
text-shadow: 1px 1px 1px #000;
}
.clearfix {
clear:both;
}
.main {
position: relative;
top: 20%;
transform: translateY(-50%);
text-align: center;
#centered {
width: 350px;
height: 150px;
margin-left: auto;
margin-right: auto;
margin-top: 45px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
border: 2px solid #FFFFFF;
}
#colour {
bottom: 5%;
color: #fff;
font-family: "Roboto", Verdana, Arial, sans-serif;
font-size: 5.4em;
font-weight: 100;
position: absolute;
right: 5%;
}
提前致谢。
这两个规则将 .main
压倒 #centered
:
top: 20%;
transform: translateY(-50%);
删除它们可以解决重叠问题。
如果要在 .main
和页面顶部之间保持一些垂直 space,请添加一点 padding-top
。
我正在尝试使 div 正确显示在另一个 div 下方,而不是流入 it/overlap。我尝试了各种方法,但找不到使它正确显示的方法。这是演示:http://s1.mstclan.xyz/mstinfo
和CSS代码:
body,
html {
margin: 0;
height: 100%;
width: 100%;
font-family: 'Roboto Slab';
background: #262627;
color: #FFF;
text-shadow: 1px 1px 1px #000;
}
.clearfix {
clear:both;
}
.main {
position: relative;
top: 20%;
transform: translateY(-50%);
text-align: center;
#centered {
width: 350px;
height: 150px;
margin-left: auto;
margin-right: auto;
margin-top: 45px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
border: 2px solid #FFFFFF;
}
#colour {
bottom: 5%;
color: #fff;
font-family: "Roboto", Verdana, Arial, sans-serif;
font-size: 5.4em;
font-weight: 100;
position: absolute;
right: 5%;
}
提前致谢。
这两个规则将 .main
压倒 #centered
:
top: 20%;
transform: translateY(-50%);
删除它们可以解决重叠问题。
如果要在 .main
和页面顶部之间保持一些垂直 space,请添加一点 padding-top
。