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

Maurits Pallesen
Maurits Pallesen
9,770 Points

How to create hint boxes like Jquery basics > Creating A Password Confirmation Form?

Hi everyone, i'm trying to put my newly learned Jquery knowlegde to use by recreating some of the stuff in the course, and i wondered.. how did Andrew Chalkley create the blue pointy things appended on the left of the hint boxes in the "Creating A Password Confirmation Form"?

3 Answers

Hi Maurits,

css triangles

Chris doesn't use pseudo elements in that article but that is what Andrew uses in the project and would probably be the preferred way to do it as these are purely visual.

From the project:

span:after {
  right: 100%;
  top: 50%;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
  border-color: rgba(136, 183, 213, 0);
  border-right-color: #2F558E;
  border-width: 8px;
  margin-top: -8px;
}

It works because adjoining borders are mitered at the corners. This creates the angles needed to make triangles.

I think the easiest way to visualize these triangles is to draw a square on a piece of paper. Then draw 2 diagonals through your square making an "X". This divides the square into 4 little triangles. The center point in the square represents the elements content box which has 0 width and height. The 4 triangles represent the elements 4 borders. If you were to color in the triangle on the right then you would have the orientation seen in the hint box.

If you look at the css above you will see that the border color is made transparent (0 opacity) and then the right border is given a fully opaque color.

Felix Yakubov
Felix Yakubov
17,475 Points

How about using :focus that makes a label next to a password switch from display:hidden to display:visible?

Maurits Pallesen
Maurits Pallesen
9,770 Points

Thanks a lot, that really explained it well :)