Как ограничить высоту элемента определенными значениями («ступенчатыми») в зависимости от содержимого ⇐ CSS
Как ограничить высоту элемента определенными значениями («ступенчатыми») в зависимости от содержимого
This is a follow-up to my previous question found here. Is there any way to achieve, I can't describe it better, "step-based heights" on a div? I made a little fiddle to display what I have.
My target is now, that every box has a height that's a multiple of 400px. So if a box with height: auto; would be 345px, it should be 400px, if it's between 400 and 800px it should be 800px, and so on. Unfortunately, I haven't found anything useful to achieve this. Any ideas?
This should be achieved ONLY with HTML and CSS. A jQuery solution could look like this:
$('div').each(resize); function resize() { var height = $(this).css( "height" ); var newHeight = Math.ceil(parseInt(height) / 400) * 400; $(this).css('height', newHeight+'px'); }
Источник: https://stackoverflow.com/questions/344 ... on-content
This is a follow-up to my previous question found here. Is there any way to achieve, I can't describe it better, "step-based heights" on a div? I made a little fiddle to display what I have.
My target is now, that every box has a height that's a multiple of 400px. So if a box with height: auto; would be 345px, it should be 400px, if it's between 400 and 800px it should be 800px, and so on. Unfortunately, I haven't found anything useful to achieve this. Any ideas?
This should be achieved ONLY with HTML and CSS. A jQuery solution could look like this:
$('div').each(resize); function resize() { var height = $(this).css( "height" ); var newHeight = Math.ceil(parseInt(height) / 400) * 400; $(this).css('height', newHeight+'px'); }
Источник: https://stackoverflow.com/questions/344 ... on-content
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Можете ли вы ограничить подписания клипа Uiview определенными сторонами представления?
Anonymous » » в форуме IOS - 0 Ответы
- 1 Просмотры
-
Последнее сообщение Anonymous
-