CSS scrollbar estilo cross browser [duplicar]


Esta pregunta ya tiene una respuesta aquí:

¿Cómo puedo definir un navegador cruzado de estilo de barra de desplazamiento CSS? Probé este código, solo funciona en IE y opera, pero falló en Chrome, Safari y Firefox.

<style type="text/css">
<!--    
body {
    scrollbar-face-color: #000000;
    scrollbar-shadow-color: #2D2C4D;
    scrollbar-highlight-color:#7D7E94;
    scrollbar-3dlight-color: #7D7E94;
    scrollbar-darkshadow-color: #2D2C4D;
    scrollbar-track-color: #7D7E94;
    scrollbar-arrow-color: #C1C1D1;
}
-->
</style>
 151
Author: Axel, 2011-10-11

6 answers

Los estilos CSS de la barra de desplazamiento son una rareza inventada por los desarrolladores de Microsoft. No son parte del estándar W3C para CSS y, por lo tanto, la mayoría de los navegadores simplemente los ignoran.

 107
Author: Till Helge,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-10-11 11:58:04

El soporte de Webkit para las barras de desplazamiento es bastante sofisticado. Este CSS da una barra de desplazamiento muy mínima, con una pista gris claro y un pulgar más oscuro:

::-webkit-scrollbar
{
  width: 12px;  /* for vertical scrollbars */
  height: 12px; /* for horizontal scrollbars */
}

::-webkit-scrollbar-track
{
  background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb
{
  background: rgba(0, 0, 0, 0.5);
}

Esta respuesta es una fantástica fuente de información adicional.

 139
Author: Drew Noakes,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:26:32

JScrollPane es una buena solución para cruzar las barras de desplazamiento del navegador y se degrada muy bien.

 31
Author: Hussein,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-06-27 22:29:43

NanoScrollerJS es simplemente para usar. Siempre los uso...

Browser compatibility:
  • IE7 +
  • Firefox 3 +
  • Chrome
  • Safari 4 +
  • Opera 11.60 +
Mobile browsers support:
  • iOS 5 +(iPhone, iPad y iPod Touch)
  • iOS 4 (con un polyfill)
  • Android Firefox
  • Android 2.2 / 2.3 navegador nativo (con un polyfill)
  • Android Opera 11.6 (con un polyfill)

Ejemplo de código de la Documentación,

  1. Marcado - El siguiente tipo de estructura de marcado es necesario para que el plugin funcione.

    ... contenido aquí ...
 8
Author: Footniko,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-08-23 09:07:25

A partir de IE6 creo que no se puede personalizar la barra de desplazamiento usando esas propiedades. El artículo de Chris Coyier enlazado arriba entra en detalle sobre las opciones para css propietario de webkit para personalizar la barra de desplazamiento.

Si realmente quieres una solución de navegador cruzado que puedas personalizar completamente, vas a tener que usar algunos JS. Aquí hay un enlace a un buen plugin para él llamado FaceScroll: http://www.dynamicdrive.com/dynamicindex11/facescroll/index.htm

 1
Author: DMTintner,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-01-06 15:06:33

Prueba esto es muy fácil de usar y probado en IE y Safari y FF y funcionó bien y además no hay necesidad de muchos div alrededor de él solo agregue id y funcionará bien, después de vincular los archivos Js y Css. FaceScroll Barra de desplazamiento personalizada

Espero que ayude

Editar Paso 1: Agregue el siguiente script a la sección de su página:

<link href="general.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<script type="text/javascript" src="jquery.ui.touch-punch.min.js"></script>

<script type="text/javascript" src="facescroll.js"></script>
<script type="text/javascript">
    jQuery(function(){ // on page DOM load
        $('#demo1').alternateScroll();
        $('#demo2').alternateScroll({ 'vertical-bar-class': 'styled-v-bar', 'hide-bars': false });  
    })
</script>

Paso 2: Luego, en el CUERPO de su página, agregue el siguiente bloque HTML de ejemplo a su página.

<p><b>Scrollbar (default style) shows onMouseover</b></p>

<div id="demo1" style="width:300px; height:250px; padding:8px; background:lightyellow; border:1px solid gray; resize:both; overflow:scroll">

From Wikipedia- Gunpowder, also known since in the late 19th century as black powder, was the first chemical explosive and the only one known until the mid 1800s.[2] It is a mixture of sulfur, charcoal, and potassium nitrate (saltpeter) - with the sulfur and charcoal acting as fuels, while the saltpeter works as an oxidizer.[3] Because of its 
</div>

<br />

<p><b>Scrollbar (alternate style), always shown</b></p>

<div id="demo2" style="width:400px; height:130px; padding:10px; padding-right:8px; background:lightyellow; border:1px solid gray; overflow:scroll; resize:both;">

From Wikipedia- Gunpowder, also known since in the late 19th century as black powder, was the first chemical explosive and the only one known until the mid 1800s.[2] It is a mixture of sulfur, charcoal, and potassium nitrate (saltpeter) - with the sulfur and charcoal acting as fuels, while the saltpeter works as an oxidizer.[3] Because of its 
</div>
 0
Author: Yousef Altaf,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-24 10:53:56