Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions 01-1-alignment.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Выравнивание элемента 100x100px по центру по горизонтали</title>
<style>
.v1, .v2, .v3, .v4, .v5, .v6 {
width: 100px;
height: 100px;
text-align:center;
}

/* 1st */
.v1 {
margin: 0 auto;
background: #99ccff;
}

/* 2nd */
.v2-container {
width: 100%;
text-align: center;
}
.v2 {
display: inline-block;
background: #66ccff;
}

/* 3rd */
.v3-container {
float:right;
width:50%;
}
.v3 {
margin-left:-50px;
background:#33ccff;
}

/* 4th */
table {
width:100%;
}
.v4 {
background:#00ccff;
}

/* 5th */
.v5 {
position:relative;
left: 50%;
margin-left: -50px;
background:#0099cc;
}

/* 6th */
.v6 {
position:absolute;
left:50%;
margin-left: -50px;
background:#336699;
}
</style>
</head>
<body>
<div class="v1"> 1 </div>

<div class="v2-container">
<div class="v2"> 2 </div>
</div>

<div class="v3-container">
<div class="v3"> 3 </div>
</div>

<table>
<tr>
<td align="center">
<div class="v4"> 4 </div>
</td>
</tr>
</table>

<div class="v5"> 5 </div>

<div class="v6"> 6 </div>
</body>
</html>
68 changes: 68 additions & 0 deletions 01-2-alignment.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Выравнивание элемента 100px х Auto по центру по горизонтали</title>
<style>
span {
display:inline-block;
height:100px;
}

/* 1st */
.v1-container {
text-align: center;
}
.v1 {
background:#99ccff;
}

/* 2nd align="center"*/
.v2 {
background: #66ccff;
}

/* 3rd */
.v3-table {
display:table;
width:100%;
text-align:center;
}
.v3 {
background:#33ccff;
}

/* 4th */
table {
width: 100%;
text-align:center;
}
.v4 {
background:#00ccff;
}
</style>
</head>
<body>
<div class="v1-container">
<span class="v1">Способ №1</span>
</div>

<div align="center">
<span class="v2">Способ №2</span>
</div>

<div class="v3-table">
<div>
<span class="v3">Способ №3</span>
</div>
</div>

<table>
<tr>
<td>
<span class="v4">Способ №4</span>
</td>
</tr>
</table>
</body>
</html>
28 changes: 28 additions & 0 deletions 02-1-layout.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Две колонки: 300px + Auto</title>
<style>
* {
margin:0;
padding:0;
}
.first-col {
float:left;
width:300px;
height:500px;
background:cadetblue;
}
.second-col {
margin-left:300px;
height:500px;
background:coral;
}
</style>
</head>
<body>
<div class="first-col"></div>
<div class="second-col"></div>
</body>
</html>
29 changes: 29 additions & 0 deletions 02-2-layout.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Две колонки: 150-300px + Auto</title>
<style>
* {
margin:0;
padding:0;
}
.left-col {
float:left;
min-width: 150px;
max-width: 300px;
width:30%;
height:500px;
background:cadetblue;
}
.right-col {
height:500px;
background:coral;
}
</style>
</head>
<body>
<div class="left-col"></div>
<div class="right-col"></div>
</body>
</html>
51 changes: 51 additions & 0 deletions 03-1-bonus.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Выравнивание элемента 100х100px по центру по вертикали</title>
<style>
* {
margin:0;
padding:0;
}

.v1, .v2{
width:100px;
height:100px;
}

/* 1st */
.v1 {
position:absolute;
top:50%;
margin-top: -50px;
background:#99ccff;
}

/* 2nd */
.v2-table {
position:absolute;
left:100px;
display:table;
float:left;
height:100%;
}
.v2-table-cell {
display:table-cell;
vertical-align: middle;
}
.v2 {
background:#66ccff;
}
</style>
</head>
<body>
<div class="v1">1</div>

<div class="v2-table">
<div class="v2-table-cell">
<div class="v2">2</div>
</div>
</div>
</body>
</html>
57 changes: 57 additions & 0 deletions 03-2-bonus.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Выравнивание элемента 100px х Auto по центру по вертикали</title>
<style>
* {
margin:0;
padding:0;
}

.v1, .v2 {
display:inline-block;
}

/* 1st */
.v1-table {
position:absolute;
display:table;
height:100%;
}
.v1-table-cell {
display:table-cell;
vertical-align: middle;
}
.v1 {
line-height: 100px;
background: #99ccff;
}

/* 2nd */
.v2-container {
position:absolute;
top:50%;
left:150px;
height:100px;
margin-top: -50px;
}
.v2 {
line-height: 100px;
background:#66ccff;
}
</style>
</head>
<body>
<div class="v1-table">
<div class="v1-table-cell">
<span class="v1">Способ №1</span>
</div>
</div>

<div class="v2-container">
<span class="v2">Способ №2</span>
</div>

</body>
</html>