CSS flex: last and first item in a row selector

后端 未结 1 441
北荒
北荒 2020-12-30 03:16

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-w

相关标签:
1条回答
  • 2020-12-30 03:47

    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");
    
    0 讨论(0)
提交回复
热议问题