Box Background
When you choose to use a background image for the box it is always a good idea to specify a background color as well. The reason is that until the background image is loaded, the background color will be shown.If there is too much difference between the background color and the background image, it will look disturbing once the browser shifts from the background color to the image.
Therefore it is a good idea to specify a background color that matches the colors of the image as close as possible.
background properties are used to define the background effects of an element.
- properties used for background effects:
background-image,
background-repeat,
background-attachment,
background-position
background-repeat.
repeat
The image is repeated both horizontally and vertically.
repeat-x
The image is repeated horizontally only.
repeat-y
The image is repeated vertically only.
no-repeat
The image is not repeated: only one copy of the image is drawn.
EXAMPLE
background-position
left, center, right, | top center | left bottom | top right etc.
background-attachment
Value - scroll | fixed
NOTE:Even if the image is fixed, it is still only visible when it is in the content, padding or border area of the element. Thus, unless the image is tiled ('background-repeat: repeat'), it may be invisible.
'fixed' background is fixed with respect to the page box and is therefore replicated on every page.
Third Trick
Lets make a Multiple BG
Not only a borders. We can also layer the Background.
code:
Opacity
The problem with using opacity in CSS is that not only the background of the element will have transparency, but all of its child elements as well. This means that any text within will have the same opacity,
code:
The Solution!
Therefore, I can happily offer an alternative for you: RGBa colors. The beauty in this is that you declare the normal RGB values + values for the level of transparency you want, resulting in a very easy way to declare transparency for a color. Making this happen with CSS,
These allow us to use opacity within our background via an alpha channel. If we are looking to use a 30% opaque we can use rgba(102, 102, 255, 0.3)
code: