Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Selector for the margin-top and margin-bottom of an element

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #245308

    So I want to have different :hover cursor in an element, lets say pointer on the element, n-resize for the margin-top, and s-rezie for the margin bottom. I know I can make a different div before and after the span element to have the selector that. The problem is, the tree HTML is auto-generated from a JS library (fancytree, a tree library), I’m afraid if I manually insert another element before and after the span, the functionality will breaks. Any help is appreciated, thanks!

    Here is the following image explaining the situation.
    http://imgur.com/a/R18Z7

    Here is the LESS code, the before and after doesn’t work (I know this is not the solution, I just provides what I tried)

    span.fancytree-node {
        /* See #117 */
        display: inherit; // #117, resolves to 'display: list-item;' for standard trees
        width: 100%;
        margin-top: @fancy-node-v-spacing;
        margin-bottom: @fancy-node-v-bottom-spacing;
        min-height: @fancy-line-height;
        cursor: pointer;
        :before {
            cursor: n-resize;
        }
        :after {
            cursor: s-resize;
        }
    }
    

    EDIT:
    To make it more clear, I need the margin, I can’t add another element above and below the element, because that margin is used by my JS library to detect drag n drop placement.

    #245310
    JamiePatt
    Participant

    Why not just something like:

    .element:before,  .element:after{
    content: ' ';
    height: 10px;
    }
    .element:before {cursor:n-resize;}
    .element:after {cursor:s-resize;}
    .element {cursor:pointer;}
    
    #245313

    Ah sorry, to make it more clear, I need the margin, I can’t add another element above and below the element, because that margin is used by my JS library to detect drag n drop placement.

    #245315

    Sorry @JamiePatt,
    You are right, I need to use :before :after,
    but your code is incomplete,
    because my CSS skill is SUCKS so I can’t adopt it to my usage.

    Someone over at Stackoverflow solved this problem in case anyone have the same problem http://stackoverflow.com/a/39381696/3390639

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.