HTML horizontale aber nicht vertikale Bildlaufleiste ausblenden


279

Ich habe einen HTML-Textbereich mit fester Breite, aber variabler Höhe. Ich möchte overflow:scrolleine vertikale Bildlaufleiste festlegen und anzeigen können, aber keine horizontale. Ich kann overflow:autoaufgrund anderer für meine Situation spezifischer Dinge nicht verwenden .

Ich weiß, dass es mit CSS2 keine Möglichkeit gibt, nur vertikale, aber keine horizontalen Bildlaufleisten anzuzeigen. Kann ich mit JavaScript etwas tun, um die horizontale Bildlaufleiste auszublenden?


3
Nein, mit CSS2 overflow:scroll;gibt es keine Möglichkeit, einen Balken und nicht den anderen anzuzeigen . Es ist inhärent in overflow:scroll; Javascript kann nur das tun, was CSS erlaubt. Aber meine Vermutung ist , dass Sie können verwenden overflow: auto, die Sie gerade nicht wissen , wie. Würden Sie die "anderen Dinge, die für Ihre Situation spezifisch sind" näher erläutern?
Tloflin

Antworten:


575

Sie können CSS wie folgt verwenden:

overflow-y: scroll;
overflow-x: hidden;

2
Ich sehe das als CSS3 und es funktioniert in Firefox nicht, wenn ich es teste. Ich sehe auch, dass dies seit jeher als reine IE-Eigenschaft verfügbar ist.
William Jones

@wiliamjones - Dies funktioniert in Firefox ... haben Sie eine Beispielseite? Könnte ein anderer Grund sein, warum es nicht funktioniert.
Nick Craver

@william - Hier ist ein vollständiges Beispiel dafür, wie es funktioniert, Test in Firefox :) jsfiddle.net/qpZ8k
Nick Craver

Sie haben Recht, es funktioniert mit Firefox, es ist die Prototype-Javascript-Bibliothek, die nicht mit diesem Attribut kompatibel ist, was einfach zu umgehen war. Ist diese Eigenschaft in allen Browsern im Allgemeinen zuverlässig?
William Jones

@williamjones - Ja, normalerweise ist es bei diesen Dingen der Fall, Browser implementieren es, dann ist es später nachträglich ein Standard.
Nick Craver

30

Verwenden Sie CSS. Es ist einfacher und schneller als Javascript.

overflow-x: hidden;
overflow-y: scroll;

22

Deaktivieren Sie die horizontale Bildlaufleiste vollständig, indem Sie diesen Code hinzufügen.

body{
  overflow-x: hidden;
  overflow-y: scroll;
}

9

Durch die Verwendung wrap=virtualin Ihren HTML-Formularfeldern wird die horizontale Bildlaufleiste am unteren Rand des Felds entfernt:

  <textarea name= "enquiry" rows="4" cols="30" wrap="virtual"></textarea>

Siehe Beispiel hier: http://jsbin.com/opube3/2 (Getestet auf FF und IE)


2
<div style="width:100px;height:100px;overflow-x:hidden;overflow-y:auto;background-color:#000000">

2
selector{
 overflow-y: scroll;
 overflow-x: hidden;
}

Arbeitsbeispiel mit Snippet und jsfiddle Link https://jsfiddle.net/sx8u82xp/3/

Geben Sie hier die Bildbeschreibung ein

.container{
  height:100vh;
  overflow-y:scroll;
  overflow-x: hidden;
  background:yellow;
}
<div class="container">

<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p>

<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p>

<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p>

<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p>

</div>


1
.combobox_selector ul {
    padding: 0;
    margin: 0;
    list-style: none;
    border:1px solid #CCC;
    height: 200px;
    overflow: auto;
    overflow-x: hidden;
}

Legt die overflow-xBildlaufgröße für 200 Pixel fest und verbirgt alle horizontalen Bildlaufleisten.


0

Für mich:

.ui-jqgrid .ui-jqgrid-bdiv {
   position: relative;
   margin: 0;
   padding: 0;
   overflow-y: auto;  <------
   overflow-x: hidden; <-----
   text-align: left;
}

Natürlich entfernen Sie die Pfeile

Durch die Nutzung unserer Website bestätigen Sie, dass Sie unsere Cookie-Richtlinie und Datenschutzrichtlinie gelesen und verstanden haben.
Licensed under cc by-sa 3.0 with attribution required.