CefSharp自定义滚动条样式

cefsharp,自定义,滚动条,样式 · 浏览次数 : 21

小编点评

**自定义滚动条样式示例** ```csharp public MainWindow() { InitializeComponent(); Browser.FrameLoadEnd += Browser_FrameLoadEnd; } private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e) { if (e.Frame.IsMain) { // 定义 CSS样式 string style = @" ::-webkit-scrollbar { width: 6px; height: 6px; background-color: #FFF; cursor: pointer; } ::-webkit-scrollbar-track { box-shadow: inset 0 0 6px rgba(155, 155, 155, 0.3); border-radius: 5px; background-color: #FFF; cursor: pointer; } ::-webkit-scrollbar-button { display: none; } ::-webkit-scrollbar-thumb { border: 1px solid #c6c6c6; border-radius: 5px; background: #c6c6c6; cursor: pointer; background-repeat: no-repeat; background-position: center; } "; // 将样式注入浏览器 Browser.GetMainFrame().ExecuteJavaScriptAsync(style); } } ``` ** CSS样式** ```css ::-webkit-scrollbar { width: 6px; height: 6px; background-color: #FFF; cursor: pointer; } ::-webkit-scrollbar-track { box-shadow: inset 0 0 6px rgba(155, 155, 155, 0.3); border-radius: 5px; background-color: #FFF; cursor: pointer; } ::-webkit-scrollbar-button { display: none; } ::-webkit-scrollbar-thumb { border: 1px solid #c6c6c6; border-radius: 5px; background: #c6c6c6; cursor: pointer; background-repeat: no-repeat; background-position: center; } ``` **注意** * 此示例仅用于 V8contenteditable 框架。 * 样式必须在 `head` 标签的 `