CSS to change the cursor style of the resize butto

2019-01-25 08:00发布

问题:

I noticed that the resize button on my text area when hovered and/or clicked is staying as an arrow.

It seems to me like it should be a pointer.

seeing as there is css to remove or add the resize tool to a textarea,

resize:none;

and css to change the cursor of the whole textarea,

cursor:pointer;

but it seems like there should be a css parameter to control the cursor of just the resize button. I've been looking around a bit and can't seem to find the property though. I can think of a few ways to do this in javascript or jquery but seems like overkill.

So is there a way to set the cursor for just the resize button of a textarea via css?

回答1:

This is rendered by the browser itself and is not part of HTML, therefore it cannot be styled via CSS.



回答2:

There is a simple way in jQuery to deal with this issue.

<script type="text/javascript">
    $(function() {
        $(document).on('mousemove', 'textarea', function(e) {
            var a = $(this).offset().top + $(this).outerHeight() - 16,  //  top border of bottom-right-corner-box area
                b = $(this).offset().left + $(this).outerWidth() - 16;  //  left border of bottom-right-corner-box area
            $(this).css({
                cursor: e.pageY > a && e.pageX > b ? 'nw-resize' : ''
            });
        })
    });
</script>

See jsFiddle

One line

$(document).on('mousemove', 'textarea', function(e) { var a=$(this).offset().top+$(this).outerHeight()-16,b=$(this).offset().left+$(this).outerWidth()-16;$(this).css({cursor:e.pageY>a&&e.pageX>b?"nw-resize":""}); })


回答3:

That is a browser feature... there aren't any styles for that. Some browsers don't even display re-size corners on text area. Sadly, that probably cannot be altered at this point.