Front End Project 2

Setup

Notice we have two divs in our section.

One is a left box with some welcome text.
The other is a box on the right that will contain our events.

Add the background

The background image url is SVG image data.

Pay attention to background-color, background-attachment, and background-size. They indicate how the background should be positioned.

Style the Left Box

In your styles, let’s style the left box of the section. The leftBox is a class of a div:

Input the css one at a time to see what’s going. Notice that we give a padding of 50px:

Put a border around the div to see what’s going.

As you can see, we need to style our left box (welcome text):

Right Box

Now we style our right box (place where we will place our future events). We put a border around the div to first see where it is:

Then we give it a width and background color/opacity:

Finally, we give it a height:

Spacing Conflict

As you can see the extra padding (50px) from the leftBox makes it width not 50%. It would add the 50px to its 50% width.

This is why when you float your rightBox right, it gets nudged to the bottom.

In order to resolve this, use

The box-sizing property allows us to include the padding and border in an element’s total width and height.

If you set box-sizing: border-box; on an element, padding and border are included in the width and height:

It will re-adjust the textContent accordingly, and fit our padding inside the 50% width.