3 expandable column landscape page in pure CSS -


if can achieved in css:

when not hovered: 3 columns split in average width

enter image description here

when hovered on 1 of column: column expands , squeezes other 2 columns

enter image description here

here's i've been trying:

* {    margin: 0;    padding: 0;    box-sizing: border-box;  }      /* vertical 1:2:1 */    html,  body {    height: 100%;  }    .vertical-divider {    display: flex;    flex-flow: column nowrap;    height: 100%;  }      /* container in page center */    .container {    display: flex;    flex-flow: row nowrap;    background-color: #eee;    flex: 2;  }    .container>.item {    display: flex;    flex-flow: column;    justify-content: left;    align-content: left;    align-items: left;    transition: .3s;    max-width: 50%;    padding-top: 24px;    padding-left: 12px;    background-color: #ccc;    min-width: 10%;    flex: 1;    text-align: left;  }    .container>.item:hover {    transition: .3s;    max-width: 80% !important;    background: #333;    flex: 4;    cursor: pointer;    color: #fff;  }
<!doctype html>  <html>    <head>  </head>    <body>    <div class="vertical-divider">      <div class="container">        <div class="item">          column 1        </div>        <div class="item">          column 2        </div>        <div class="item">          column 3        </div>      </div>    </div>  </body>    </html>

but responsive design (e.g. if want put them vertically if screen narrow) seems hard achieve. i'm asking if there better solution.

flexbox offers clean, modern solution. can transition on flex property. if want make hovered div take more room, adjust value higher number.

.container {    display: flex;  }    .container > div {    flex: 1;    border-right: 2px solid black;    height: 300px;    padding: 10px;    transition: 0.5s flex;  }    .container > div:hover {    flex: 3;  }    .container > div:last-child {    border-right: 0;  }
<div class="container">    <div>col 1</div>    <div>col 2</div>    <div>col 3</div>  </div>

edit new requirement has emerged: make responsive. flexbox makes easy addition changing flex-direction property inside simple media query.

@media screen , (max-width: 700px) {   .container {     flex-direction: column;     height: 100vh;   }    .container > div {     border-right: none;     border-bottom: 2px solid;   } } 

with media query in place, our example complete.

enter image description here

have look.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -