CSS Positioning/ Handling Images CSS Flashcards

1
Q

How can you centre images and how do you add a background image to an element?

A

.main {
display: block;
margin 0 auto;
}

h1 {
background-image: url(“link”);
}

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

Sometimes when you add an background image, the image can repeat itself, how can you change this? When the image is changed to not repeated, it’s position can be modified, how can you do this?

A
h1 {
  background-image: url("link");
  background-repeat: no-repeat;
  background-position: center bottom;
}

Background position values:

3x3 grid (left top - right bottom)

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

How can you add an liner gradient color to the background of an element?

A

.btn {
background-image: -webkit-linear-gradient (#, #);
}

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

How do you know when to add an image to a webpage between the background property in CSS, or with img element in HTML?

A

If you want to add an image that is part of the content of a web page such as: logos, icons, album photos etc. then use the <img></img> element.

If you want to add an image, solely to style the page better, then the background-image property in CSS is the better option.

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

How can you change the position of block level elements on a web page and what are the four values of this property? Also, how can you change the position of block level elements on a web page and what are the four values of this property?

A
h1 {
  position: fixed
  top: 20px;
  bottom: 20px;
}

Four values:

fixed - When set to fixed, an elements position can be pinned to any part of the web page, the element will remain in view no matter what
relative - the relative value allows you to position an element relative to its default static position on the web page (left).

absolute - All other elements on the page will ignore the element and act like it’s not present on the page

static - The default position of a block element

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

When there are multiple boxes on web page with different positions, the boxes (plus their content) can overlap with each other, how can we fix this?

A

.header {
z-index: 1;
}

.welcome {
z-index: 2;
}

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

If you want to simply move an element all the way to the right or left, how can you do this?

A

.welcome {
float: right;
width: 100%
}

Crucial that the width is set, for the float property to function properly

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

When multiple elements are floated and have different heights, it can affect their layout on the page. Specifically, elements can bump into each other and not allow other elements to properly move to the left or right. How can you work around this?

A

.welcome {
clear: both
}

values:

  • left
  • right
  • both
  • none
How well did you know this?
1
Not at all
2
3
4
5
Perfectly