Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gprocell927/40f20d07eb112b8ad6ad7cdf15ee1bc7 to your computer and use it in GitHub Desktop.
Save gprocell927/40f20d07eb112b8ad6ad7cdf15ee1bc7 to your computer and use it in GitHub Desktop.
CSS Layout Challenge Solutions
Challenge Number 1

Description of approach: We used a container to wrap the div2 and div3 elements so that we could display the elements as an inline block and float them to the right as one unit. Challenge number

Challenge Number 2

Description of approach: After much struggle, we learned that this challenge needed to make use of margin: auto to center the element horizontally within it's column. The element takes up a specified width and splits the remaining space equally between the left and right margins. Challenge number

Challenge Number 3

Description of approach: At first, I really wanted to use the z-index. After not having luck with that, I looked into positioning properties. Then a light bulb came on, and I simply nested div2 inside of div1. I think this worked because div1 set the structure for div2 to work within...although I am not 100% sure on this. Challenge number

Challenge Number 4

Description of approach: Since div2 was nested within div1, setting div2's position to relative would make it move out of the normal flow provided by div1. Positioning is starting to slowly make some sense. Challenge number

Challenge Number 5

Description of approach: Since div2 was nested within div1, setting div2's position to relative would make it move out of the normal flow provided by div1. Ergo, I also positioned div3 within div2, so that I could position it in relation to div2. Challenge number

Challenge Number 6

Description of approach:I used the same methods from Challenges 4 and 5 to get divs 2 and 3 into position within div 1. Can't figure out how to position div1, 2, and 3 at bottom right of page. Challenge number

Challenge Number 7

Description of approach:I nested div 2 within div1 to be able to position it within relation to div1 Challenge number

Challenge Number 8

Description of approach:I nested div 2 within div1 to be able to position it within relation to div1 and used negative positioning from the top (on div2) to line the div to the top right corner of div1. Challenge number

Challenge Number 9

Description of approach:Div 2 is nested inside div 1 so that it may move in relation to one. Div 3 is nested within div 2 to move in relation to div 2 and 1. Challenge number

Challenge Number 10

Description of approach: I worked with keeping div2 and 3 nested within div1 and 3 also nested within 2. This allowed me to move them as a whole to the center of the screen. I also positioned 2 and 3 relative to 1. Challenge number

Challenge Number 11

Description of approach: I kept the nesting structure that I used for 10, and played with the positioning from the top and left in relation to div 1 and 2. Challenge number

Challenge Number 12

Description of approach: I kept the nesting structure that I used for 10, and played with the positioning from the top and left in relation to div 1 and 2. Challenge number

Challenge Number 13

Description of approach: I nested divs2-5 within the previous div, then positioned them relative to one another. Challenge number

Challenge Number 14

Description of approach:I nested div 2 within div 1 to be able to float both elements to the right. From there, I positioned div 2 relative to div 1. Challenge number

Challenge Number 15

Description of approach: I nested div3 within div1 to be able to position div3 relative to div1. I relied on margins to position div 2 and div 4. Challenge number

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