Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Having trouble fitting a third element in the menu bar

I have a menu bar that has two elements. I want to edit it to make a third element in the center of them both. The problem is when I do this the middle element sits next to the first one but the third element drops below the first two. Also the border is the same size as the original menu bar. How do I get all three elements to be next to one another and make the grey border cover all three elements too? I have attached my code below- http://codepen.io/Johned22/pen/kkwOAy Thanks in advance

2 Answers

Hey John, I took a look at your code pen, and noticed you have your <a> tags set to 49% width of their parent (#menu). if you change this so each takes up 1/3rd of the parent, your three element will fit. Please see below:

a{
font-size:0.7em;
text-decoration:none;
display:block;
float:left;
padding: 17px 0px;
width:33%; /*****  Changed from 49.6% ******/
text-align:center;
color:#efdcdc;
background: #f73c82; /* Old browsers */
background: -moz-linear-gradient(top,  #f73c82 0%, #c21063 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f73c82), color-stop(100%,#c21063)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #f73c82 0%,#c21063 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #f73c82 0%,#c21063 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #f73c82 0%,#c21063 100%); /* IE10+ */
background: linear-gradient(to bottom,  #f73c82 0%,#c21063 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f73c82', endColorstr='#c21063',GradientType=0 ); /* IE6-9 */
-webkit-transition:0.5s;
-moz-transition:0.5s;
-ms-transition:0.5s;
-o-transition:0.5s;
transition:0.5s;
}```

Thanks, that solved my problem.