CSS Flex: Last And First Item In A Row Selector
I'm having a problem trying to select the last element of the first row and the first element of the last row of a flex container. My flex container is flex-wrap: wrap; and all my
Solution 1:
I don't see any simple solution, but this way is a little bit clean:
var fun = function () {
var flex = $(".container");
var cw = flex.width(); // container width
var ch = flex.height(); // container height
var tl = $(".ui-widget:visible:first");
var tr = $(".ui-widget:visible").closestToOffset({left: cw-20, top: -20});
var bl = $(".ui-widget:visible").closestToOffset({left: 0+20, top: ch+20});
// those '20's are to to throw away from the others elements
var br = $(".ui-widget:visible:last");
$(".ui-widget").removeClass(function (index, css) {
return (css.match(/\ui-corner-\S+/g) || []).join(' ');
});
tl.addClass("ui-corner-tl");
tr.addClass("ui-corner-tr");
bl.addClass("ui-corner-bl");
br.addClass("ui-corner-br");
Post a Comment for "CSS Flex: Last And First Item In A Row Selector"