2017-12-26 7 views
0

jquery Bildlaufleiste | Formattag vs style-Attribut

$(document).ready(function(){ 
 
    $('.scrollcontainer1').scrollbar(); 
 
    $('.scrollcontainer2').scrollbar(); 
 
})
.scrollcontainer1{ 
 
width:200px; 
 
height:200px 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.scrollbar/0.2.11/jquery.scrollbar.css" rel="stylesheet"/> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.scrollbar/0.2.11/jquery.scrollbar.js"></script> 
 
<h1>Width and height in style tag</h1> 
 
<div class="scrollcontainer1 inner-scrollbar"> 
 
jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu 
 
jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu 
 
</div> 
 
<h1>Width and height in style attr</h1> 
 
<div class="scrollcontainer2 inner-scrollbar" style="width:200px;height:200px"> 
 
jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu 
 
jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu jniuniuiubiubiuiuhiuhiuuy hbubu ubiub ubiu uiiu 
 
</div>

Das ist meine Frage. Wenn ich width und height im style-Attribut div width und height verwende, setze automatisch auf content width und height. Aber wenn ich Breite und Höhe in Style-Tags setze, funktioniert es. Ich möchte die Breite und Höhe dynamisch mit PHP ändern. Also ich möchte die zweite Methode verwenden. Können Sie einen Weg vorschlagen, dies zu tun?

Antwort

0

Es scheint, dass diese Bibliothek überschreibt bestehende Inline-Styles:

enter image description here

Ich denke, Ihre sicherste Wette, diese Werte von PHP mit Javascript zu fangen ist und dynamisch die Höhen divs Scrollbar Initialisierung nach ändern.


EDIT:

Also habe ich daran interessiert, wie bei the docs, um sicher diese Fähigkeit zu erreichen und auf der Suche Ich bemerkte, dass sie Set Inline-Stil in einem inneren div und Scrollbar auf die Umhüllung div gelten. Vielleicht ist das auch einen Blick wert.