html - Flexbox, absolute positioning and 100% height -


i've run bit of problem while playing around flexbox inside absolute box, inside defined height div (i'll explain along way).

first off, here's page demo, might easier grasp problem: http://geekometric.com/test_new_homepage.html

as can see, when hover block, text appears below doesn't quite show fully.

i have main div (let's call $main) hover part 600x250px overflow: hidden, , inside it, 2 divs: title , text (say $title , $text), appear after 1 (regular flow).

$title can take 2 lines, height set auto. $text set 100% height, positioned in relative , set display: flex. inside div ($intro) positioned in absolute, top: 100% (which switches 0 when hovered) , align-self: flex-end in order keep @ bottom of $main. (this keep text being stuck title - breathe)

the structure goes this, basically:

<div class="main">  <div class="title">i'm title!</div>  <div class="text">   <div class="intro"><p>just bunch of long paragraphs of text</p></div>  </div> </div> 

now, can see on demo, $text's height set 100%, expected height $main minus $title's heights, here seems $main's height, makes $text block overflow, , when hover block make text appear, locks bottom outside $main , cuts off part of text.

would have clue has how can make $text have expected height, knowing can't predict $title's height (and can't use calc(), @ least as know) , i don't want use javascript in way?

you can check source code on demo - know code bit heavy i'm testing things out, i'll clean when put online. ;)

thanks can provide, , hope clear - please let me know if need more details!

cheers,
chris

i've gone through , reworked code without using heights block text or title text , using flex. if use display: flex; only on container contain flexible items within it, tell each item how flexible (ie. flex-grow: 1;), you'll result you're looking for. here's link fiddle put using initial code , reworking code. let me know if have questions or need clarification on anything.

body {    font-family: 'bitter', georgia, serif;    width: 673px;  }  { color: #161616; text-decoration: none; }  * { box-sizing: border-box; }    .home_post_new * { transition: .5s all; }    .home_post_new {    background-position: right center;    background-repeat: no-repeat;    width: 100%;    height: 250px;    position: relative;    overflow: hidden;    margin-bottom: 20px;  }    .home_post_new_text {    float: right;    display: flex;    flex-direction: column;    width: 600px;    height: 100%;    background: hsla(0,0%,100%,0);    color: #fff;    position: relative;  }    .home_post_new:hover .home_post_new_text {    background: hsla(0,0%,0%,.33);  }    .home_post_new_block {    flex-grow: 2;    position: relative;    top: 250px;    width: 100%;    padding: 16px 16px 32px;    font-size: .9em;    line-height: 125%;    text-shadow: 0 1px 0 hsla(0,0%,0%,.75), 0 0 5px hsla(0,0%,0%,.75);  }  .home_post_new:hover .home_post_new_block {    top: 0;  }  .home_post_new_title {    flex-grow: 1;    font-family: 'source sans pro', arial, sans-serif;    font-size: 1.625em;    line-height: 1.333em;    width: 100%;    padding: 4px 8px 16px;    text-shadow: 0 1px 0 hsla(0,0%,0%,.75), 0 0 1px hsla(0,0%,0%,.75), 0 1px 5px hsla(0,0%,0%,.75);    background: -moz-linear-gradient(top, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0) 100%);    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.65)), color-stop(100%,rgba(0,0,0,0)));    background: -webkit-linear-gradient(top, rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);    background: -o-linear-gradient(top, rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);    background: -ms-linear-gradient(top, rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);    background: linear-gradient(to bottom, rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%);  }    .home_post_new_more {    position: absolute;    right: 0;    bottom: -50%;    padding: 4px 8px;    font-family: 'source sans pro', arial, sans-serif;    color: #fff;    text-shadow: 0 1px 0 hsla(0,0%,0%,.75), 0 0 5px hsla(0,0%,0%,.75);    border-style: solid;    border-width: 1px 0 0 1px;    border-color: currentcolor;    border-radius: 0;     border-top-left-radius: 2px;    text-transform: uppercase;    letter-spacing: 1px;    background: hsla(0,0%,0%, .5);  }  .home_post_new_more:hover {    color: #009884;    cursor: pointer;  }  .home_post_new:hover .home_post_new_more {    bottom: 0;  }      .home_post_new_meta {    width: calc(100% - 600px);    height: 100%;    text-align: center;    color: #009884;  }    .home_post_new_date {    background: #009884;    color: #eee;    padding: 24px 0 0;    height: 50%;  }    .home_post_new_date_day {    font-size: 250%;    font-weight: bold;  }    .home_post_new_date_month {    font-family: 'source sans pro', arial, sans-serif;    text-transform: uppercase;    font-size: 150%;    border-top: 1px solid #eee;    display: inline-block;    margin-top: 8px;    padding-top: 4px;  }    .home_post_new_date_comments {    color: currentcolor;    display: inline-block;    border-radius: 50%;    border-bottom-right-radius: 0;    width: 42px;    height: 42px;    margin-top: 32px;     padding: 12px 4px;    border: 1px solid currentcolor;    margin-top: calc(50% - 4px);  }    .home_post_new_text:after {    clear: both;    overflow: auto;    zoom: 1;  }
<div class="home_post_new" style="background-image: url(http://geekometric.com/wp-content/uploads/2014/11/fetch_ifl.jpg);">    <a class="home_post_new_text" href="#">      <div class="home_post_new_title">[test] infamous : first light</div>      <div class="home_post_new_block">        <p>après les aventures de delsin, voici infamous : first light, qui propose de jouer dans la peau d’un personnage secondaire de second son : fetch. une aventure qui est, à l’instar de festival of blood pour infamous 2, une extension ne nécessitant pas le jeu de base. même ville, différents pouvoirs (enfin, pas vraiment), nouvelle histoire et un mode de jeu en plus… de quoi s’amuser un peu ! mais qu’est-ce que ça vaut ? voyons cela.</p>      </div>    </a>    <div class="home_post_new_more">lire la suite &rarr;</div>    <div class="home_post_new_meta">      <div class="home_post_new_date" title="30 novembre 2014">        <div class="home_post_new_date_day">30</div>        <div class="home_post_new_date_month">nov</div>      </div>      <a href="#" class="home_post_new_date_comments" title="2 commentaires">2</a>    </div>  </div>    <div class="home_post_new" style="background-image: url(http://geekometric.com/wp-content/uploads/2014/11/monumentvalley.jpg);">    <a class="home_post_new_text" href="#">      <div class="home_post_new_title">[test] monument valley</div>      <div class="home_post_new_block">        <p>profitant d’un crédit de 3€ offert par amazon sur leur app shop, je me suis laissé tenter par monument valley, ayant entendu du bien du jeu et étant assez intrigué son style. au pire, je ne perdais rien dans l’affaire… après plusieurs courtes séances, j’ai terminé le jeu et j’ai donc pu forger un avis assez complet dessus, malgré le fait que monument valley soit un « petit jeu », mais il ne faut pas négliger son ambition et potentiel pour autant. </p>      </div>    </a>    <div class="home_post_new_more">lire la suite &rarr;</div>    <div class="home_post_new_meta">      <div class="home_post_new_date" title="28 octobre 2014">        <div class="home_post_new_date_day">17</div>        <div class="home_post_new_date_month">nov</div>      </div>      <a href="#" class="home_post_new_date_comments" title="37 commentaires">37</a>    </div>  </div>    <div class="home_post_new" style="background-image: url(http://geekometric.com/wp-content/uploads/2014/11/interstellar.jpg);">    <a class="home_post_new_text" href="#">      <div class="home_post_new_title">[séance ciné] interstellar</div>      <div class="home_post_new_block">        <p>alors comme ça le prochain long-métrage de christopher nolan est sorti ? la science-fiction, c’est mon truc, ça ! je me suis évité tout spoiler possible sur ce film, cette critique en fera autant. j’ai eu le plaisir de voir interstellar en imax, ma première séance dans ce format d’ailleurs, ce qui ne m’a pas déçu. bon allez, on va voir tout ça, 3… 2… 1… décollage !</p>      </div>    </a>    <div class="home_post_new_more">lire la suite &rarr;</div>    <div class="home_post_new_meta">      <div class="home_post_new_date" title="28 octobre 2014">        <div class="home_post_new_date_day">11</div>        <div class="home_post_new_date_month">nov</div>      </div>      <a href="#" class="home_post_new_date_comments" title="37 commentaires">37</a>    </div>  </div>    <div class="home_post_new" style="background-image: url(http://geekometric.com/wp-content/uploads/2014/11/johnwick.jpg);">    <a class="home_post_new_text" href="#">      <div class="home_post_new_title">[séance ciné] john wick</div>      <div class="home_post_new_block">        <p>encore un film qui est sorti de nulle part pour moi, john wick attiré mon attention, notamment grâce à la présence de l’immortel keanu reeves sur l’affiche. malgré la minuscule salle (vous savez, celle pour 40 personnes qu’on paie aussi cher que les énormes salles…), j’ai bien pu me mettre dans le film. chargez vos fusils, on va voir ce que ça donne.</p>      </div>    </a>    <div class="home_post_new_more">lire la suite &rarr;</div>    <div class="home_post_new_meta">      <div class="home_post_new_date" title="28 octobre 2014">        <div class="home_post_new_date_day">28</div>        <div class="home_post_new_date_month">oct</div>      </div>      <a href="#" class="home_post_new_date_comments" title="37 commentaires">37</a>    </div>  </div>    <div class="home_post_new" style="background-image: url(http://geekometric.com/wp-content/uploads/2013/12/tlou_goodies.jpg);">    <a class="home_post_new_text" href="#">      <div class="home_post_new_title">[avis de passage] goodies last of : press kit, figurine…</div>      <div class="home_post_new_block">        <p>bon, c'est un arrivage qui date un peu, mais je tenais à vous présenter quelques goodies tirés de last of us, non seulement parce que j'adore ce jeu mais parce que ces chouettes objets sont plutôt réussis, et étant donné qu'ils ne sont vus que par mes petits yeux, pourquoi ne pas vous en faire profiter un peu également ? et ce n'est certainement pas un moyen de faire du contenu en attendant que je fasse mes tests de jeux ps4, je vous assure ! bon j'ai pris un paquet de photos, c'est cadeau.</p>      </div>    </a>    <div class="home_post_new_more">lire la suite &rarr;</div>    <div class="home_post_new_meta">      <div class="home_post_new_date" title="28 octobre 2014">        <div class="home_post_new_date_day">28</div>        <div class="home_post_new_date_month">oct</div>      </div>      <a href="#" class="home_post_new_date_comments" title="3 commentaires">3</a>    </div>  </div>


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -