简体   繁体   中英

scale a div after children or 100% of window height

I have a question regarding height: 100%
how do you scale a div after the height of the window and at the same time after it's content
(So one overrides the other if it's not true)?

standard height 100% css
How dose one scale the div after 100% or full height of it's content

just ask and i will provide more info if something was unclear

I would recommend using Flexbox as I do in the snippet, but the key to viewport height and then expanding is min-height: 100vh ; The vh property (short for viewport height) is pretty well-supported.

Please see the snippet for a demonstration.

 $(function() { $(document).on('click', '.deck', function(evt) { $newEl = $('#copy-me').clone().text(HolderIpsum.words(~~(Math.random() * 20), true)); $('.deck').append($newEl); }); });
 body { background-color: gray; } .deck { width: 100vw; min-height: 100vh; display: flex; flex-wrap: wrap; background-color: white; padding: 1em; align-items: stretch; } .deck::after { content: 'CLICK ANYWHERE IN WHITE BOX TO ADD MORE CONTENT'; order: 999; background-color: transparent !important; color: gray !important; border-color: gray !important; } .deck::after, .deck__card { flex: 33% 0 1; padding: 0.5em; margin: 1em; border: 2px solid orange; background-color: blue; color: orange; font-size: 2em; font-family: sans-serif; height: auto; min-height: 33vh; order: 1; }
 <script src="https://cdn.jsdelivr.net/holder-ipsum/0.1/holder-ipsum.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="deck"> <div id="copy-me" class="deck__card" data-holder-ipsum-mode="words" data-holder-ipsum-words-count="3"></div> </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM