Answer the question
In order to leave comments, you need to log in
How to set height attribute for automatic image cutting?
Hello
There is such a tile: large screen - i.imgur.com/JLdMfTX.jpg , while reducing the width of the screen. images are proportionally reduced - i.imgur.com/IEmlUBo.jpg
<div class="first-post">
<img src="http://lorempixel.com/700/700/" alt="">
</div>
<div class="second-post">
<img src="http://lorempixel.com/300/300/" alt="">
<div class="heading4">Заголовок</div>
</div>
<div class="fif-post">
<img src="http://lorempixel.com/700/700/" alt="">
</div>
<div class="fio-post">
<img src="http://lorempixel.com/300/300/" alt="">
<div class="heading4">Заголовок</div>
</div>
.first-post img, .second-post img, .fif-post img, .fio-post img {
border-radius: 10px; width: 100%;
}
.first-post, .second-post, .fif-post, .fio-post {
padding: 5px;
}
.first-post {
width: 60%;
float: left;
}
.second-post{
width: 40%;
float: right;
}
.fif-post {
width: 60%;
float: right;
}
.fio-post{
width: 40%;
float: right;
}
.first-post img, .second-post img, .fif-post img, .fio-post img {
border-radius: 10px;
display: block;
max-height: 100%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: 0 -25%;
}
.first-post, .second-post, .fif-post, .fio-post {
display: block;
position: relative;
overflow: hidden;
border-radius: 10px;
border: #fff 5px solid;
}
.first-post {
width: 60%;
padding: 60% 0 0 0;
float: left;
}
.second-post{
width: 40%;
padding: 35% 0 0 0;
float: right;
}
.fif-post {
width: 60%;
padding: 60% 0 0 0;
float: right;
}
.fio-post{
width: 40%;
padding: 35% 0 0 0;
float: right;
}
Answer the question
In order to leave comments, you need to log in
Use backgrounds instead of images:
<div class="first-post" style="background-image: url(http://lorempixel.com/700/700/)"></div>
........
.first-post, .second-post, .fif-post, .fio-post {
border-radius: 10px; margin: 5px;
background: transparent center/cover
}
.first-post {
width: calc(60% - 10px);
height: calc(60% - 10px);
float: left;
}
.... и так далее
Only the container should not have an explicit height and should not have position: absolute or fixed, otherwise the blocks will not turn out to be square.
With the help of mansory, it seems like it’s possible, again, I think the solution is cumbersome for 4 tiles. Are there any other options?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question