Roo*_*ter 14 css textarea resize cursor css3
我注意到,当悬停和/或点击时,我的文本区域上的调整大小按钮保持为箭头.
在我看来它应该是一个指针.
看到有css要删除或添加调整大小工具到textarea,
resize:none;
Run Code Online (Sandbox Code Playgroud)
和css来改变整个textarea的光标,
cursor:pointer;
Run Code Online (Sandbox Code Playgroud)
但似乎应该有一个css参数来控制调整大小按钮的光标.我一直在四处寻找,但似乎无法找到房产.我可以想一些在javascript或jquery中执行此操作的方法,但看起来有点矫枉过正.
那么有没有办法通过css为textarea的调整大小按钮设置光标?
SpY*_*3HH 17
在jQuery中有一种简单的方法来处理这个问题.
<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>
Run Code Online (Sandbox Code Playgroud)
一条线
$(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":""}); })
Run Code Online (Sandbox Code Playgroud)
小智 5
您可以在元素的“:after”伪元素上使用 CSS 的光标属性:
#block{
display: block;
width:150px;
height:100px;
border: solid black 1px;
background: red;
}
.resizable{
resize: both;
overflow:auto;
position:relative;
}
.resizable:after{
content:"";
position: absolute;
bottom: 0;
right:0;
display:block;
width:8px;
height:8px;
cursor: nwse-resize;
background-color: rgba(255,255,255,0.5)
}Run Code Online (Sandbox Code Playgroud)
<div id="block" class="resizable"></div>Run Code Online (Sandbox Code Playgroud)
(我将半透明的白色背景颜色添加到 :after 伪元素中,以便您可以看到它的位置和大小,但您可以使其不可见)