Da1T
Da1T

Reputation: 49

Div overlapping another div

I'm trying to make a div correctly appear below another div and not flow into it/overlap it. I tried various ways, can't find a way to make it appear correctly though. Here is the demo: http://s1.mstclan.xyz/mstinfo

And CSS code:

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%;
}

Thanks in advance.

Upvotes: 1

Views: 805

Answers (1)

Hatchet
Hatchet

Reputation: 5428

These two rules are pushing .main down over #centered:

top: 20%;
transform: translateY(-50%);

Removing them corrects the overlap issue.

If you want to maintain some vertical space between .main and the top of the page, add a bit of padding-top.

Upvotes: 2

Related Questions