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
How are horizontal navbars styled differently than vertical navbars?
<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
In a navbar, how do change what links look like when you hover over them or click on them?
make changes to the LI element.
How do you code a background image for the whole page?
div#main {
background-image: url(“images/field-of-poppies.jpg”);
}
How can you make a page with a background image load faster?
You can make the page load faster if you use an image slice that’s 1 pixel wide (or tall) and tile it.
How do you code a background page with a repeating image? (both horizontally and vertically)
For horizontal repeat: background-repeat: repeat-x;
For vertical repeat: background-repeat: repeat-y;