我想更改以下 div 右下角的调整大小图标(请参阅下面的代码片段),我还想更改悬停时的光标(例如电子调整大小光标)
我尝试添加:
#resizableDiv::-webkit-resizer {
cursor:e-resize;
background-image: url(some_image.png);
}
Run Code Online (Sandbox Code Playgroud)
但徒然,我怎样才能做到这一点,到底有可能吗?
#resizableDiv::-webkit-resizer {
cursor:e-resize;
background-image: url(some_image.png);
}
Run Code Online (Sandbox Code Playgroud)
#resizableDiv {
overflow:auto;
border:1px;
height:100px;
width:200px;
resize:horizontal;
display:inline-block;
background-color:yellow;
}Run Code Online (Sandbox Code Playgroud)
考虑在单独的嵌套元素中使用图标元素。通过伪元素
的一点帮助,您将能够实现预期的行为,如下面的代码片段所示。
代码片段演示:
#resizableDiv {
overflow:auto;
border:1px;
height:100px;
width:200px;
resize:horizontal;
display:inline-block;
background-color:yellow;
position: relative; /* required */
}
/* Additional */
div#resizableDiv:after {
content: "";
resize: horizontal;
bottom: 0;
right: 0;
cursor: e-resize;
position: absolute;
z-index: 9;
width: 20px;
height: 20px;
}
.resizeUI {
position: absolute;
bottom: 0;
right: 0;
background: inherit;
padding: 0px 3px;
pointer-events: none;
cursor: e-resize;
}Run Code Online (Sandbox Code Playgroud)
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">
<div id="resizableDiv">
Resizable div for a single user working with Chrome
<div class="resizeUI"><i class="fa fa-arrows-h"></i></div>
</div>Run Code Online (Sandbox Code Playgroud)