html - How to control which elements will change width more than other? Mixing fluid with static containers inline -
html - How to control which elements will change width more than other? Mixing fluid with static containers inline -
i creating fluid design need place 4 inline fields. first 3 fields 20% width each , 4th 40% and/or minimum of 280px or , split 2 separate fields. because 280px field contain background image split separate buttons.
now, since using percentage on fields , lastly field has static minimum width, beingness moved next line when coming close 600px parent width.
how can assure elements remain in place , forcefulness first 3 elements compress more lastly one?
or how leave lastly field fixed width , stretch first 3?
jsfiddle link
<div style="width: 100%; height: 50px;"> <div style="width: 20%; height: 100%; float: left; background-color: blue; display: block">a</div> <div style="width: 20%; height: 100%; float: left; background-color: green; display: block">b</div> <div style="width: 20%; height: 100%; float: left; background-color: blue; display: block">c</div> <div style="width: 40%; min-width: 280px; height: 100%; float: left; display: block;"> <div style="width: 50%; height: 100%; float: left; background-color: yellow;">d</div> <div style="width: 50%; height: 100%; float: left; background-color: orange;">e</div> </div> </div>
this perfect scenario flexbox. here's take on it: http://jsfiddle.net/7quy9/3/. create sure using browser supports flexbox or utilize latest version of chrome.
in book "functional css," available free on amazon next 1.5 days, consider lot more of flexbox in lastly case: navigation menu. welcome check out if want.
make sure resize jsfiddle preview window see flexbox in action. great spec.
here's html code:
<div id = "main"> <div>1</div> <div>2</div> <div>3</div> <div> <div>4a</div> <div>4b</div> </div> </div>
and here's css:
#main { height: 20px; display: -webkit-flex; display: flex; -webkit-flex-direction: row; flex-direction: row; } #main > div:nth-of-type(-n + 3) { -webkit-flex: 1 1 140px; flex: 1 1 140px; outline: 1px dashed red; } #main > div:nth-of-type(4) { -webkit-flex: 2 0 280px; flex: 2 0 280px; outline: 1px dashed red; display: -webkit-flex; display: flex; -webkit-flex-direction: row; flex-direction: row; } #main > div:nth-of-type(4) > div { -webkit-flex: 1 1 50%; flex: 1 1 50%; outline: 1px dotted blue; }
html css css-float inline
Comments
Post a Comment