.htmlsoubor
index.html,
index2.html,
index3.html, ...
./- aktuální složka
../- nadřazená složka
Většina prohlížečů automaticky odsazuje prvky.
margin
margin-top,
margin-right,
margin-bottom,
margin-left
<!DOCTYPE html>
<html>
<head>
<style>
p {
margin: 30px;
}
</style>
</head>
<body>
<p>Ahoj Honzo</p>
</body>
</html>
padding
padding-top,
padding-right,
padding-bottom,
padding-left
<!DOCTYPE html>
<html>
<head>
<style>
div{
width: 200px;
height: 200px;
background-color: antiquewhite;
padding: 30px;
}
</style>
</head>
<body>
<div>
<p>Ahoj Honzo</p>
</div>
</body>
</html>
border
border-top,
border-right,
border-bottom,
border-left
<!DOCTYPE html>
<html>
<head>
<style>
div{
width: 100px;
height: 100px;
background-color: antiquewhite;
padding: 30px;
border: 20px solid green;
}
</style>
</head>
<body>
<div>
<p>Ahoj Honzo</p>
</div>
</body>
</html>
padding,
border,
margin
border-radius- vlastnost pro zaoblení rohů
pixelech
<!DOCTYPE html>
<html>
<head>
<style>
div{
width: 100px;
height: 100px;
background-color: antiquewhite;
border-radius: 5px;
}
</style>
</head>
<body>
<div>
<p>Ahoj Honzo</p>
</div>
</body>
</html>
widtha
height
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
height: 100px;
background-color: red;
}
</style>
</head>
<body>
<div>
</div>
</body>
</html>
margin-left: auto;
margin-right: auto;
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
height: 100px;
background-color: red;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<div>
</div>
</body>
</html>
div p
div > p
div + p
div ~ p
div, p
:hover- při najetí myší
:active- při kliknutí
:focus- při zaměření
display- vlastnost pro změnu zobrazení elementu
block,
inline,
inline-block,
flex
block- element zabírá celou šířku stránky a začíná na novém řádku
div,
h1,
p
<!DOCTYPE html>
<html>
<head>
<style>
div {
/*display: block;*/
height: 100px;
background-color: cadetblue;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
inline- element zabírá jen tolik místa, kolik potřebuje a nezačíná vždy na novém řádku
span,
a
<!DOCTYPE html>
<html>
<head>
<style>
span {
/*display: inline;*/
color: cadetblue;
}
</style>
</head>
<body>
<span>Toto je první span</span>
<span>Toto je druhý span</span>
</body>
</html>
inline-block- kombinuje výhody inline a block
<!DOCTYPE html>
<html>
<head>
<style>
.box {
display: inline-block;
width: 80px;
height: 80px;
background-color: lightcoral;
margin: 5px;
}
</style>
</head>
<body>
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
</body>
</html>
display: flex- vlastnost pro vytvoření flexboxu
<!DOCTYPE html>
<html>
<head>
<style>
.container {
display: flex;
background-color: lightgray;
padding: 10px;
}
.item {
background-color: coral;
padding: 20px;
margin: 5px;
}
</style>
</head>
<body>
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>
</body>
</html>
justify-content- zarovnání prvků na hlavní ose
align-items- zarovnání prvků na vedlejší ose
flex-direction- směr, ve kterém se prvky budou řadit
flex-wrap- zalamování prvků
flex-start,
center,
flex-end,
space-between,
space-around
<!DOCTYPE html>
<html>
<head>
<style>
.container {
display: flex;
justify-content: center;
background-color: lightgray;
padding: 10px;
}
.item {
background-color: coral;
padding: 20px;
margin: 5px;
}
</style>
</head>
<body>
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>
</body>
</html>
flex-start,
center,
flex-end,
stretch
<!DOCTYPE html>
<html>
<head>
<style>
.container {
display: flex;
align-items: center;
height: 200px;
background-color: lightgray;
padding: 10px;
}
.item {
background-color: coral;
padding: 20px;
margin: 5px;
}
</style>
</head>
<body>
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>
</body>
</html>
row,
column,
row-reverse,
column-reverse
<!DOCTYPE html>
<html>
<head>
<style>
.container {
display: flex;
flex-direction: column;
background-color: lightgray;
padding: 10px;
}
.item {
background-color: coral;
padding: 20px;
margin: 5px;
}
</style>
</head>
<body>
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.container {
display: flex;
justify-content: space-between;
align-items: center;
height: 150px;
background-color: lightgray;
padding: 10px;
}
.item {
background-color: coral;
padding: 15px;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="container">
<div class="item">Levý</div>
<div class="item">Střed</div>
<div class="item">Pravý</div>
</div>
</body>
</html>