Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.43 KB | None | 0 0
  1. /**
  2. * Flexbox Spec
  3. */
  4.  
  5. body {
  6. font-family: 'Oxygen', sans-serif;
  7. font-weight: 300;
  8. color: #777;
  9. }
  10.  
  11. hr {
  12. margin: 2em 0;
  13. color: transparent;
  14. border-bottom: .5em solid yellowgreen;
  15. }
  16.  
  17. /* --------------------------------------------- EXAMPLE 1 ----------------------------------------------------------- */
  18. #deals {
  19. display: flex; /* Flex layout so items have equal height */
  20. flex-flow: row wrap; /* Allow items to wrap into multiple lines */
  21. }
  22.  
  23. /* If I resize the view-port, the item shrinks up to the image dimensions */
  24. .sale-item {
  25. xvisibility:collapse;
  26. xbox-sizing: border-box;
  27. display: flex; /* Lay out each item using flex layout */
  28. flex-flow: column; /* Lay out item’s contents vertically */
  29.  
  30. width: 20em;
  31. margin: 1em;
  32. padding: 1em;
  33. border: 0.3em solid #0af;
  34. border-radius: 1em;
  35. background-color: #efefef;
  36. }
  37.  
  38. /* If I comment the last line, img stretches */
  39. .sale-item > img {
  40. xposition: absolute;
  41. order: -1; /* Shift image before other content (in visual order) */
  42. align-self: center; /* Center the image cross-wise (horizontally) */
  43. }
  44. .sale-item > button {
  45. margin-top: auto; /* Auto top margin pushes button to bottom */
  46.  
  47. padding: .5em;
  48. font-size: 1.5em;
  49. font-weight: bold;
  50. color: #fff;
  51. background-color: #f06;
  52. border: 0;
  53. border-radius: .5em
  54. }
  55.  
  56. /* --------------------------------------------- EXAMPLE 3 ----------------------------------------------------------- */
  57. @media (min-width: 60em) { /* 960px */
  58. /* two column layout only when enough room (relative to default text size) */
  59. #example-3 {
  60. display: flex;
  61. }
  62.  
  63. #main_ {
  64. flex: 1; /* Main takes up all remaining space */
  65. order: 1; /* Place it after (to the right of) the navigation */
  66. min-width: 12em; /* Optimize main content area sizing */
  67.  
  68. border: 1px dashed yellowgreen;
  69. }
  70. }
  71.  
  72. /* menu items use flex layout so that visibility:collapse will work */
  73. #example-3 nav > ul > li {
  74. display: flex;
  75. flex-flow: column;
  76. }
  77.  
  78. /* dynamically collapse submenus when not targeted */
  79. #example-3 nav > ul > li:not(:target):not(:hover) > ul {
  80. visibility: collapse;
  81. }
  82. #example-3 nav > ul > li > ul {
  83. xvisibility: collapse;
  84. }
  85. #example-3 nav > ul > li:hover > ul {
  86. xvisibility: visible;
  87. }
  88. #example-3 a {
  89. max-width: 10em;
  90. margin: .2em;
  91. padding: .5em;
  92. text-decoration: none;
  93. color: #f06;
  94. background-color: gold;
  95. border: .1em solid orange;
  96. border-radius: .5em;
  97. }
  98.  
  99.  
  100.  
  101.  
  102. /* --------------------------------------------- EXAMPLE 4 ----------------------------------------------------------- */
  103. .tabs {
  104. display: flex;
  105. position: relative;
  106. margin: 3em;
  107. margin-bottom: 20em;
  108. }
  109. .tabs > * {
  110. min-width: min-content; /* Prevent tabs from getting too small for their content. */
  111. }
  112. .tabs > .current {
  113. order: -1; /* Lower than the default of 0 */
  114. }
  115. .tab {
  116. display: flex;
  117. }
  118. .tab label {
  119. background: #eee;
  120. padding: .8em;
  121. border: 1px solid #ccc;
  122. border-radius: 1em 1em 0 0;
  123. cursor:pointer;
  124. }
  125. .tab [type=radio] {
  126. display: none;
  127. }
  128. .content {
  129. visibility: collapse;
  130. position: absolute;
  131. top: 2.9em;
  132. left: 0;
  133. width: 100%;
  134. background: white;
  135. padding: 1em;
  136. border: 1px solid #ccc;
  137. }
  138. .tab [type=radio]:checked ~ label {
  139. background: white;
  140. border-bottom: 1px solid white;
  141. z-index: 2;
  142. }
  143. .tab [type=radio]:checked ~ label ~ .content {
  144. visibility: visible;
  145. z-index: 1;
  146. }
  147.  
  148.  
  149. /* --------------------------------------------- EXAMPLE 5 ----------------------------------------------------------- */
  150. /* the columns will all be equal-height by default */
  151. #main { display: flex; }
  152. #main > article { order: 2; min-width: 12em; flex: 1; }
  153. #main > nav { order: 1; width: 200px; }
  154. #main > aside { order: 3; width: 200px; }
  155.  
  156. @media all and (max-width: 600px) {
  157. /* Too narrow to support three columns */
  158. #main { flex-flow: column wrap; }
  159. #main > article,
  160. #main > nav,
  161. #main > aside { /* Return them to document order */
  162. order: 0;
  163. width: auto;
  164. }
  165. }
  166.  
  167. #example-5 {
  168. font-family: mono;
  169. color: #fff;
  170. background-color: #555;
  171. padding: .5em;
  172. border-radius: 1em;
  173. text-align: center;
  174. }
  175. #example-5 header,
  176. #main article,
  177. #main nav,
  178. #main aside,
  179. #example-5 footer {
  180. padding: inherit;
  181. background-color: #999;
  182. border-radius: .5em;
  183. }
  184.  
  185. #example-5 header { margin-bottom: .5em;}
  186. #main article { margin: 0 .5em;}
  187. #example-5 footer { margin-top: .5em;}
  188.  
  189.  
  190.  
  191.  
  192.  
  193. /***** SECOND ONE *****/
  194. /* Fluid navigation that changes when resizing the window */
  195. .navigation {
  196. display: flex;
  197. flex-flow: row wrap;
  198. justify-content: flex-end;
  199.  
  200. list-style: none;
  201. margin: 3em 0 0;
  202. background: #66bbcc;
  203. }
  204. .navigation a {
  205. text-decoration: none;
  206. display: block;
  207. padding: 1em;
  208. color: white;
  209. }
  210. .navigation a:hover {
  211. background: hotpink;
  212. }
  213.  
  214. @media all and (max-width: 800px) {
  215. .navigation {
  216. justify-content: space-around;
  217. }
  218. }
  219. @media all and (max-width: 600px) {
  220. .navigation {
  221. flex-flow: column wrap;
  222. padding: 0;
  223. }
  224. .navigation a {
  225. text-align: center;
  226. padding: 10px;
  227. border-top: 1px solid rgba(255,255,255,0.3);
  228. border-bottom: 1px solid rgba(0,0,0,0.1);
  229. }
  230. .navigation li:last-of-type a {
  231. border-bottom: none;
  232. }
  233. }
  234.  
  235. /* Fluid layout that changes when resizing of the window */
  236. .wrapper {
  237. display: flex;
  238. flex-flow: row wrap;
  239.  
  240. font-weight: bold;
  241. text-align: center;
  242. }
  243. .wrapper > * {
  244. flex: 1 100%;
  245. padding: 10px;
  246. }
  247. .header { background: tomato; }
  248. .footer { background: lightgreen; }
  249. .main { background: deepskyblue; text-align: left; }
  250. .aside-1 { background: gold; }
  251. .aside-2 { background: hotpink; }
  252. @media all and (min-width: 600px) {
  253. .aside { flex: 1 auto; }
  254. }
  255. @media all and (min-width: 800px) {
  256. .main { flex: 2 0px; }
  257. .aside-1 { order: 1; }
  258. .main { order: 2; }
  259. .aside-2 { order: 3; }
  260. .footer { order: 4; }
  261. }
  262.  
  263.  
  264.  
  265. /* --------------------------------------------- EXAMPLE 6 ----------------------------------------------------------- */
  266. #flex1,
  267. #flex2 {
  268. display: flex;
  269. flex-flow: row wrap;
  270. width: 300px;
  271.  
  272. margin: 3em;
  273. padding: 0 .2em .2em 0;
  274. background-color: #555;
  275. border-radius: .5em;
  276. }
  277.  
  278. .item {
  279. width: 80px;
  280.  
  281. margin: .2em 0 0 .2em;
  282. padding: .2em;
  283. font-size: 1.2em;
  284. text-align: center;
  285. color: #fff;
  286. background-color: #999;
  287. border-radius: .25em;
  288. }
  289.  
  290. #flex2 .item {
  291. xflex: 0 0 auto;
  292. xflex: 0 1 auto;
  293. xflex: 1 1 auto;
  294. xflex: 1 0 0%;
  295. xflex: 0 0 30%;
  296. xflex: 1 0 30%;
  297. flex: 0 0 0%
  298. }
  299.  
  300.  
  301.  
  302. /* --------------------------------------------- EXAMPLE 7 ----------------------------------------------------------- */
  303. #example-7 > ul {
  304. display: flex;
  305.  
  306. background-color: #efefef;
  307. border-radius: .5em;
  308. }
  309. #example-7 > ul > li {
  310. min-width: min-content; /* Prevent items from getting too small for their content. */
  311.  
  312. list-style-type: none;
  313. margin: .5em 0;
  314. padding: 0 .5em;
  315. border-right: .15em solid;
  316. }
  317. #example-7 > ul > #login {
  318. margin-left: auto;
  319.  
  320. border: 0;
  321. }
  322.  
  323. #example-7 a {
  324. text-decoration: none;
  325. padding: 0 .3em;
  326. }
  327.  
  328. #example-7 a:hover {
  329. color: #efefef;
  330. background-color: #999;
  331. text-decoration: underline;
  332. border-radius: .2em;
  333. }
  334.  
  335.  
  336. /* --------------------------------------------- EXAMPLE 8 ----------------------------------------------------------- */
  337. #example-8 {
  338. display: flex;
  339. }
  340.  
  341. #example-8 .box {
  342. display: flex;
  343. flex-flow: column wrap;
  344. margin: auto;
  345. max-width: 5em;
  346.  
  347. padding: .5em;
  348. padding-bottom: 0;
  349. background-color: #999;
  350. border-radius: 1em;
  351. }
  352.  
  353. #example-8 .box:first-child div {
  354. margin: auto;
  355.  
  356. margin-bottom: .5em; /* :first-child overwrites this =( */
  357. }
  358.  
  359. #example-8 .box:last-child div {
  360. align-self: center;
  361. xjustify-content: center;
  362. xjustify-content: flex-start;
  363. xjustify-content: flex-end;
  364. }
  365.  
  366. #example-8 .box div {
  367. margin-bottom: .5em;
  368. padding: .5em;
  369. background-color: #efefef;
  370. border-radius: .5em;
  371. }
  372.  
  373. /* --------------------------------------------- Example 9 ----------------------------------------------------------- */
  374. #without p {
  375. position: relative;
  376. top: 50%;
  377. transform: translateY(-50%);
  378.  
  379. text-align: center;
  380. margin: 0; padding: 0; /* Only needed for the resizing */
  381. }
  382.  
  383. #with {
  384. display: flex;
  385. align-items: center;
  386. justify-content: center;
  387. }
  388.  
  389. #with p {
  390. text-align: center; /* if you know the exact width of the content, you can use width instead of text-align */
  391. xborder: 1px dashed;
  392. }
  393.  
  394. #without,
  395. #with {
  396. margin: auto 3em;
  397. width: 20em;
  398. height: 6em;
  399. background: #f06;
  400. font: bold 150% sans-serif;
  401. color: #fff;
  402. text-shadow: 0 1px 2px rgba(0,0,0,.5);
  403. resize: both;
  404. overflow: hidden; /* un-comment this if you want to resize the box, but it'll break the #without one, unless you add margin:0; padding:0; */
  405. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement