fix flex display issue. code review by LZF
Showing
2 changed files
with
67 additions
and
54 deletions
@@ -37,19 +37,28 @@ function hiddenTips($ele) { | @@ -37,19 +37,28 @@ function hiddenTips($ele) { | ||
37 | } | 37 | } |
38 | } | 38 | } |
39 | 39 | ||
40 | -function isFlexSupport() { | ||
41 | - var flex = document.createElement('p').style.flex, | ||
42 | - webkitFlex = document.createElement('p').style.webkitFlex, | ||
43 | - flexWrap = document.createElement('p').style.flexWrap; | ||
44 | - | ||
45 | - if ((flex === '' || webkitFlex === '') && flexWrap === '') { | ||
46 | - return true; | ||
47 | - } else { | ||
48 | - return false; | ||
49 | - } | 40 | +//function isFlexSupport() { |
41 | +// var flex = document.createElement('p').style.flex, | ||
42 | +// webkitFlex = document.createElement('p').style.webkitFlex, | ||
43 | +// flexWrap = document.createElement('p').style.flexWrap; | ||
44 | +// | ||
45 | +// if ((flex === '' || webkitFlex === '') && flexWrap === '') { | ||
46 | +// return true; | ||
47 | +// } else { | ||
48 | +// return false; | ||
49 | +// } | ||
50 | +//} | ||
51 | + | ||
52 | +function wrapElements(selector, count) { | ||
53 | + $(selector).each(function(idx, el) { | ||
54 | + if (idx % count === 0) { | ||
55 | + $($(selector).slice(idx, idx + count)).wrapAll($('<div class="js-wraper"></div>')); | ||
56 | + } | ||
57 | + }); | ||
50 | } | 58 | } |
51 | 59 | ||
52 | 60 | ||
61 | + | ||
53 | function search() { | 62 | function search() { |
54 | if (searching || end) { | 63 | if (searching || end) { |
55 | return; | 64 | return; |
@@ -84,9 +93,10 @@ function search() { | @@ -84,9 +93,10 @@ function search() { | ||
84 | hiddenTips($('#size-swiper-container')); | 93 | hiddenTips($('#size-swiper-container')); |
85 | hiddenTips($('#reference-swiper-container')); | 94 | hiddenTips($('#reference-swiper-container')); |
86 | 95 | ||
87 | - if (!isFlexSupport()) { | ||
88 | - $('.detail .column').removeClass('column').addClass('oldbox'); | ||
89 | - } | 96 | + //if (!isFlexSupport()) { |
97 | + // $('.detail .column').removeClass('column').addClass('oldbox'); | ||
98 | + //} | ||
99 | + wrapElements('.detail .column', 2); | ||
90 | searching = false; | 100 | searching = false; |
91 | end = true; | 101 | end = true; |
92 | loading.hideLoadingMask(); | 102 | loading.hideLoadingMask(); |
@@ -41,50 +41,53 @@ $basicBtnC:#eb0313; | @@ -41,50 +41,53 @@ $basicBtnC:#eb0313; | ||
41 | } | 41 | } |
42 | 42 | ||
43 | &.table { | 43 | &.table { |
44 | - @include flexbox(( | 44 | + .js-wraper { |
45 | + @include flexbox(( | ||
45 | display: box, | 46 | display: box, |
46 | box-lines: multiple, | 47 | box-lines: multiple, |
47 | box-pack: start | 48 | box-pack: start |
48 | - ), $version: 1); | ||
49 | - @include flexbox(( | ||
50 | - display: flex, | ||
51 | - flex-wrap: wrap, | ||
52 | - justify-content: flex-start | ||
53 | - )); | ||
54 | - width: 100%; | ||
55 | - .column { | ||
56 | - box-sizing: border-box; | ||
57 | - //padding: pxToRem(20px) pxToRem(12px); | ||
58 | - padding: pxToRem(6px) 3%; | ||
59 | - width: 49.9%; | ||
60 | - border: 1px solid #fff; | ||
61 | - font-size: pxToRem(24px); | ||
62 | - background-color: $tableCellC; | ||
63 | - word-wrap: break-word; | ||
64 | - @include flexbox(( | ||
65 | - box-flex: 1.0, | ||
66 | - display: box, | ||
67 | - box-align: center | ||
68 | - ), $version: 1); | ||
69 | - @include flexbox(( | ||
70 | - display: flex, | ||
71 | - align-items: center, | ||
72 | - flex-basis: 49.9% | ||
73 | - )) | ||
74 | - } | ||
75 | - .oldbox{ | ||
76 | - padding: pxToRem(6px) 3%; | ||
77 | - width: 49.9%; | ||
78 | - background-color: $tableCellC; | ||
79 | - box-sizing: border-box; | ||
80 | - border: 1px solid #fff; | ||
81 | - width: 49.9%; | ||
82 | - height: 100%; | ||
83 | - float: left; | ||
84 | - text-overflow:ellipsis; | ||
85 | - white-space:nowrap; | ||
86 | - overflow:hidden; | ||
87 | - } | 49 | + ), $version: 1); |
50 | + @include flexbox(( | ||
51 | + display: flex, | ||
52 | + flex-wrap: wrap, | ||
53 | + justify-content: flex-start | ||
54 | + )); | ||
55 | + } | ||
56 | + width: 100%; | ||
57 | + .column { | ||
58 | + box-sizing: border-box; | ||
59 | + //padding: pxToRem(20px) pxToRem(12px); | ||
60 | + padding: pxToRem(6px) 3%; | ||
61 | + width: 49.9%; | ||
62 | + border: 1px solid #fff; | ||
63 | + font-size: pxToRem(24px); | ||
64 | + background-color: $tableCellC; | ||
65 | + word-wrap: break-word; | ||
66 | + @include flexbox(( | ||
67 | + box-flex: 1.0, | ||
68 | + display: box, | ||
69 | + box-align: center | ||
70 | + ), $version: 1); | ||
71 | + @include flexbox(( | ||
72 | + display: flex, | ||
73 | + align-items: center, | ||
74 | + flex-basis: 49.9% | ||
75 | + )) | ||
76 | + } | ||
77 | + .oldbox{ | ||
78 | + padding: pxToRem(6px) 3%; | ||
79 | + width: 49.9%; | ||
80 | + background-color: $tableCellC; | ||
81 | + box-sizing: border-box; | ||
82 | + border: 1px solid #fff; | ||
83 | + width: 49.9%; | ||
84 | + height: 100%; | ||
85 | + float: left; | ||
86 | + text-overflow:ellipsis; | ||
87 | + white-space:nowrap; | ||
88 | + overflow:hidden; | ||
89 | + } | ||
90 | + | ||
88 | } | 91 | } |
89 | } | 92 | } |
90 | } | 93 | } |
-
Please register or login to post a comment