background
Vlastnost background je zkratka pro několik dalších vlastností:
- background-color - nastavuje barvu pozadí elementu - např. background-color: red;
- background-image - nastavuje tapetu pro element - např. background-image: url("cesta/k/obrazku/obrazek.png");
- background-position - nastavuje počáteční součadnice pro tapetu - např. background-position: center top;
- background-size - nastavuje rozměry tapety pro pozadí - např. background-size: cover;
- background-repeat - nastavuje jestli se pozadí bude opakvoat - např. background-repeat: no-repeat;
- background-attachment - nastavuje jestli pozadí bude při scrollování fixní či nikoliv - např. background-attachment: fixed;
Editor
Pro živou ukázku je CSS a JavaScript vepsaný přímo v dokumentu - v praxi tyto soubory vždy oddělujte do externích souborů
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("https://upload.wikimedia.org/wikipedia/en/1/1f/Agent_Smith_%28The_Matrix_series_character%29.jpg");
background-repeat: repeat;
background-attachment: fixed;
background-position: center top;
background-size: 200px 400px;
}
p {
width: 50px;
}
</style>
</head>
<body>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
</body>
</html>