HTML & CSS- part 11 Flashcards

1
Q

When you fixed the position of an element, you take it out of the normal flow of the HTML. Other elements will encroach on it. How do you prevent this?

A

Make a “spacer div” that stays in the normal flow using this:

visibility: hidden;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you explicitly overrule the default stack order of the page?

A

z-index

This overrides the default stack order (layers of the page).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the default z-index?

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Tips for making a space div

A

To make a spacer div for a header:

  1. put the spacer div first
  2. add a selector for each element in the header to the CSS formatting: div#header h2, div#spacer h2 {
  3. copies of all elements in the header should go into the spacer div, too
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What’s an informal way to think of a vertical navigation bar?

A

A vertical nav bar is just an unordered list hanging out in a div.

Each list item is a link

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do I remove the bullet points from an unordered list?

A

div#navbar ul {

list-style-type: none;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the steps to build a navbar?

A

Steps to build a navbar:

  1. Create an unordered list
  2. Make the list items into links
  3. Remove the bullet points
  4. Style the anchors
  5. Add a background color
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Instead of putting a navbar in a <div>, newer websites might use what?

A

<nav></nav>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you style the div bar just wide enough to fit the list items, but no wider?

A

display: inline-block;

This is the “shrink to fit” code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In a navbar, why would there still be padding on the left side?

A

Because it’s a list. You can remove this with padding-left: 0;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which kind of margins do block elements add?

A

Top and bottom margins

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Code the background of a div blue

A

background-color: blue;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What’s the difference between these?

list-style-type

text-decoration

A

list-style-type
removes/changes bullet points

text-decoration: none;
removes underling from anchors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What happens when you do this?

display: block;

A

Displays an element as a block element (like <p>).

It starts on a new line, and takes up the whole width

It also adds top and bottom margins

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Is padding inside an element or outside of it?

A

Inside

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How are horizontal navbars styled differently than vertical navbars?

A

<ul> styling: no differences

<li> styling:
for horizontal navbars, use display: inline;

This puts the list items side-by-side rather than vertically

width: makes sure that each list item is the same width

float: left;

margin-right: .5em (or so) This creates a little space between the list items.

<a> styling: smaller font size

17
Q

In a navbar, how do change what links look like when you hover over them or click on them?

A

make changes to the LI element.

18
Q

How do you code a background image for the whole page?

A

div#main {
background-image: url(“images/field-of-poppies.jpg”);
}

19
Q

How can you make a page with a background image load faster?

A

You can make the page load faster if you use an image slice that’s 1 pixel wide (or tall) and tile it.

20
Q

How do you code a background page with a repeating image? (both horizontally and vertically)

A

For horizontal repeat: background-repeat: repeat-x;

For vertical repeat: background-repeat: repeat-y;