-
-
Save kizu/9909593 to your computer and use it in GitHub Desktop.
Untitled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.image-container | |
{ | |
position: absolute; | |
left: 0; | |
right: 0; | |
top: 0; | |
bottom: 50%; | |
background: lightyellow; | |
overflow: hidden; | |
text-align: center; | |
white-space: nowrap; | |
} | |
.image-container:after | |
{ | |
content: ""; | |
height: 100%; | |
display: inline-block; | |
vertical-align: middle; | |
} | |
.image-container:before | |
{ | |
content: "Я"; | |
position: absolute; | |
left: 50%; | |
top: 50%; | |
margin-left: -20px; | |
margin-top: -20px; | |
width: 40px; | |
height: 40px; | |
border: 4px solid white; | |
background: darkred; | |
border-radius: 100%; | |
color: white; | |
font-weight: bold; | |
line-height: 40px; | |
text-align: center; | |
} | |
.image | |
{ | |
vertical-align: middle; | |
max-height: 100%; | |
max-width: 100%; | |
} | |
.info | |
{ | |
position: absolute; | |
padding: 10px; | |
top: 0; | |
right: 0; | |
left: 50%; | |
border: 1px dotted lightgray; | |
font-size: 14px; | |
line-height: 1.5; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="image-container"> | |
<img class="image" src="http://festival.1september.ru/articles/594478/presentation/23.jpg"> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="image-container"> | |
<span class="image-wrapper"> | |
<img class="image" src="http://festival.1september.ru/articles/594478/presentation/23.jpg"> | |
</span> | |
</div> | |
<p class="info"> | |
<b>Задача:</b> Отцентрировать иконку относительно тянущейся картинки. <br /> | |
<b>Решение:</b> Обернуть картинку в блок, который будет повторять размеры картинки и спозиционировать иконку относительно него. <br /> | |
<b>В чем проблема:</b> При первой отрисовке обертка соответствует размерам картинки, однако при ресайзе все портится — по высоте блок соответствует, а по ширине нет. | |
</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.image-container | |
{ | |
position: absolute; | |
left: 0; | |
right: 0; | |
top: 0; | |
bottom: 50%; | |
background: lightyellow; | |
} | |
.image-wrapper | |
{ | |
position: relative; | |
display: inline-block; | |
height: 100%; | |
background: yellow; | |
} | |
.image-wrapper:after | |
{ | |
content: "Я"; | |
position: absolute; | |
left: 50%; | |
top: 50%; | |
margin-left: -20px; | |
margin-top: -20px; | |
width: 40px; | |
height: 40px; | |
border: 4px solid white; | |
background: darkred; | |
border-radius: 100%; | |
color: white; | |
font-weight: bold; | |
line-height: 40px; | |
text-align: center; | |
} | |
.image | |
{ | |
display: block; | |
max-height: 100%; | |
width: auto; | |
} | |
.info | |
{ | |
position: absolute; | |
padding: 10px; | |
top: 0; | |
right: 0; | |
left: 50%; | |
border: 1px dotted lightgray; | |
font-size: 14px; | |
line-height: 1.5; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment