HTML & CSS- part 11 Flashcards
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?
Make a “spacer div” that stays in the normal flow using this:
visibility: hidden;
How do you explicitly overrule the default stack order of the page?
z-index
This overrides the default stack order (layers of the page).
What is the default z-index?
0
Tips for making a space div
To make a spacer div for a header:
- put the spacer div first
- add a selector for each element in the header to the CSS formatting: div#header h2, div#spacer h2 {
- copies of all elements in the header should go into the spacer div, too
What’s an informal way to think of a vertical navigation bar?
A vertical nav bar is just an unordered list hanging out in a div.
Each list item is a link
How do I remove the bullet points from an unordered list?
div#navbar ul {
list-style-type: none;
}
What are the steps to build a navbar?
Steps to build a navbar:
- Create an unordered list
- Make the list items into links
- Remove the bullet points
- Style the anchors
- Add a background color
Instead of putting a navbar in a <div>, newer websites might use what?
<nav></nav>
How do you style the div bar just wide enough to fit the list items, but no wider?
display: inline-block;
This is the “shrink to fit” code
In a navbar, why would there still be padding on the left side?
Because it’s a list. You can remove this with padding-left: 0;
Which kind of margins do block elements add?
Top and bottom margins
Code the background of a div blue
background-color: blue;
What’s the difference between these?
list-style-type
text-decoration
list-style-type
removes/changes bullet points
text-decoration: none;
removes underling from anchors
What happens when you do this?
display: block;
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
Is padding inside an element or outside of it?
Inside