Skip to content

Instantly share code, notes, and snippets.

@kccrs
Last active July 10, 2016 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kccrs/5212b178b3209785c59ae41fae477da4 to your computer and use it in GitHub Desktop.
Save kccrs/5212b178b3209785c59ae41fae477da4 to your computer and use it in GitHub Desktop.
CSS Challenges

Challenge 1

I set all divs to float left and inline-block then assigned absolute positioning to divs 2 and 3 and added a right offset of 105px and 0px respectively.

Challenge 1

Challenge 2

I removed all positioning from the div elements to reset to the default block styling. Then I set div2 to have margin: auto and set div3 to absolute positioning with a right offset value of 0. (We also discovered that you could set margin-right, margin, and margin-left on the 3 divs respectively to auto and it would also work).

Challenge 2

Challenge 3

I wrapped the div2 element inside the div1 element. Next, I doubled the size of div1 relative to div2. Then I set margin: auto; on both divs and added a top margin of 20px to div1 and 30px to div2.

Challenge 3

Challenge 4

I set div2 to absolute positioning and added a bottom offset of 50px and a left offset of 50px.

Challenge 4

Challenge 5

I set div1, div2, and div3 to the following values: margin-left: auto;, margin: auto;, and margin-right: auto; respectively.

Challenge 5

Challenge 6

First I nested divs 2 and 3 inside div 1. Then I set all divs to inline-block and absolute positioning. Div 1 was then offset with values of 0 for bottom and right. Div 2 had offset values on bottom and left at 0, div 3 had offset values top and right at 0.

Challenge 6

Challenge 7

First I nested div 2 inside div 1. Then I set all divs to inline-block and absolute positioning. Div 2 had offset values bottom and right at 0.

Challenge 7

Challenge 8

First I nested div 2 inside div 1. Then I set all divs to inline-block and absolute positioning. Div 2 had offset values top and right at 0.

Challenge 8

Challenge 9

First I nested divs 2 and 3 inside div 1. Then I set all divs to inline-block and absolute positioning. Div 3 had a bottom offset value of 0. I then added a left margin of 25px to divs 2 and 3 to center the element since the div 1 width was 150px and divs 2 and 3 were 100px.

Challenge 9

Challenge 10

On div 1 I set the margin to auto and then added a 25px top margin. Divs 2 and 3 I set to inline-block with a relative position and a top offset of 25px. I set div 2's left offset at 0 and div 3's left offset to 75px.

Challenge 10

Challenge 11

I nested divs 2 and 3 inside div 1. Then I gave all divs absolute positioning. For div 2 I added bottom and right offsets of 0px. For div 3 I added bottom and right offsets of 15px each.

Challenge 11

Challenge 12

This challenge was very similar to Challenge 11. I began by nesting divs 2 and 3 inside div 1. Then I gave all divs absolute positioning. For div 2 I added a bottom offset of 0 and a right offsets of -100 px since the width of the div is 200 px and the div is half inside and half outside div 1. For div 3 I added a right offset of 0 px and a bottom offset of -75px because the height of the div is 150px and its position is halfway outside the bottom of div 1.

Challenge 12

Challenge 13

For this challenge I set all 5 divs to the same height and width of 100px and gave them all absolute positioning. For div 2 I added top and left offsets of 50px each as that is half the height/width of the box and that would push it right and down. For div 3 I did the same thing but increase the offsets to 100px each to offset it half the height and width of div 2. Then I repeated this pattern with offsets of 150px for div 4 and 200px for div 5.

Challenge 13

Challenge 14

I nested div 2 inside of div 1 and gave them both absolute positioning. I made div 2 half the height and width of div 1. Next I added a right offset of 0 to div 1 and a bottom offset of 0 to div 2.

Challenge 14

Challenge 15

I created 4 divs and set divs 1 and 4 to be twice the height and width of divs 2 and 3. I gave all divs absolute positioning. Div 2 I offset 400px from the right. Div 3 I offset 500px from the top. Div 4 I offset 400px from the right so that it lined up with div 2 and I offset it 300px from the top so the bottom edge was in line with div 3.

Challenge 15

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