Documente Academic
Documente Profesional
Documente Cultură
Lecia 6
<h1>LECIA 6</h1>
<ul>
<li>Border</li>
<li>Margin</li>
<li>Padding</li>
<li>Dimensiuni</li>
<li>Display</li>
<li>Pozitionare</li>
<li>Float</li>
</ul>
<html>
Border
Exemplu:
div {
border: 10px solid green;
}
<html>
Border
Stilul border-ului
<html>
Border
Stilul border-ului
Exemplu:
div {
border: 5px groove #98bf21;
}
<html>
Border
Limea border-ului
border-width: <medium|thin|thick|length>;
Exemplu:
div {
border-width: 10px;
}
<html>
Margin
<html>
Margin
<html>
Margin
body {
margin-top: 100px;
margin-right: 40px;
margin-bottom: 10px;
margin-left: 70px;
}
sau
body {
margin: 100px 40px 10px 70px;
<html>
Margin
#x {
background: blue;
width: 100px;
height: 100px;
}
#y {
background: yellow;
width: 100px;
height: 100px;
margin-left: 10px;
margin-top: -50px;
}
#z {
background: red;
width: 100px;
height: 100px;
margin-left: 20px;
margin-top: -50px;
}
<html>
Exemplu margini negative:
Margin
<html>
Margin
Notaii simplificate:
margin: 20px 10px;
/* margine sus, jos = 20px */
/* margine stanga, dreapta = 10px */
margin: 30px;
/* margine sus, jos, stanga, dreapta = 30px */
<html>
Padding
<html>
Padding
<html>
Padding
Sintax
padding-left: 20px;
/* padding la stanga de 20px */
padding-top: 10px;
/* padding sus de 10px */
padding-bottom: 50px;
/* padding jos de 50px */
padding-right: 30px;
/* padding dreapta de 30px */
<html>
Padding
Notaii simplificate:
padding: 20px 10px;
/* padding sus, jos = 20px */
/* padding stanga, dreapta = 10px */
padding: 30px;
/* padding sus, jos, stanga, dreapta = 30px */
<html>
Dimensiuni
<html>
Dimensiuni
Proprietate
Descriere
height
max-height
max-width
min-height
min-width
width
<html>
<html>
<body>
<div id="x"></div>
<div id="y"></div>
<div id="z">
<div id="z1"></div>
<div id="z2"></div>
</div>
</body>
</html>
Dimensiuni
div {
border: 2px solid blue;
min-height: 50px;
}
#x {
width: 100px;
background: green;
}
#y {
width: 200px;
background: red;
}
#z {
width: 600px;
background: gray;
}
#z1 {
width: 30%;
background: maroon;
}
#z2 {
width: 70%;
background: purple;
}
<html>
Dimensiuni
<html>
Display
<html>
Display
<html>
<html>
<body>
<div id="x"></div>
<div id="y"></div>
<div id="z"></div>
</body>
</html>
Display
div {
height: 50px;
border: 5px solid blue;
margin: 10px;
}
#x {
background: green;
}
#y {
background: maroon;
visibility: hidden;
}
#z {
background: gray;
}
<html>
Display
<html>
<html>
<body>
<div id="x"></div>
<div id="y"></div>
<div id="z"></div>
</body>
</html>
Display
div {
height: 50px;
border: 5px solid blue;
margin: 10px;
}
#x {
background: green;
}
#y {
background: maroon;
display: none;
}
#z {
background: gray;
}
<html>
Display
<html>
Display
Elemente bloc
Elemente care ocup toat limea disponibil
Exemple: <h1>, <p>, <li>, <div>
Elemente inline
Elemente care ocup doar atta spaiu ct au nevoie
Exemple: <span>, <a>
<html>
Display
<html>
Display
display: inline;
}
</style>
<body>
<ul>
<li>Mere</li>
<li>Pere</li>
<li>Gutui</li>
</ul>
</body>
</html>
<html>
Display
none
Elementul nu va fi afiat deloc
block
Elementul va fi afiat ca un element de tip block
inline
Elementul va fi afiat ca un element de tip inline
<html>
Display
inline-block
Elementul este afiat ca un element inline fa de restul
elementelor, dar n interior poate fi formatat precum un element
block
<html>
Display
visible
Elementul este vizibil
hidden
Elementul este ascuns
<html>
Poziionare
<html>
Poziionare
{ position: static; }
<html>
Poziionare
{ position: fixed; }
<html>
Poziionare
{ position: relative; }
<html>
Poziionare
{ position: absolute; }
<html>
Poziionare
Suprapunerea elementelor
Gestionarea ordinii de afiare pentru elementele suprapuse
se face folosind proprietatea z-index
Elementele cu valoare z-index mai mare sunt afiate
deasupra
Dac doua elemente au aceeai valoare pentru z-index, se
va afia cel care apare mai jos n codul HTML
{ z-index: valoare; }
<html>
Poziionare
Suprapunerea elementelor
Gestionarea ordinii de afiare pentru elementele suprapuse
se face folosind proprietatea z-index
Elementele cu valoare z-index mai mare sunt afiate
deasupra
Dac doua elemente au aceeai valoare pentru z-index, se
va afia cel care apare mai jos n codul HTML
{ z-index: valoare; }
<html>
Exemple
<html>
<style>
div {
width: 100px;
height: 100px;
}
#x {
background: red;
}
#y {
background: blue;
}
</style>
<body>
<div id="x"></div>
<div id="y"></div>
</body>
</html>
Poziionare
<html>
Exemple
div {
width: 100px;
height: 100px;
}
#x {
background: red;
}
#y {
background: blue;
position: absolute;
left: 20px;
top: 20px;
}
Poziionare
<html>
Float
<html>
Exemple
<html>
<style>
div {
width: 100px;
height: 100px;
}
#x {
background: red;
float: right;
}
#y {
background: blue;
}
</style>
<body>
<div id="x"></div>
<div id="y"></div>
</body>
</html>
Poziionare
<html>
Float
{ z-index: left|right|both; }
<html>
Float
<html>
<style>
div {
float: left;
margin: 10px;
}
</style>
<body>
<div><img src="cat.jpg" /><br/>Poza 1</div>
<div><img src="cat.jpg" /><br/>Poza 2</div>
<div><img src="cat.jpg" /><br/>Poza 3</div>
</body>
</html>
<html>
Float
<html>
Float
<html>
<style>
div {
float: left;
margin: 10px;
}
</style>
<body>
<div><img src="cat.jpg" /><br/>Poza 1</div>
<div><img src="cat.jpg" /><br/>Poza 2</div>
<div style="clear: both;"><img src="cat.jpg" /><br/>Poza 3</div>
</body>
</html>
<html>
Float