Skip to content

Instantly share code, notes, and snippets.

@jbexx
Last active May 9, 2017 15:38
Show Gist options
  • Select an option

  • Save jbexx/4c59697a5604208ebcabfe74d20abc5a to your computer and use it in GitHub Desktop.

Select an option

Save jbexx/4c59697a5604208ebcabfe74d20abc5a to your computer and use it in GitHub Desktop.
Turing css challenges
Challenge 1

I wrote the divs in reverse order in the HTML so that the order of the divs would be right. In CSS I set all divs to inline-block display and then floated div1 left and floated div2 and div3 right.

See Challenge 1 on CodePen


Challenge 2

I left the divs as block elements, floated div3 right, set div2s margin to auto and left div1 as it is.

See Challenge 2 on CodePen


Challenge 3

I nested div2 inside of div1 so that it would 'be on top of' or 'lay-over', or however you say it correctly, div1. In CSS I set the margin on div1 to auto to center it horizontaly and then with the Dev Tools I did some maths to find out what I needed to set the margins on div2 to center it vertically. I put the words "div1" in a p tag and set the margin to 0 so that it wouldn't effect the position of div2.

See Challenge 3 on CodePen


Challenge 4

I set the display for both divs to inline-block so they would be next to each other in a line. I then set div2 to a relative position and floated it left. I set div1 to an absolute position so that div2 would float on top of it. I then set the margin of div2 to half of the pixels of div1s length and width to offset it.

See Challenge 4 on CodePen


Challenge 5

I floated the first div right, the second div I set its margin to auto so that it centers horizontally and did nothing to the third div. I put a clear fix for all divs; set clear to both so that the second div wouldn't be in the first divs line.

See Challenge 5 on CodePen


Challenge 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment