Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for float issue by inserting before element instead of appending. #4

Closed
wants to merge 3 commits into from

2 participants

This page is out of date. Refresh to see the latest.
Showing with 7 additions and 14 deletions.
  1. +2 −11 demo.html
  2. +5 −3 src/responsive-containers.js
View
13 demo.html
@@ -69,15 +69,6 @@
border: none;
text-align: center;
}
- .menu li {
- width: 49%;
- float: left;
- border-left: 1px solid #AAA;
- }
- .menu li.wide {
- width: 100%;
- float: none;
- }
.codex {
color: green;
@@ -166,8 +157,8 @@
<script>
- var els = document.querySelectorAll(".menu li");
- SelectorQueries.add(els, "max-width", "15em", "wide");
+ var els = document.querySelectorAll(".menu");
+ SelectorQueries.add(els, "max-width", "30em", "wide");
SelectorQueries.ignoreDataAttributes();
</script>
View
8 src/responsive-containers.js
@@ -99,7 +99,9 @@ THE SOFTWARE.
el.className += " " + rule[4];
}
} else {
- el.className = (" " + el.className + " ").replace(" " + rule[4] + " ", " ");
+ var class_name = el.className.replace(new RegExp('(^| )'+rule[4]+'( |$)'), '$1');
+ class_name = class_name.replace(/ $/, '');
+ el.className = class_name;
}
}
}
@@ -156,14 +158,14 @@ THE SOFTWARE.
return Math.round(val * em);
});
- var originalWidth = function(el, class_name) {
+ var getDefaultWidth = function(el, class_name) {
var test = el.cloneNode(true);
test.className = (" " + test.className + " ").replace(" " + class_name + " ", " ");
test.style.height = 0;
test.style.visibility = "none";
test.style.overflow = "hidden";
var parent = el.parentNode;
- parent.appendChild(test);
+ parent.insertBefore(test, el);
var val = test.offsetWidth;
parent.removeChild(test);
return val;
Something went wrong with that request. Please try again.