width: 100% child bigger than parent

Viewed 1192

I know there are a lot of threads like this one but I can't seem to solve this width:100% issue. I have this sliding description on a menu and it's bigger than the button. I've tried adding box-sizing: border-box; but it didn't work. I don't know what the problem is. Probably has to do with the margins, padding, and two different css codes for #mainicons and #mainicons i ?

My code:

#mainicons {
  height: 50px;
  width: 70px;
  position: fixed;
  top: 250px;
  left: 0px;
  text-align: center;
}

#mainicons>a {
  position: relative;
  margin-top: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#mainicons i {
  display: flex;
  flex-direction: column;
  margin-top: 20px;
  height: 40px;
  width: 50px;
  padding: 10px;
  color: #fff;
  background: #CE9C87;
  text-align: center;
  font-size: 15px;
  line-height: 40px;
  -webkit-transition: all .5s ease;
  -moz-transition: all .5s ease;
  -o-transition: all .5s ease;
  transition: all .5s ease;
}

#mainicons i:hover {
  -webkit-box-shadow: inset 7px 0px 0px 0px #CE9C87;
  -moz-box-shadow: inset 7px 0px 0px 0px #CE9C87;
  box-shadow: inset 7px 0px 0px 0px #CE9C87;
  color: #CE9C87;
  background: #fff;
  -webkit-transition: all .5s ease;
  -moz-transition: all .5s ease;
  -o-transition: all .5s ease;
  transition: all .5s ease;
}

#mainicons span {
  color: #CE9C87;
  background: #fff;
  width: 100%;
  height: 100%;
  z-index: -1;
  font-size: 15px;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  left: -100px;
  -webkit-transition: all .5s ease;
  -moz-transition: all .5s ease;
  -o-transition: all .5s ease;
  transition: all .5s ease;
}

#mainicons a:hover>span {
  left: 70px;
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">

<body bgcolor="#E6E6FA">
  <div id="mainicons">
    <a href="/"><i class="fa fa-home"></i><span>Home</span></a>
    <a href="/ask"><i class="fa fa-envelope"></i><span>Ask</span></a>
    <a href="/submit"><i class="fa fa-pencil "></i><span>Request</span></a>
    <a href="/archive"><i class="fa fa-clock-o"></i><span>Archive</span></a>
  </div>

Thanks for the help! :)

3 Answers
Related